xml—用java创建saop消息

osh3o9ms  于 2021-07-12  发布在  Java
关注(0)|答案(1)|浏览(455)

我试图用java创建一个saop消息,我得到了一个错误
javax.xml.soap.soapexception:无法为soap创建消息工厂:无法创建saaj元工厂:找不到提供程序com.sun.xml.internal.messaging.saaj.soap.saajmetafactoryimpl
我的密码是

  1. MessageFactory messageFactory = MessageFactory.newInstance();
  2. SOAPMessage soapMessage = messageFactory.createMessage();
  3. createSoapEnvelope(soapMessage);
  4. MimeHeaders headers = soapMessage.getMimeHeaders();
  5. headers.addHeader("SOAPAction", soapAction);
  6. soapMessage.saveChanges();
  7. /* Print the request message, just for debugging purposes */
  8. System.out.println("Request SOAP Message:");
  9. soapMessage.writeTo(System.out);
  10. System.out.println("\n");
  11. return soapMessage;
  12. }```
  13. I am using jdk14, what could be the solution?
hi3rlvi2

hi3rlvi21#

作为一个错误 com.sun.xml.internal.messaging.saaj.soap.SAAJMetaFactoryImpl not found 需要为该类添加依赖项。
在pom.xml中添加以下依赖项。

  1. <dependency>
  2. <groupId>com.sun.xml.messaging.saaj</groupId>
  3. <artifactId>saaj-impl</artifactId>
  4. <version>1.5.1</version>
  5. </dependency>

相关问题