我收到以下SOAP响应
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<ns0:Get_Response xmlns:ns0="urn:DAL:OrderShim_WS">
<ns0:Order_Number>Order001165</ns0:Order_Number>
</ns0:Get_Response>
</soapenv:Body>
</soapenv:Envelope>
我需要从上面的响应中得到Order_Number
。
import javax.xml.soap.MessageFactory;
import javax.xml.soap.MimeHeaders;
import javax.xml.soap.SOAPBody;
import javax.xml.soap.SOAPConnection;
import javax.xml.soap.SOAPConnectionFactory;
import javax.xml.soap.SOAPElement;
import javax.xml.soap.SOAPEnvelope;
import javax.xml.soap.SOAPHeader;
import javax.xml.soap.SOAPMessage;
import javax.xml.soap.SOAPPart;
public class Test {
public static void main(String[] args) {
try {
SOAPConnectionFactory soapConnectionFactory = SOAPConnectionFactory.newInstance();
SOAPConnection soapConnection = soapConnectionFactory.createConnection();
String url = "http://devlocal:8080/arsys/services/";
SOAPMessage soapResponse = soapConnection.call(createSOAPRequest(), url);
soapResponse.writeTo(System.out);
soapConnection.close();
} catch (Exception e) {
System.out.println("Exception : " + e);
}
}
}
我可以得到响应。但是我如何得到Order_Number
的值。
我使用的是Java。
1条答案
按热度按时间c2e8gylq1#
您应该检索
SOAPBody
对象并迭代其节点,如下所示: