.net在android中的Web服务,并没有得到XML响应
问题描述:
我正在使用asmx web服务在我的代码中没有返回正确的XMl文件。这是我的代码.net在android中的Web服务,并没有得到XML响应
private static final String SOAP_ACTION = "http://tempuri.org/ValidateLogin";
private static final String METHOD_NAME = "ValidateLogin" ;
private static final String NAMESPACE = "http://tempuri.org/";
private static final String URL = "http://ufindfish.b4live.com/FindFish.asmx";
request= new SoapObject(NAMESPACE,METHOD_NAME);
request.addProperty("sUserName",name);
request.addProperty("sPwd", password);
//envelope.bodyOut=request;
envelope=new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet=true;
envelope.setOutputSoapObject(request);
envelope.encodingStyle=SoapSerializationEnvelope.XSD;
//generate httpresponce
httpTransportSE=new HttpTransportSE(URL);
try {
httpTransportSE.call(SOAP_ACTION,envelope);
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (XmlPullParserException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
SoapObject result = null;
try {
result=(SoapObject)envelope.getResponse();
//Log.i("RESPONCE",""+result.toString());
} catch (SoapFault e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
thand responce is below ...我该怎么办?
anyType{NearLake=anyType{tblNearLake=anyType{LAKE=2022C01 BENSFORT BRIDGE to PETERBOROUGH; LAT=11.622; LON=20.616; }; tblNearLake=anyType{LAKE=2022C01 BENSFORT BRIDGE to PETERBOROUGH; LAT=11.186; LON=19.443; }; }; }
PLSE帮我...
在此先感谢
答
我挣扎了很多这个问题终于得到解决。以下代码将为您完成这项工作。
httpTransportSE.debug=true;
httpTransportSE.call(SOAP_ACTION, envelope);
String ss=httpTransportSE.responseDump;
Log.d("--Result-- ", ss);
如果该Web服务返回一个xml,它将正确地打印带有xml标记的webservice输出。
+0
+1 frnd ..终于放松了解决方案.. – NullPointerException 2012-09-27 18:49:03
你是如何检查结果不正确的?检查它时,不能依赖toString()方法的结果! – Olegas 2011-04-13 12:04:47
@ Olegas结果是好的...但它不给我适当的XML文件来解析它。 – devaki 2011-04-13 12:20:44
你是如何解析它的?为什么你想分别对它进行拉伸?它不是已经被你的SOAP库解析过吗? – Olegas 2011-04-13 12:31:53