Search code examples
javaandroidksoap2

ksoap2 requests with String parameters returns null


I am new to android developing,I am using Ksoap2 to access .Net web service and The call is executed just fine without parameters or integer parameters But with String parameters I am getting nothing. the purpose of code below is searching in restaurants by name and returns a list of them.

    Action = "SearchResturant";
    request = new SoapObject(WSDL_TARGET_NAMESPACE, Action);

    PropertyInfo pi = new PropertyInfo();
    pi.setName("name");
     pi.setValue(Name);
    pi.setType(String.class);

    request.addProperty(pi);
   SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
        SoapEnvelope.VER11);
       //   envelope.dotNet = true;
       // envelope.bodyOut = request;

        envelope.setOutputSoapObject(request);

        envelope.setAddAdornments(false);
        envelope.implicitTypes = true;

        HttpTransportSE httpTransport = new HttpTransportSE(SOAP_ADDRESS);
        httpTransport.debug=true;
        httpTransport.setXmlVersionTag("<?xml version=\"1.0\" encoding= \"UTF-8\"?>");

        try
        {
        httpTransport.call(SOAP_ACTION + Action, envelope);

        return httpTransport.responseDump.toString();
        }
        catch (Exception exception)
        {

        isEroor=true;
        return exception.toString();

        }

and this is the response that i get :

<?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><SearchResturantResponse xmlns="http://RST.org/"><SearchResturantResult /></SearchResturantResponse></soap:Body></soap:Envelope>

can anybody help me please?


Solution

  • You Need to add a line after calling the httptransport and return the final result. check this solution it will work

             httpTransport.call(SOAP_ACTION + Action, envelope);
             SoapObject final_result=(SoapObject)envelope.bodyIn;
             return final_result.toString();