我想从soap webservice读取数据。这是我的代码:
final String NAMESPACE = "http://www.webservicex.com/";
final String URL = "http://www.webservicex.com/globalweather.asmx";
final String SOAP_ACTION = "http://www.webservicex.com/globalweather.asmx?op=GetCitiesByCountry";
final String METHOD_NAME = "GetCitiesByCountry";
TextView lblResult;
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
request.addProperty("CountryName","Germany");
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.setOutputSoapObject(request);
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
try {
androidHttpTransport.call(SOAP_ACTION, envelope);
//SoapPrimitive resultsRequestSOAP = (SoapPrimitive) envelope.getResponse();
// SoapPrimitive resultsRequestSOAP = (SoapPrimitive) envelope.getResponse();
SoapObject resultsRequestSOAP = (SoapObject) envelope.bodyIn;
Log.v("this",resultsRequestSOAP.toString()+ " response");
Log.v("this","Response::"+resultsRequestSOAP.toString());
} catch (Exception e) {
SoapFault error = (SoapFault)envelope.bodyIn;
Log.v("this","Error message : "+error.toString());
Log.v("this","Error"+e);
}
我认为我已经将数据严重设置为变量。我收到这个错误:
Error message : SoapFault - faultcode: 'soap:Client' faultstring: 'System.Web.Services.Protocols.SoapException: Server did not recognize the value of HTTP Header SOAPAction: http://www.webservicex.com/globalweather.asmx?op=GetCitiesByCountry.
at System.Web.Services.Protocols.Soap11ServerProtocolHelper.RouteRequest()
at System.Web.Services.Protocols.SoapServerProtocol.RouteRequest(SoapServerMessage message)
at System.Web.Services.Protocols.SoapServerProtocol.Initialize()
at System.Web.Services.Protocols.ServerProtocolFactory.Create(Type type, HttpContext context, HttpRequest request, HttpResponse response, Boolean& abortProcessing)' faultactor: 'null' detail: org.kxml2.kdom.Node@52739eac