Problems with ksoap2 settings for Android

I'm trying to pass a parameter to my service, the code starts, but the service never gets the parameters? The call works, I just add the variable and then return it when I return it. I found that the web service never received it!

thanks for the help

final String SOAP_ACTION = "http://NathofGod.com/GetCategoryById"; final String METHOD_NAME = "GetCategoryById"; final String NAMESPACE = " http://NathofGod.com/"; final String URL = "http://10.0.2.2:4021/Service1.asmx"; SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME); PropertyInfo pi1 = new PropertyInfo(); pi1.setName("name"); pi1.setValue("the name"); pi1.setType(String.class); pi1.setNamespace(NAMESPACE); request.addProperty(pi1); SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11); envelope.dotNet = true; envelope.setOutputSoapObject(request); HttpTransportSE conn = new HttpTransportSE(URL); try { conn.call(SOAP_ACTION, envelope); SoapObject response = (SoapObject)envelope.getResponse(); } catch(Exception e) { e.printStackTrace(); } 
0
source share
5 answers

not sure why it doesn't work, but I remember how he used it with

 request.addProperty("name", "my_Name"); 

and it worked fine, otherwise you can check the server side ...

+1
source

This line of code was my problem! !!

 envelope.dotNet = true; 

REMOVE IT

+1
source

Try debugging it according to the instructions on the wiki .

0
source

I cleaned up the code a bit and put it in a function. I'm not sure if something else, but this code works. Thanks for answers.

public SoapObject soap () throws IOException, XmlPullParserException {

  SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME); request.addProperty("name", "myname"); SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11); envelope.dotNet = true; envelope.setOutputSoapObject(request); HttpTransportSE conn = new HttpTransportSE(URL); conn.call(SOAP_ACTION, envelope); //send request SoapObject result=(SoapObject)envelope.getResponse(); return result; } 
0
source

final String NAMESPACE = " http://NathofGod.com/ ";

Change to

 final String NAMESPACE = "http://NathofGod.com/"; 

Remove the white space and create the namespace as it is in your XML request. Please note that it is also case sensitive.

0
source

Source: https://habr.com/ru/post/1439339/


All Articles