关于web service 解析天气 遇到的问题
public static List<String> getCityList(String provice){final static String TARGETNAMESPACE= "http://WebXml.com.cn";
final static String URL = "http://webservice.webxml.com.cn/WebServices/WeatherWS.asmx";
String methodName = "getSupportCityString";
String soapAction = TARGETNAMESPACE + "/" + methodName;
HttpTransportSE ht = new HttpTransportSE(URL);
ht.debug = true;
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
SoapObject soapObject = new SoapObject(TARGETNAMESPACE, methodName);
soapObject.addProperty("theRegionCode", provice);
envelope.bodyOut = soapObject;
envelope.dotNet = true;
try {
ht.call(soapAction, envelope);
if(envelope.getResponse() != null){
SoapObject result = (SoapObject) envelope.bodyIn;
SoapObject detail = (SoapObject) result.getProperty(methodName + "Result");
return getProviceOrCity(detail);
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (XmlPullParserException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
通过debug出来的soapObject = getSupportCityString{theRegionCode=黑龙江; } 做完部署报空指针错 通过debug发现 bodyIn = SoapFault - faultcode: 'soap:Server' faultstring: '服务器无法处理请求。 ---> 值不能为空。
参数名: input' faultactor: 'null' detail: org.kxml2.kdom.Node@412f5f68 哪位大侠帮助小弟一下解决这个困惑 小弟这里万分感谢了 --------------------编程问答-------------------- 觉得这种只有自己多DEBUG了 --------------------编程问答-------------------- 遇到同样的问题。还没解决。
soapObject.addProperty("theRegionCode", provice);
这一步添加过参数了,还是有错,那是web service 里要求的参数名不同? --------------------编程问答-------------------- final static String TARGETNAMESPACE= "http://WebXml.com.cn";改成final static String TARGETNAMESPACE= "http://WebXml.com.cn/";试试
补充:移动开发 , Android