xml—用java创建saop消息

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

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

MessageFactory messageFactory = MessageFactory.newInstance();
        SOAPMessage soapMessage = messageFactory.createMessage();

        createSoapEnvelope(soapMessage);

        MimeHeaders headers = soapMessage.getMimeHeaders();
        headers.addHeader("SOAPAction", soapAction);

        soapMessage.saveChanges();

        /* Print the request message, just for debugging purposes */
        System.out.println("Request SOAP Message:");
        soapMessage.writeTo(System.out);
        System.out.println("\n");

        return soapMessage;
    }```

I am using jdk14, what could be the solution?
hi3rlvi2

hi3rlvi21#

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

<dependency>
    <groupId>com.sun.xml.messaging.saaj</groupId>
    <artifactId>saaj-impl</artifactId>
    <version>1.5.1</version>
</dependency>

相关问题