Generating soap request using ksoap2



I am trying to generate a request in SOAP using ksoap, wherein i send two values to the server and get a response. i keep getting error as:


09-21 16:49:06.676: W/System.err(957): SoapFault - faultcode: 'SOAP-ENV:Client' faultstring: 'Method 'urn:XMLLocReq' not implemented: method name or namespace not recognized' faultactor: 'null' detail: null 09-21 16:49:06.686: W/System.err(957): at org.ksoap2.serialization.SoapSerializationEnvelope.parseBody(SoapSerializationEnvelope.java:136) 09-21 16:49:06.686: W/System.err(957): at org.ksoap2.SoapEnvelope.parse(SoapEnvelope.java:137) 09-21 16:49:06.686: W/System.err(957): at org.ksoap2.transport.Transport.parseResponse(Transport.java:96) 09-21 16:49:06.696: W/System.err(957): at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:189) 09-21 16:49:06.696: W/System.err(957): at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:95) 09-21 16:49:06.696: W/System.err(957): at com.example.wattestingone.YehBaatKarega.communicateKarega(YehBaatKarega.java:44) 09-21 16:49:06.696: W/System.err(957): at com.example.wattestingone.MainActivity$KyaChalRahaHai.doInBackground(MainActivity.java:69) 09-21 16:49:06.696: W/System.err(957): at com.example.wattestingone.MainActivity$KyaChalRahaHai.doInBackground(MainActivity.java:1) 09-21 16:49:06.696: W/System.err(957): at android.os.AsyncTask$2.call(AsyncTask.java:288) 09-21 16:49:06.696: W/System.err(957): at java.util.concurrent.FutureTask.run(FutureTask.java:237) 09-21 16:49:06.696: W/System.err(957): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231) 09-21 16:49:06.696: W/System.err(957): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) 09-21 16:49:06.706: W/System.err(957): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) 09-21 16:49:06.706: W/System.err(957): at java.lang.Thread.run(Thread.java:841)


this is my code:



private final String NAMESPACE = "http://address+port/urn:XMLLocReq/";
private final String URL = "http://address+port/XMLLocReq.wsdl/";
private final String SOAP_ACTION = "";
private final String METHOD_NAME = "getLocation";
public String communicateKarega(String transID, String msis) {
// TODO Auto-generated method stub

SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
request.addProperty("transactionId", transID);
request.addProperty("msisdn", msis);

SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
SoapEnvelope.VER11);

envelope.setOutputSoapObject(request);

HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);

androidHttpTransport.debug = true;
try {
// Involve web service
androidHttpTransport.call(SOAP_ACTION, envelope);
// Get the response
SoapPrimitive getResponse = (SoapPrimitive) envelope.getResponse();
abc = getResponse.toString();

} catch (IOException e) {

e.printStackTrace();

e.printStackTrace();
} catch (XmlPullParserException e) {
System.out.println("XmlPullParserException");

e.printStackTrace();
}
return abc;
}
}


this is the successful request that i tested using soap ui tool:



<soapenv:Envelope xmlns:soapenv="http://ift.tt/sVJIaE" xmlns:urn="urn:XMLLocReq">
<soapenv:Header/>
<soapenv:Body>
<urn:XMLLocReq>
<param-1>
<transactionId>0</transactionId>
<msisdn>76543</msisdn>
</param-1>
</urn:XMLLocReq>
</soapenv:Body>
</soapenv:Envelope>


and this is the wsdl file:



<?xml version="1.0" encoding="UTF-8"?>
<definitions name="XMLLocReq"
targetNamespace="urn:XMLLocReq"
xmlns:tns="urn:XMLLocReq"
xmlns:SOAP-ENV="http://ift.tt/sVJIaE"
xmlns:SOAP-ENC="http://ift.tt/wEYywg"
xmlns:xsi="http://ift.tt/ra1lAU"
xmlns:xsd="http://ift.tt/tphNwY"
xmlns:getLocation="urn:XMLLocReq"
xmlns:SOAP="http://ift.tt/KIQHA2"
xmlns:MIME="http://ift.tt/L9w8xG"
xmlns:DIME="http://ift.tt/Xol4U2"
xmlns:WSDL="http://ift.tt/LcBaVt"
xmlns="http://ift.tt/LcBaVt">

<types>

<documentation>

</documentation>

<schema targetNamespace="urn:XMLLocReq"
xmlns:SOAP-ENV="http://ift.tt/sVJIaE"
xmlns:SOAP-ENC="http://ift.tt/wEYywg"
xmlns:xsi="http://ift.tt/ra1lAU"
xmlns:xsd="http://ift.tt/tphNwY"
xmlns:getLocation="urn:XMLLocReq"
xmlns="http://ift.tt/tphNwY"
elementFormDefault="unqualified"
attributeFormDefault="unqualified">
<import namespace="http://ift.tt/wEYywg"/>
<complexType name="LocRequest">
<sequence>
<element name="transactionId" type="xsd:long" minOccurs="1" maxOccurs="1"/>
<element name="msisdn" type="xsd:string" minOccurs="0" maxOccurs="1" nillable="true"/>
</sequence>
</complexType>
<!-- operation request element -->
<element name="XMLLocReq">
<complexType>
<sequence>
<element name="param-1" type="getLocation:LocRequest" minOccurs="1" maxOccurs="1"/>
</sequence>
</complexType>
</element>
<!-- operation response element -->
<element name="LocResponse">
<complexType>
<sequence>
<element name="result" type="xsd:long" minOccurs="1" maxOccurs="1"/>
<element name="longitude" type="xsd:float" minOccurs="1" maxOccurs="1"/>
<element name="lattitude" type="xsd:float" minOccurs="1" maxOccurs="1"/>
<element name="transactionId" type="xsd:long" minOccurs="1" maxOccurs="1"/>
<element name="msisdn" type="xsd:string" minOccurs="0" maxOccurs="1" nillable="true"/>
</sequence>
</complexType>
</element>
</schema>

</types>

<message name="XMLLocReq">
<part name="parameters" element="getLocation:XMLLocReq"/>
</message>

<message name="LocResponse">
<part name="parameters" element="getLocation:LocResponse"/>
</message>

<portType name="XMLLocReqPortType">
<operation name="XMLLocReq">
<documentation>Service definition of function getLocation__XMLLocReq</documentation>
<input message="tns:XMLLocReq"/>
<output message="tns:LocResponse"/>
</operation>
</portType>

<binding name="XMLLocReq" type="tns:XMLLocReqPortType">
<SOAP:binding style="document" transport="http://ift.tt/LcBaVu"/>
<operation name="XMLLocReq">
<SOAP:operation soapAction=""/>
<input>
<SOAP:body use="literal"/>
</input>
<output>
<SOAP:body use="literal"/>
</output>
</operation>
</binding>

<service name="XMLLocReq">
<documentation>gSOAP 2.7.3 generated service definition</documentation>
<port name="XMLLocReq" binding="tns:XMLLocReq">
<SOAP:address location="http://localhost:80"/>
</port>
</service>

</definitions>

No comments:

Post a Comment