Getting Parameter Error In Ksoap 2 Android
I am using calling webservice using ksoap2 in android I am getting this error SoapFault - faultcode: 'soap:Server' faultstring: 'Server was unable to process request. ---> The
Solution 1:
I merged knowledge from Your prev post and from this one. You Have problem with call parameters (fe. lack of slash on the end of namespace "http://23.253.164.20:8096/") and with lack of namespace on parameters uname and pwd. I really recommend to use SoapUI to compare correct request with what You have in transport.requestDump.
Working code:
publicfinalstaticStringURL="http://23.253.164.20:8096/login.asmx";
publicstaticfinalStringNAMESPACE="http://23.253.164.20:8096/";
publicstaticfinalStringSOAP_ACTION_PREFIX="http://23.253.164.20:8096/validLogin";
privatestaticfinalStringMETHOD="validLogin";
public String getFahrenheit(String celsius) {
try {
// SoapEnvelop.VER11 is SOAP Version 1.1 constantSoapSerializationEnvelopeenvelope=newSoapSerializationEnvelope(
SoapEnvelope.VER12);
SoapObjectrequest=newSoapObject(NAMESPACE, METHOD);
PropertyInfofromProp=newPropertyInfo();
fromProp.setName("uname");
fromProp.setValue("test");
fromProp.setType(String.class);
fromProp.setNamespace(NAMESPACE);
request.addProperty(fromProp);
PropertyInfotoProp=newPropertyInfo();
toProp.setName("pwd");
toProp.setValue("test");
toProp.setType(String.class);
toProp.setNamespace(NAMESPACE);
request.addProperty(toProp);
//bodyOut is the body object to be sent out with this envelope
envelope.bodyOut = request;
envelope.implicitTypes=true;
HttpTransportSEtransport=newHttpTransportSE(URL);
transport.debug=true;
try {
// transport.call(NAMESPACE + SOAP_ACTION_PREFIX + METHOD, envelope);
transport.call(SOAP_ACTION_PREFIX, envelope);
} catch (IOException e) {
e.printStackTrace();
} catch (XmlPullParserException e) {
e.printStackTrace();
}
//bodyIn is the body object received with this envelopeif (envelope.bodyIn != null) {
//getProperty() Returns a specific property at a certain index.SoapPrimitiveresultSOAP= (SoapPrimitive) ((SoapObject) envelope.bodyIn)
.getProperty(0);
System.out.println(resultSOAP.toString());
}
Post a Comment for "Getting Parameter Error In Ksoap 2 Android"