android to .net webservice


Last Updated: 2013-01-11 09:44:15
  1. melvintcs

    melvintcs New Member

    i have done the java class for android and .net, but seems like got a minor problem with the layout
    Code (Text):
    1. package com.webservice.test;
    2.  
    3. import android.app.Activity;
    4. import android.os.Bundle;
    5. import org.ksoap2.SoapEnvelope;
    6. import org.ksoap2.serialization.SoapObject;
    7. import org.ksoap2.serialization.SoapPrimitive;
    8. import org.ksoap2.serialization.SoapSerializationEnvelope;
    9. import org.ksoap2.transport.AndroidHttpTransport;
    10. import android.widget.TextView;
    11.  
    12. public class mainScreen extends Activity {
    13.     private static final String SOAP_ACTION = "http://tempuri.org/GetAllEmployees";
    14.     private static final String METHOD_NAME = "GetAllEmployees";
    15.     private static final String NAMESPACE = "http://tempuri.org/";
    16.     private static final String URL = "http://max-5.com.my/EmployeeWebService.asmx";
    17.     TextView tv;
    18.     TextView tvValue;
    19.    
    20.     @Override
    21.     public void onCreate(Bundle savedInstanceState) {
    22.         super.onCreate(savedInstanceState);
    23.         setContentView(R.layout.main);
    24.         tv = (TextView)findViewById(R.id.textView1);
    25.        
    26.         SoapObject Request = new SoapObject (NAMESPACE, METHOD_NAME);
    27.        
    28.         SoapSerializationEnvelope soapEnvelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
    29.        
    30.         soapEnvelope.dotNet = true;
    31.         soapEnvelope.setOutputSoapObject(Request);
    32.        
    33.         AndroidHttpTransport aht = new AndroidHttpTransport(URL);
    34.                
    35.         try
    36.         {
    37.             aht.call(SOAP_ACTION, soapEnvelope);
    38.             SoapObject resultString = (SoapObject) soapEnvelope.getResponse();                             
    39.             tv.setText(resultString.toString());                     
    40.         }
    41.         catch(Exception e)
    42.         {
    43.             tv.setText(e.toString());          
    44.         }            
    45.     }
    46. }
    i got this result
    Code (Text):
    1. anyType{Employee=anyType{Id=1;Name=Peter;Salary=22000;};Employee=anyType{Id=2;Name=Marcu........
    i want the data only, i dun want those 'anyType' 'id' 'name' ...etc text
    i want to have a data something like this:
    Code (Text):
    1. 1
    2. Peter
    3. 22000
    4.  
    5. 2
    6. Marcu
    7. 24000
    8. .... continues...

    Advertisement
  2. sfdfesfs

    sfdfesfs New Member

    I do not quite understand your question. Can you be clear?
  3. Zpecter

    Zpecter New Member

    Hello, when you call a webservice, it can return data as xml or json, so you can't modify this behaviour unless the webservice was yours, and it shouldn't be recommended to modify this behaviour after all.

    It's your responsability to parse the data you receive from the webservice and map your own objects with those values.

Share This Page