2

I am newbie in SOAP webservice client and getting errors while creating client.

please help me to solve this

//This is request that has to be send using SOAP Envelope POST /DISWebService/DISWebService.asmx HTTP/1.1 Host: 192.168.2.119 Content-Type: application/soap+xml; charset=utf-8 Content-Length: length <?xml version="1.0" encoding="utf-8"?> <soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope"> <soap12:Body> <LoginSystem xmlns="http://tempuri.org/"> <username>string</username> <password>string</password> </LoginSystem> </soap12:Body> </soap12:Envelope> 

Java Code

public static void main(String args[]) { try { // Create SOAP Connection SOAPConnectionFactory soapConnectionFactory = SOAPConnectionFactory .newInstance(); SOAPConnection soapConnection = soapConnectionFactory .createConnection(); String url = "http://192.168.2.119/VISWebService/VISWebService.asmx"; // String url = // "http://192.168.2.119/DISWebService/DISWebService.asmx?op=LoginSystem"; SOAPMessage soapResponse = soapConnection.call(createSOAPRequest(),url); // Process the SOAP Response printSOAPResponse(soapResponse); soapConnection.close(); } catch (Exception e) { System.err .println("Error occurred while sending SOAP Request to Server"); e.printStackTrace(); } } private static SOAPMessage createSOAPRequest() throws Exception { MessageFactory messageFactory = MessageFactory.newInstance(); SOAPMessage soapMessage = messageFactory.createMessage(); SOAPPart soapPart = soapMessage.getSOAPPart(); String serverURI = "http://192.168.2.119/DISWebService/DISWebService.asmx"; // SOAP Envelope SOAPEnvelope envelope = soapPart.getEnvelope(); // SOAP Body SOAPBody soapBody = envelope.getBody(); SOAPElement soapBodyElem = soapBody.addChildElement("LoginSystem"); SOAPElement soapBodyElem1 = soapBodyElem.addChildElement("username"); soapBodyElem1.addTextNode("Chirendu"); SOAPElement soapBodyElem2 = soapBodyElem.addChildElement("password"); soapBodyElem2.addTextNode("verve12*"); MimeHeaders headers = soapMessage.getMimeHeaders(); headers.addHeader("SOAPAction", serverURI ); soapMessage.saveChanges(); /* Print the request message */ System.out.print("Request SOAP Message = "); soapMessage.writeTo(System.out); System.out.println(); return soapMessage; } 

Please help me to create client.

9
  • soapConnection.call(createSOAPRequest(),url); this will make a SOAP request to specified URL. For what purpose you need the client? Commented Oct 26, 2013 at 10:17
  • I want to consume given webservice and need respone to show in UI Commented Oct 26, 2013 at 10:20
  • If I understand it correctly your Web Service client perfectly works and you're asking for a GUI, correct? Commented Oct 26, 2013 at 10:24
  • no webservice is not working properly and while making request it is giving me error Commented Oct 26, 2013 at 10:25
  • 1
    then please show the error (stacktrace)... Commented Oct 26, 2013 at 10:26

1 Answer 1

3

I will suggest debugging in 2 steps

1)Use soapUI and check whether your response in coming or not

2)Use the working example i used from mykong

Sign up to request clarification or add additional context in comments.

1 Comment

using SOAPUI for beginner would be easy to learn by comparing SOAP request

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.