Note that there are some explanatory texts on larger screens.

plurals
  1. POKSOAP2 Library...Error sending data to asmx webservice
    primarykey
    data
    text
    <p>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.</p> <p>On the webservice, I'm checking if the strings are null. If they are, I return an error code "2405"</p> <pre><code>[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 } </code></pre> <p>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.</p> <p>The following is my android code:</p> <pre><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); </code></pre> <p>Sorry that I can provide you with the namespace, methodname, url, etc. It is against the company policy and I hope you understand. :) </p> <p>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. <br/><br/> <b>UPDATE: </b>I debugged the SOAP request (androidHttpTransport.debug = true) and got the following results for the requestDump and responseDump.</p> <p><strong>Request Dump</strong></p> <pre><code>&lt;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/"&gt; &lt;v:Header /&gt; &lt;v:Body&gt; &lt;LoginUser xmlns="http://tempuri.org" id="o0" c:root="1"&gt; &lt;auth_token i:type="d:string"&gt;TestAuth&lt;/auth_token&gt; &lt;username i:type="d:string"&gt;TestUser&lt;/username&gt; &lt;/LoginUser&gt; &lt;/v:Body&gt; &lt;/v:Envelope&gt; </code></pre> <p><strong>responseDump</strong></p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;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"&gt; &lt;soap:Body&gt; &lt;LoginUserResponse xmlns="http://tempuri.org/"&gt; &lt;LoginUserResult&gt;2405&lt;/LoginUserResult&gt; &lt;/LoginUserResponse&gt; &lt;/soap:Body&gt; &lt;/soap:Envelope&gt; </code></pre> <p><b>UPDATE 2</b><br/> This is what <strong>the server expects:</strong><br/></p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;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/"&gt; &lt;soap:Body&gt; &lt;LoginUser xmlns="http://tempuri.org/"&gt; &lt;auth_token /&gt; &lt;username /&gt; &lt;/LoginUser&gt; &lt;/soap:Body&gt; &lt;/soap:Envelope&gt; </code></pre> <p>This is what the <strong>android application is sending</strong>:<br/></p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;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/"&gt; &lt;v:Header /&gt; &lt;v:Body&gt; &lt;LoginUser xmlns="http://tempuri.org" id="o0" c:root="1"&gt; &lt;auth_token i:type="d:string"&gt;TestAuth&lt;/auth_token&gt; &lt;username i:type="d:string"&gt;TestUser&lt;/username&gt; &lt;/LoginUser&gt; &lt;/v:Body&gt; &lt;/v:Envelope&gt; </code></pre> <p>In addition to this, I've added the following line to the android code: </p> <pre><code>androidHttpTransport.setXmlVersionTag("&lt;?xml version=\"1.0\" encoding=\"utf-8\"?&gt;"); </code></pre> <p>PLEASE HELP! </p> <p>Many thanks!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload