Below is my code, which I have written to validate user log in credentials. The web service written using .net
private static final String SOAP_ACTION = "http://tempuri.org/getCredentials";
private static final String OPERATION_NAME = "getCredentials";
private static final String WSDL_TARGET_NAMESPACE = "http://tempuri.org/";
private static final String SOAP_ADDRESS = "http://myStaticIP:portNo/WebSiteName/CommunicationInterface.asmx";
SoapObject request = new SoapObject(WSDL_TARGET_NAMESPACE, OPERATION_NAME);
request.addProperty("username",Username);
request.addProperty("password", Password);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.setOutputSoapObject(request);
HttpTransportSE httptransport = new HttpTransportSE(SOAP_ADDRESS);
try
{
httptransport.call(SOAP_ACTION, envelope);
SoapPrimitive result = (SoapPrimitive) envelope.getResponse();
String value = result.toString();
value_LoginWS = value;
val = value;
login_status = Boolean.valueOf(result.toString());
Log.v("CS return value: -", result.toString());
return value;
}
catch (Exception e)
{
Log.v("Exception Soap" , e.toString());
}
In line "httptransport.call(SOAP_ACTION, envelope)"
I get the exception saying
"org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope (position:START_TAG <html>
@1:7 in java.io.InputStreamReader@41afb3f0)" <br/><br/>
I have no idea what the error is about. This piece of code is worked perfectly for emulator( changing the staticIP to 10.0.2.2:portNo).
Please help me to solve this problem.
Thank you.
The answer to this question as I figure it out is, in the SOAP_ADDRESS string, remove the /WebSiteName part and it works fine. I have tested this in my android device. Works perfectly.
The corrected String should be as follow:
where CommunicationInterface.asmx is the web service name.
other static variables remain same.
Note: This is used when the web site is hosted in IIS.