Search code examples
androidweb-servicesksoap2

Parameters for SOAP client connection


I use asmx web service for android client application. I need soap_action, method_name, namespace and url for sample SOAP 1.1 request that written below. How can i bring out these parameters for any webservice request? The point i want to learn where these parameters come from. (ex: method_name="GetKullaniciBilgileri" it comes from after body tag)

POST /WebSite1/WebService.asmx HTTP/1.1
Host: localhost
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://kodmerkezi.net/HelloThere"

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <HelloThere xmlns="http://kodmerkezi.net">
      <name>string</name>
    </HelloThere>
  </soap:Body>
</soap:Envelope>

and i run these service as

http://localhost:56053/WebSite1/WebService.asmx?op=HelloThere

Solution

  • Namespace = "http://kodmerkezi.net"

    SOAP_Method = "HelloThere"

    SOAP_Action = "http://kodmerkezi.net/HelloThere"

    URL = "http://localhost:56053/WebSite1/WebService.asmx"

    It is actually easy to extract these fields if you have the WSDL.

    SOAPAction is already mentioned in the WSDL and hence you can use it from there.

    SOAPAction = Namespace + MethodName

    Hence, form the SOAPAction, use the first part (the part with the http://...) as the namespace and the second part as the SOAPMethod.

    Also, MethodName comes after the Body tag which is then followed by the namespace.

    eg. <soap:Body>
    <MethodName xmlns="namespace">
    

    You can get these two from here and then use SOAP_Action = Namespace + MethodName to get the SOAPAction.

    Lastly, the URL refers to the URL of the *.asmx file from where you are running the service.