我正在连接到web服务,即android中的service.asmx。我能够连接到服务并获得共鸣但我得到的响应如下。服务器发送给我一个有效的xml但我无法正确读取xml。我得到的输出如下
anyType{schema=anyType{element=anyType{complexType=anyType{choice=anyType{element=anyType{complexType=anyType{sequence=anyType{element=anyType{}; element=anyType{}; element=anyType{}; element=anyType{}; element=anyType{}; }; }; }; }; }; }; }; diffgram=anyType{}; }
并且用于获得响应的代码如下所示。envelope.getResponse
是否会返回xml格式,或者我需要使用其他东西。我已经搜索了但是我仍然不清楚这个。
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
SoapEnvelope.VER11);
SoapObject request = new SoapObject(NAMESPACE, MethName);
envelope.setOutputSoapObject(request);
androidHttpTransport.debug=true;
// Property which holds input parameters
PropertyInfo sayHelloPI = new PropertyInfo();
// Set Name
sayHelloPI.setName("UserId");
// Set Value
sayHelloPI.setValue(1);
// Set dataType
sayHelloPI.setType(int.class);
// Add the property to request object
request.addProperty(sayHelloPI);
//Set envelope as dotNet
envelope.dotNet = true;
try {
// Invoke web service
androidHttpTransport.call(SOAP_ACTION, envelope);
// Get the response
SoapObject response = (SoapObject) envelope.getResponse();
System.out.println("response-----------------"+response);
答案 0 :(得分:-1)
谢谢大家,我使用了这种方法
String ss=httpTransport.responseDump;
它给了我一个有效格式的xml