gpt4 book ai didi

android - 将 wsdl 1.2 与 ksoap2-android 一起使用

转载 作者:行者123 更新时间:2023-11-29 21:50:01 33 4
gpt4 key购买 nike

我正在使用 ksaop2-android 生成我的网络服务,这是我使用的 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 了解更多详情。

好像没有发送参数,哪部分是错误的?

最佳答案

   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/";

关于android - 将 wsdl 1.2 与 ksoap2-android 一起使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14673119/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com