1

私は ksaop2-android を使用して Web サービスを生成しています。使用する wsdl は次のとおりです: http://wsf.cdyne.com/WeatherWS/Weather.asmx?WSDL

これは私のコードです:

    String serviceUrl = "http://wsf.cdyne.com/WeatherWS/Weather.asmx?WSDL";
    String methodName = "GetCityWeatherByZIP";
    SoapObject request = new SoapObject("http://ws.cdyne.com/WeatherWS/",
            methodName);
    request.addProperty("ZIP", "64101");
    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
            SoapEnvelope.VER12);
    envelope.dotNet = false;
    envelope.setOutputSoapObject(request);
    HttpTransportSE ht = new HttpTransportSE(serviceUrl);
    try {
        ht.call("http://wsf.cdyne.com/WeatherWS/Weather.asmx/GetCityWeatherByZIP", envelope);
        if (envelope.getResponse() != null) {
            SoapObject soapObject = (SoapObject) envelope.getResponse();
            System.out.println(soapObject.getProperty("ResponseText"));
        }
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (XmlPullParserException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

この URL で正しい応答を得ることができます: http://wsf.cdyne.com/WeatherWS/Weather.asmx/GetCityWeatherByZIP?ZIP=64101

ただし、私のコードは次のような応答を返します。

気象データに市が見つかりませんでした。詳しくはCDYNEまでお問い合わせください。

引数が送信されていないようですが、どの部分が間違っている可能性がありますか?

4

2 に答える 2

2
   SoapObject request = new SoapObject(NAMESPACE, METHOD);

    request.addProperty("ZIP", "64101");

    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
            SoapEnvelope.VER12);
    envelope.dotNet = true;
    envelope.setOutputSoapObject(request);

    HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);

    try {
        androidHttpTransport.call(SOAP_ACTION, envelope);
        .....


    } catch (Exception e) {
        e.printStackTrace();

    }

どこ

SOAP_ACTION = "http://ws.cdyne.com/WeatherWS/GetCityForecastByZIP";
URL = "http://wsf.cdyne.com/WeatherWS/Weather.asmx";
METHOD = "GetCityForecastByZIP";
NAMESPACE = "http://ws.cdyne.com/WeatherWS/";
于 2013-02-03T15:41:56.527 に答える
0

これを試して:

ht.call("http://ws.cdyne.com/WeatherWS/GetCityWeatherByZIP", envelope);

それ以外の:

ht.call("http://wsf.cdyne.com/WeatherWS/Weather.asmx/GetCityWeatherByZIP", envelope);
于 2013-02-03T14:19:59.310 に答える