Hello,
I'm trying to send a SOAP request and receive SOAP response.
But, I'm not able to get the response object, It is coming as NULL.
The code goes like this :
public class SoapRequest { public static void main(String[] args) { try { MessageFactory mf = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL); SOAPMessage sm = mf.createMessage(); SOAPBody sb = sm.getSOAPBody(); QName bodyName = new QName("http://ec2-184-73-115-196.compute-1.amazonaws.com/foundation-webapp/services/wsservice?wsdl", "getServiceListByHostName", "urn"); SOAPBodyElement bodyElement = sb.addBodyElement(bodyName); QName qn = new QName("hostName"); SOAPElement quotation = bodyElement.addChildElement(qn); quotation.addTextNode("i-e3aeee88@ami-29ef0840"); System.out.println("\n Soap Request:\n"); sm.writeTo(System.out); System.out.println(); SOAPConnectionFactory soapConnectionFactory = SOAPConnectionFactory.newInstance(); SOAPConnection connection = soapConnectionFactory.createConnection(); URL endpoint = new URL("http://ec2-184-73-115-196.compute-1.amazonaws.com/foundation-webapp/services/wsservice?wsdl"); SOAPMessage response = connection.call(sm, endpoint); connection.close(); System.out.println("SOAP Reponse : " + response.getContentDescription()); } catch (Exception ex) { ex.printStackTrace(); } } }
Thanks in Advance.
Abhi