Search code examples
androidweb-servicesparametersksoap2

Android ksoap2 parameter issues


I am trying to pass a parameter to my service, the code runs but the service never receives the parameters?? The call works, I simply add the variable then get it back, when getting it back I discover the webservice never received it!

Thanks for your 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();
        }

Solution

  • not sure about why is not working, but I remember using it with

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

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