Home:ALL Converter>XmlPullParserException in Android SOAP Webservices

XmlPullParserException in Android SOAP Webservices

Ask Time:2012-05-29T19:16:01         Author:user1423421

Json Formatter

I want to consume soap webservices from andriod websevice program by using ksoap2. For that I have written the following code. When I run this in Android emulator I am not getting the response in my logcat. My webservices return type result is XML file .

public class SoapWebservicesExampleActivity extends Activity {
    /** Called when the activity is first created. */
    final String NAMESPACE = "urn:sap-com:document:sap:soap:functions:mc-style";
    final String URL = "http://***********:8000/sap/bc/srt/wsdl/srvc_14DAE9C8D79F1EE196F1FC6C6518A345/wsdl11/allinone/ws_policy/document?sap-client=800&sap-user=*******&sap-password=*********";

//i am appending the Username and password as URL Parameters.

    final String METHOD_NAME = "Z_GET_CUST_GEN";
    final String SOAP_ACTION = "urn:sap-com:document:sap:soap:functions:mc-style/Z_GET_CUST_GEN";

// i am getting the method name tns from WSDL file.

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME); // set up
        request.addProperty("Input", "1460");
        //  request.addProperty("Langu", "d");

//one property in the webservices 

        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11); // put all required data into a soap
        envelope.dotNet = true;
        envelope.setOutputSoapObject(request);
        HttpTransportSE httpTransport = new HttpTransportSE(URL);
        httpTransport.debug = true;
        try {
            httpTransport.call(SOAP_ACTION, envelope);

// by using call method we can call the services

            SoapObject response = (SoapObject)envelope.getResponse();
            String str = response.getProperty(0).toString();
            System.out.println("theeeeeeeeeee"+str);

//printing the respose here

        }
        catch(SocketException ex){
            ex.printStackTrace();

        } catch (Exception e) {
               e.printStackTrace();
        }
    }

}

But here problem is I got this exception i am adding ksoap2 jar file.

            05-29 15:37:54.403: WARN/System.err(383): org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope (position:START_TAG <{http://schemas.xmlsoap.org/wsdl/}wsdl:definitions targetNamespace='urn:sap-com:document:sap:soap:functions:mc-style'>@1:686 in java.io.InputStreamReader@40547218)
            05-29 15:37:54.403: WARN/System.err(383):     at org.kxml2.io.KXmlParser.exception(KXmlParser.java:273)

Author:user1423421,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/10798046/xmlpullparserexception-in-android-soap-webservices
drulabs :

That means the property you are adding, i.e.\n\nrequest.addProperty(\"Input\", \"1460\");\n\n\nis improper. Please check the web method that you are calling and make sure that the number of parameters, method name, spelling (that includes case too) of parameters are proper. I get this error all the time this is how you fix it.\n\n((please share your web method too. if the above solution doesn't work))",
2012-05-29T11:24:21
yy