1

I am new in android development, i need to get the XML file from the Webservice by using SOAP message. I have tried my level best to find out SOAP message parsing in Android but, i cannot find out exact solution for the SOAP message parsing. Here i have attached my sample code to parse the SOAP message. Can you please help me to parse the SOAP message in Android? (Response comes in permission denied).

I tried source code given below:

SoapObject request = new SoapObject(NAMESPACE ,METHOD_NAME);
request.addProperty("username","d");
request.addProperty("password","d123");
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet=true;
envelope.setOutputSoapObject(request);envelope.setAddAdornments(true);
HttpTransportSE httpTransport = new HttpTransportSE(URL);  
try 
  {
      httpTransport.call(SOAP_ACTION, envelope); //send request
      SoapObject result=(SoapObject)envelope.bodyIn;
      String results = result.toString();
      tv.setText( ""+results);
  }
  catch (Exception e)
  {
       tv.setText(e.getMessage());
   }

AndroidManifest.Xml file:

<uses-permission android:name="android.permission.INTERNET">
</uses-permission>
1
  • Is REST not an option, also make sure you do this in a background thread separate to the main UI thread like I explained in another question I answered yesterday here stackoverflow.com/questions/8812281/… Commented Jan 11, 2012 at 10:23

2 Answers 2

1

You are missing envelope.getResponse(); in your code, prabably that can be the reason that you are not getting the Response.

You can try,

SoapObject result=(SoapObject)envelope.getResponse();
String results = result.toString();
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks you, but response is same permission denied
Post the exception in the question.
0

You can do it like this

        HttpPost httppost = new HttpPost(webServicePath);
    httppost.setHeader("Content-Type", "text/xml;charset=UTF-8");

    HttpParams params = new BasicHttpParams();
    params.setParameter(CoreProtocolPNames.PROTOCOL_VERSION,
            HttpVersion.HTTP_1_1);

    String soapRequestXML = getXMLAsString();
    soapRequestXML = prepareInputParam(soapRequestXML);

    StringEntity se;
    se = new StringEntity(soapRequestXML, HTTP.UTF_8);
    se.setContentType("text/xml");
    httppost.setEntity(se);

    response = httpClient.execute(httppost);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.