This is the soap request as obtained from SoapUi by feeding the wsdl.
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:typ="http://wsclient.xyz.com/types/">
<soapenv:Header/>
<soapenv:Body>
<typ:loginserviceElement>
<typ:username>test.test</typ:username>
<typ:password>test123</typ:password>
</typ:loginserviceElement>
</soapenv:Body>
</soapenv:Envelope>
But the android code dumped (from logcat) the request as:
<?xml version="1.0" encoding= "UTF-8" ?>
<v:Envelope xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:d="http://www.w3.org/2001/XMLSchema"
xmlns:c="http://schemas.xmlsoap.org/soap/encoding/" xmlns:v="http://schemas.xmlsoap.org/soap/envelope/">
<v:Header />
<v:Body>
<n0:loginservice xmlns:n0="http://wsclient.xyz.com//">
<username>test.test</username>
<password>test1234</password>
</n0:loginservice>
</v:Body>
</v:Envelope>
My question is- Is both the xml request are same or should work interchangeably? If not how can I customize the request to match the one I get from SoapUi?
As mentioned in the reposnce I am getting:
SoapFault - faultcode: 'env:Client' faultstring: 'Caught exception while handling request: unrecognized operation: {http://wsclient.xyz.com//}loginservice' faultactor: 'null' detail: null
Response from SoapUi (what I am trying to achive in anddroid code):
<env:Body>
<ns0:loginserviceResponseElement>
<ns0:result>
<ns0:logintoken>181210281021ahash</ns0:logintoken>
<ns0:hrmsid>0000002</ns0:hrmsid>
</ns0:result>
</ns0:loginserviceResponseElement>
</env:Body>
</env:Envelope>
I have tried many answer as found on SO and other tutorials with out success.
I would be grateful if a reference to good link can be provided that some how clearly describes the different tags like v:Envelope or soapenv:Envelope, n0:loginservice or typ:loginserviceElement or type:loginserviceElement etc
Below is the android code for reference:
public class SoapRequests {
private static final boolean DEBUG_SOAP_REQUEST_RESPONSE = true;
private static final String MAIN_REQUEST_URL = "http://abc.xyz.com/WSClient/WSServiceSoapHttpPort";
private static final String NAMESPACE = "http://wsclient.xyz.com//";
private static final String SOAP_ACTION = "http://wsclient.xyz.com//loginservice";
private static String SESSION_ID;
private final void testHttpResponse(HttpTransportSE ht) {
ht.debug = DEBUG_SOAP_REQUEST_RESPONSE;
if (DEBUG_SOAP_REQUEST_RESPONSE) {
Log.v("SOAP RETURN", "Request XML:
" + ht.requestDump);
Log.v("SOAP RETURN", "
Response XML:
" + ht.responseDump);
}
}
public User getUserData(String name, String pwd){
User user = null;
String methodname = "loginservice";
SoapObject request = new SoapObject(NAMESPACE, methodname);
PropertyInfo userName =new PropertyInfo();
userName.setName("username");
userName.setValue(name);
userName.setType(String.class);
request.addProperty(userName);
PropertyInfo password =new PropertyInfo();
password.setName("password");
password.setValue(pwd);
password.setType(String.class);
request.addProperty(password);
SoapSerializationEnvelope envelope = getSoapSerializationEnvelope(request);
HttpTransportSE ht = getHttpTransportSE();
try {
ht.call(SOAP_ACTION, envelope);
testHttpResponse(ht);
SoapPrimitive resultsString = (SoapPrimitive)envelope.getResponse();
String data = resultsString.toString();
Log.v("***********RESPONSE*******************", data);
} catch (SocketTimeoutException t) {
t.printStackTrace();
} catch (IOException i) {
i.printStackTrace();
} catch (Exception q) {
q.printStackTrace();
}
// some code to set user data
....
return user;
}
private SoapSerializationEnvelope getSoapSerializationEnvelope(SoapObject request) {
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = false;
envelope.implicitTypes = true;
envelope.setAddAdornments(false);
envelope.setOutputSoapObject(request);
return envelope;
}
private final HttpTransportSE getHttpTransportSE() {
HttpTransportSE ht = new HttpTransportSE(Proxy.NO_PROXY,MAIN_REQUEST_URL,60000);
ht.debug = true;
ht.setXmlVersionTag("<?xml version="1.0" encoding= "UTF-8" ?>");
return ht;
}
}
EDIT: RESPONSE from android code:
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns0="http://wsclient.xyz.com/types/">
<env:Body>
<env:Fault>
<faultcode>env:Client</faultcode>
<faultstring>Caught exception while handling request: unrecognized operation: {http://wsclient.hrms.com//}loginservice</faultstring>
</env:Fault>
</env:Body>
</env:Envelope>
See Question&Answers more detail:
os