我正在尝试调用一个Web服务,它希望数组作为参数,但我不知道如何做到这一点,我没有wsdl,我想使用javax来做到这一点。
String operation = "TheOperationName";
String urn = "TheWebService";
String destination = "http://my-server/something.php";
// First create the connection
SOAPConnectionFactory soapConnFactory = SOAPConnectionFactory.newInstance();
SOAPConnection connection = soapConnFactory.createConnection();
// Next, create the actual message
MessageFactory messageFactory = MessageFactory.newInstance();
SOAPMessage message = messageFactory.createMessage();
SOAPPart soapPart = message.getSOAPPart();
SOAPEnvelope envelope = soapPart.getEnvelope();
envelope.addNamespaceDeclaration("SOAP-ENC", "http://schemas.xmlsoap.org/soap/encoding/");
// Create and populate the body
SOAPBody body = envelope.getBody();
// Create the main element and namespace
SOAPElement operationItem = body.addChildElement(
envelope.createQName(operation, "ns1"));
//我失去了,我应该创建一个数组
param0 SOAP-ENC:arrayType =“SOAP-ENC:Struct [1]”xsi:type =“SOAP-ENC:Array”
包含我的项目数组
SOAPElement itemElement = myarray.addChildElement("item");
// Add parameters
itemElement.addChildElement("ID_Bug").addTextNode("ID");
itemElement.addChildElement("ID_Release").addTextNode("RELEASE");
// Save the message
message.saveChanges();
// Send the message and get the reply
SOAPMessage reply = connection.call(message, destination);
reply.toString();
// Close the connection
connection.close();
关于如何实现这一目标的任何建议?