How to get response from SOAP endpoint in java?

前端 未结 5 1639
悲哀的现实
悲哀的现实 2021-01-21 16:44

I am very new to SOAP, so was looking into some programs online, this is what I came up with but I get a null response, must be some silly thing, but need little help

Pl

5条回答
  •  广开言路
    2021-01-21 17:28

    @Ricky, this is the correct code.

    SOAPBody body = message.getSOAPBody();
    QName bodyName = new QName("http://www.webserviceX.NET", "GetAtomicNumber");
    SOAPBodyElement bodyElement = body.addBodyElement(bodyName);
    SOAPElement symbol = bodyElement.addChildElement("MyMetal");
    symbol.addTextNode("iron");
    SOAPConnection connection = SOAPConnectionFactory.newInstance().createConnection();
    SOAPMessage response = connection.call(message, endpoint);
    connection.close();
    message.writeTo(System.out);
    System.out.println();
    response.writeTo(System.out);
    System.out.println();
    

提交回复
热议问题