简体   繁体   中英

Android: Error while trying to access a .Net Web Service

I have created a small app to access a .Net Web Service

But I get this error from Android

SoapFault - faultcode: 'soap:Client' faultstring: 'System.Web.Services.Protocols.SoapException: Server did not recognize the value of HTTP Header SOAPAction: http://webservice.pollsdb.com/Msgs.
   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@b1ebfe80

does anyone know how to call this service from android?

This is my code

SOAP_ACTION = namespace + MethodName;

request = new SoapObject(namespace, MethodName);

//Adding String value to request object
request.addProperty("Lg", Lg);
request.addProperty("Lt", Lt);
request.addProperty("Cnt", Cnt);

//request.addProperty("ToUnit", "" + toUnit);

SetEnvelope();

//SOAP calling webservice
androidHttpTransport.call(SOAP_ACTION, envelope);

//Got Webservice response
String result = envelope.getResponse().toString();

return result;

我发现了问题,这是在.Net中,而不是在Android中。刚从.Net默认名称空间更改为该服务所在的网站

[WebService(Namespace = "http://webservice.pollsdb.com/")]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM