1. Download our Official Android App: Forums for Android!

Apps SOAP Reuest Response problem...

Discussion in 'Android Development' started by satellitemundo, Jul 11, 2011.

  1. satellitemundo

    Thread Starter
    Rank:
    None
    Points:
    15
    Posts:
    29
    Joined:
    Aug 18, 2010

    Aug 18, 2010
    29
    0
    15
    Hi friends,


    I want to sent a SOAP request with some parameter. So basically it is a post request. I am able to fire simple get reuest with no reuest parameter. But now I want to pass some reuest parameter.

    Following is some code which I have tried.

    Code (Java):
    1.         private static String SOAP_ACTION = "http://tempuri.org/GetBookby_Author";
    2.  
    3.     private static String NAMESPACE = "http://tempuri.org/";
    4.     private static String METHOD_NAME = "GetBookby_Author";
    5.  
    6.     private static String URL = "http://xyzsite.xyzsite.com/webservice/mobilesync.asmx";

    Above is taking parameter authorId. Now how to pass it in java call

    Below is my java call


    Code (Java):
    1. SoapObject request=new SoapObject(NAMESPACE, METHOD_NAME);
    2.  
    3.         Hashtable<String, String> table=new Hashtable<String, String>();
    4.         table.put("AuthorID", ""+2);
    5.        
    6.         SoapSerializationEnvelope envelop=new SoapSerializationEnvelope(SoapEnvelope.VER11);
    7.         envelop.properties=table;
    8.         envelop.setOutputSoapObject(request);
    9.        
    10.         HttpTransportSE androidHttpTransport=new HttpTransportSE(URL);
    11.        
    12.         try {
    13.             androidHttpTransport.call(SOAP_ACTION, envelop);
    14.         } catch (IOException e) {
    15.             // TODO Auto-generated catch block
    16.             e.printStackTrace();
    17.         } catch (XmlPullParserException e) {
    18.             // TODO Auto-generated catch block
    19.             e.printStackTrace();
    20.         }
    21.        
    22.         SoapObject result=null;
    23.        
    24.         try {
    25.             result = (SoapObject)envelop.getResponse();
    26.         } catch (Exception e) {
    27.             // TODO Auto-generated catch block
    28.             e.printStackTrace();
    29.         }
    I am not sure I am doing right thing using hash table or not. I tried addProperty and addAttribute methods also. But they all did not gave me favorable results. Please help.
     

    Advertisement

Share This Page

Loading...