Get List from .net Web Service on Android

后端 未结 1 1776
盖世英雄少女心
盖世英雄少女心 2021-02-06 19:37

I have .net Web Service and I want to use it on android. This web service\'s methods return List(Of String) and I didn\'t get response on android. What can I do ? Here is the co

1条回答
  •  别那么骄傲
    2021-02-06 20:03

    I got it !!

    this is false;

    SoapObject response = (SoapObject) envelope.bodyIn;
    

    Lets see this code, it's true;

    SoapObject response = (SoapObject) envelope.getResponse();
    

    Finally there are some trick about it.

    1. First of all delete ksoap2 jar file from your project.
    2. Save it and close Eclipse.
    3. Then copy ksoap2 jar file, go to your workspace folder.
    4. Open your project folder, click "libs" folder and paste it.
    5. Open again Eclipse and Run Project!!

          private Spinner myspinner;
          private static final String METHOD_NAME = "Sektorler";  
          private static final String NAMESPACE = "http://tempuri.org";   
          private static final String SOAP_ACTION = "http://tempuri.org/Sektorler";
          private static final String URL = "http://www.xxxxxxxxxx.com/webservice1.asmx";
          private String[] denemeList;
      
          private void SektorDoldur(){
      
              SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
              SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
              envelope.dotNet = true;     
              envelope.setOutputSoapObject(request);
              HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
              androidHttpTransport.debug = true;
      
              try {
      
             androidHttpTransport.call(SOAP_ACTION, envelope);
             SoapObject response = (SoapObject) envelope.getResponse();
             denemeList = new String[response.getPropertyCount()];
      
            for(int i=0;i adapter = new ArrayAdapter(this,android.R.layout.simple_spinner_item, denemeList);
              adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
              myspinner.setAdapter(adapter);
      
          }
      

    0 讨论(0)
提交回复
热议问题