1

この Web サービスを利用しようとしています: http://www.ezzylearning.com/services/CountryInformationService.asmx with KSoap.

パラメータなしで Web メソッド (例: GetContinents) を呼び出すと、正常に動作します。パラメータを指定して使用しようとすると、常に空のデータが返されます。

これが私のActivityクラスです(テスト目的のため):

public class MyTestActivity extends Activity
    {
      private static final String NAMESPACE = "http://www.ezzylearning.com/services/";
      private static final String URL = "http://www.ezzylearning.com/services/CountryInformationService.asmx?WSDL";
      private static final String ACTION_GET_COUNTRIES_BY_CONTINENT = "http://www.ezzylearning.com/services/CountryInformationService.asmx/GetCountriesByContinent";
      private static final String METHOD_GET_COUNTRIES_BY_CONTINENT = "GetCountriesByContinent";    


    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState)
     {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.fourth);
    String property = "continentCode";
    String value = "AS";
    new GetCountriesByContinentTask().execute(URL, NAMESPACE, ACTION_GET_COUNTRIES_BY_CONTINENT, METHOD_GET_COUNTRIES_BY_CONTINENT, property, value);
   }

// Implementation of AsyncTask used get the countries by continent.
private class GetCountriesByContinentTask extends AsyncTask<String, Void, String>
{

    @Override
    protected void onPreExecute()
    {
    }

    @Override
    protected String doInBackground(String... params)
    {
        String result = "Testing...";

        String url = params[0];
        String namespace = params[1];
        String action = params[2];
        String method = params[3];
        String property = params[4];
        String value = params[5];
        List<PropertyInfo> propertyList = new ArrayList<PropertyInfo>();

        //Use this to add parameters
        PropertyInfo pi = new PropertyInfo();
        pi.setName(property);
        pi.setValue(value);
        pi.setType(String.class);
        propertyList.add(pi);

        try
        {   
            MySoapHandler soapHandler = new MySoapHandler();
            SoapObject soapRresult = soapHandler.soapCall(url, namespace, action, method, propertyList);
            if (soapRresult != null)
            {
                System.out.println("RESULT: " + soapRresult.toString());  // THE DATA SET IS ALWAYS EMPTY     
            }
        } 
        catch (Exception ex) 
        {
            System.out.println("Exception: " + ex.getMessage());       
            ex.printStackTrace();
        }       

        return result;
    }

    @Override


    protected void onPostExecute(String result) 
        {
        }
    }
}

Web サービスを呼び出すための私のクラス:

public class MySoapHandler
{

public 
        public SoapObject soapCall(String url, 
                               String namespace, 
                               String action, 
                               String method, 
                               List<PropertyInfo> propertyInfoList)
    throws IOException, XmlPullParserException
    {
        //Initialize soap request
    SoapObject request = new SoapObject(namespace, method);

    //Add parameters
    if(propertyInfoList != null)
    {
        for(PropertyInfo pi: propertyInfoList)
        {
            request.addProperty(pi);
        }
    }

    //Declare the version of the SOAP request
    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
    envelope.setOutputSoapObject(request);
    envelope.dotNet = true;

    //Call the webservice
    HttpTransportSE transport = new HttpTransportSE(url);
    transport.call(action, envelope);

    //Return the SoapResult from the envelope body.


return (SoapObject)envelope.bodyIn;
    }
}

私が間違っていることについて何か考えはありますか?

また、 envelope.bodyInenvelope.getResponse()に変更しようとしましたが、データセットはまだ空です。

ありがとうございました。

4

0 に答える 0