5

My .net webservice is apparently running soap 1.2 (by checking the .wsdl) and ive been trying to access the helloworld webservice for testing but i have encountered errors. Im trying to do this via the emulator by the way.

So when I use soap 1.2 version , i get the error that it is "unable to handle request without a valid action parameter. Please supply a valid soap" I want to know what I am missing and what should I do.

Thank you!

Things I have already done:

  • Add permission for android to use the internet
  • Change from Soap version 1.1 and 1.2
  • Change from SoapObject to Object (for both soap 1.1 and 1.2)
  • Used 10.0.2.2 for the emulator
  • Checked for errors in spelling in the addresses and method names

My codes:

 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
Cory Tam
  • 81
  • 2
  • 6

1 Answers1

0

use SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);

instead of

SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
     SoapEnvelope.VER12);

and remove this line androidHttpTransport.setXmlVersionTag("<?xml version=\"1.0\" encoding=\"utf-8\"?>");

and instead of SoapObject response = (SoapObject)envelope.getResponse();

use SoapObject response = (SoapObject)envelope.bodyIn;

It will Help you.If still get Error then Write me.

Sachin D
  • 1,370
  • 7
  • 29
  • 42