Reputation: 217
Can some body please guide me on this.I am totally new to using KSOAP in android.Following are my details in XML.And i want to Send the details in webservice.Please tell me how to addProperty am i doing something wrong there?
<?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>
<CheckLoginWithIPhoneData xmlns="http://tempuri.org/">
<UserName>string</UserName>
<Pin>string</Pin>
<Password>string</Password>
<DeviceID>string</DeviceID>
</CheckLoginWithIPhoneData>
</soap:Body>
</soap:Envelope>
And in java code I have done this:
public void showdetails()
{
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME1);
request.addProperty("UserName","sometext");
request.addProperty("Pin","sometext");
request.addProperty("Password","sometext");
request.addProperty("DeviceID","sometext");
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope( SoapEnvelope.VER11);
envelope.setOutputSoapObject(request);
envelope.dotNet = true;
try {
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
androidHttpTransport.debug=true;
androidHttpTransport.call(SOAP_ACTION1, envelope);
Log.e("RESPONSE",""+androidHttpTransport.responseDump);
SoapObject result = (SoapObject) envelope.bodyIn;
Log.e("result",""+result);
if (result != null)
{
Log.e("val", "" + result.getProperty(0).toString());
}
else
{
Toast.makeText(getApplicationContext(), "No Response",Toast.LENGTH_LONG).show();
}
} catch (Exception e) {
e.printStackTrace();
}
}
I have called the method in background.
However I get the following error when i try to print the RESPONSE Log.e("RESPONSE",""+androidHttpTransport.responseDump);
<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><soap:Fault><faultcode>soap:Client</faultcode><faultstring>
System.Web.Services.Protocols.SoapException: Server did not recognize the value of HTTP Header SOAPAction: https://tempuri.org/CheckLoginWithIPhoneData.
Upvotes: 0
Views: 3261
Reputation: 174
The type of String that you wrote might be incorrect, for example for "Pin" tag if it only accepts integer and if you write char it gives you an error.
Upvotes: 0
Reputation: 25830
Make Sure you have the Variables related to SOAP request as Below :
Generally the SOAP_ACTION
Should be Combination of NAMESPACE
and METHOD_NAME
SOAP_ACTION=NAMESPACE+METHOD_NAME
Sample values of Above Variables :
private static final String SOAP_ACTION = "http://uri.org/GetFormData";
private static final String METHOD_NAME = "GetFormData";
private static final String NAMESPACE = "http://uri.org/";
private static final String URL = "http://inukshk.com/getformsdata/sample.asmx";
Hope it would help you.
Upvotes: 0
Reputation: 1097
request = new SoapObject(Util.getInstance().NAMESPACE, method);
AuthenticateRequest authenticateRequest = (AuthenticateRequest) params[0];
SoapObject authenticate = new SoapObject(Util.getInstance().NAMESPACE, "CheckLoginWithIPhoneData");
authenticate.addProperty("UserName", <value>);
authenticate.addProperty("Pin", <value>);
authenticate.addProperty("Password", <value>);
authenticate.addProperty("DeviceID", <value>);
PropertyInfo propertyInfo1 = new PropertyInfo();
propertyInfo1.namespace = Util.getInstance().NAMESPACE;
propertyInfo1.name = "CheckLoginWithIPhoneData";
request.addProperty(propertyInfo1, authenticate);
Hope this help!
Upvotes: 1