marnicola / ksoap2-android

Automatically exported from code.google.com/p/ksoap2-android
0 stars 0 forks source link

Error sending data to asmx webservice #100

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I have an ASMX webservice setup on Microsoft Azure and I'm trying to send data 
to the webservice and receive output using an android application. For this 
purpose, I am using the KSOAP library.

On the webservice, I'm checking if the strings are null. If they are, I return 
an error code "2405"

[WebMethod]
        public string LoginUser(string auth_token, string username)
        {
            // All these tests performed, so someone from outside of out application
            // scope does not attempt to abuse our webservice.
            #region Check for nulls
            if (string.IsNullOrEmpty(auth_token))
                return "2405";
            if (string.IsNullOrEmpty(username))
                return "2405";
            #endregion
        }

In my android application, I am sending the data, but the webservice still 
returns the 2405 error code, which means that the data is not sent.

The following is my android code:

        SoapObject request = new SoapObject(NAMESPACE, method_name);

        PropertyInfo pi = new PropertyInfo();
        pi.setName("auth_token");
        pi.setValue("TestAuth");
        request.addProperty(pi);

        PropertyInfo pe = new PropertyInfo();
        pe.setName("username");
        pe.setValue("TestUser");
        request.addProperty(pe);

        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
                SoapEnvelope.VER11);
        envelope.dotNet = true;

        envelope.setOutputSoapObject(request);
        HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
        androidHttpTransport.call(SOAP_ACTION, envelope);

Sorry that I can provide you with the namespace, methodname, url, etc. It is 
against the company policy and I hope you understand. :)

Nevertheless, I'll go over the error again. After calling the above Android 
code, the webservice returns 2405, which according to the ASMX code is when any 
of the twos values are null. 

Original issue reported on code.google.com by pathachiever11 on 12 Jan 2012 at 1:54

GoogleCodeExporter commented 9 years ago
Request Dump

<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>
    <LoginUser xmlns="http://tempuri.org" id="o0" c:root="1">
      <auth_token i:type="d:string">TestAuth</auth_token>
      <username i:type="d:string">TestUser</username>
    </LoginUser>
  </v:Body>
</v:Envelope>
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>
    <LoginUserResponse xmlns="http://tempuri.org/">
      <LoginUserResult>2405</LoginUserResult>
    </LoginUserResponse>
  </soap:Body>

</soap:Envelope>

Original comment by pathachiever11 on 12 Jan 2012 at 1:54

GoogleCodeExporter commented 9 years ago
So .. what should the request look like?

Original comment by mosa...@gmail.com on 10 Apr 2012 at 6:17

GoogleCodeExporter commented 9 years ago
Closing since no feedback

Original comment by mosa...@gmail.com on 30 Apr 2012 at 7:32