gpt4 book ai didi

java - 在JAVA中创建SOAP消息请求

转载 作者:行者123 更新时间:2023-11-30 07:39:45 25 4
gpt4 key购买 nike

我想在 JAVA 中创建 SOAP 消息请求,如下所示:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"   xmlns:urn="urn:WSFS">
<soapenv:Header/>
<soapenv:Body>
<urn:saveSignedPDF>
<docID>??</docID>
<input>??</input>
</urn:saveSignedPDF>
</soapenv:Body>

有人可以帮我做这件事吗?谢谢

我的代码:

String url = "http://mydomain/scripts/ws4.php";
SOAPMessage soapResponse = soapConnection.call(
createSOAPRequest(documentId, encoded), url);

private static SOAPMessage createSOAPRequest(String documentId,
String fileToUpdate) throws Exception {
MessageFactory messageFactory = MessageFactory.newInstance();
SOAPMessage soapMessage = messageFactory.createMessage();
SOAPPart soapPart = soapMessage.getSOAPPart();
String serverURI = "WSFS";
SOAPEnvelope envelope = soapPart.getEnvelope();
SOAPBody soapBody = envelope.getBody();
SOAPBodyElement element = soapBody.addBodyElement(envelope.createName("saveSignedPDF", "urn", ""));
element.addChildElement("docID").addTextNode(documentId);
element.addChildElement("input").addTextNode(fileToUpdate);
soapMessage.saveChanges();
return soapMessage;
}

最佳答案

jaxws-maven-plugin 可以从您提供的 wsdl 生成您需要的类。

Maven 插件:https://jax-ws-commons.java.net/jaxws-maven-plugin/

示例:http://www.hascode.com/2010/03/how-to-build-a-confluence-soap-client-in-5-minutes/

关于java - 在JAVA中创建SOAP消息请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34853855/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com