My.net webservice obviously works with soap 1.2 (by checking .wsdl), and I'm trying to access the helloworld web service for testing, but I ran into errors. I am trying to do this through an emulator, by the way.
So, when I use soap 1.2, I get an error that it "cannot process the request without a valid action parameter. Please put a valid soap." I want to know what I don’t have and what should I do.
Thank!
Things I've already done:
- Add permission for Android to use the Internet
- Change from soap versions 1.1 and 1.2
- Change from SoapObject to Object (for both soaps 1.1 and 1.2)
- Used 10.0.2.2 for the emulator
- Checked for errors when writing address and method names
My codes are:
private static final String NAMESPACE = "http://localhost/WebService/";
private static final String URL = "http://10.0.2.2:1672/Eventurous/WsEventurousMobile.asmx";
private static final String HelloWorld_SOAP_ACTION = "http://localhost/WebService/HelloWorld";
private static final String METHOD_NAME1 = "HelloWorld";
...
...
public static String GetHelloWorld() {
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME1);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
SoapEnvelope.VER12);
envelope.dotNet = true;
envelope.setOutputSoapObject(request);
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL,60000);
try {
androidHttpTransport.setXmlVersionTag("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
androidHttpTransport.call(HelloWorld_SOAP_ACTION, envelope);
SoapObject response = (SoapObject)envelope.getResponse();
String result = response.getProperty(0).toString();
return result;
} catch (Exception e) {
return e.toString();
}
}
Error for soap version 1.2
Code: soap:Sender, Reason: System.Web.Services.Protocols.SoapException: Unable to handle request without a valid action parameter. Please supply a valid soap action.
at System.Web.Services.Protocols.Soap12ServerProtocolHelper.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
Error for soap version 1.1
SoapFault - faultcode: 'soap:Client' faultstring: 'System.Web.Services.Protocols.SoapException: Server did not recognize the value of HTTP Header SOAPAction: http://localhost/WebService/HelloWorld.
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@413c9098
source
share