It looks like the ksoap library excludes the soap action from the envelope on Soap VER12. This action is needed for WSE enhanced web services, so a simple change from VER12 to VER11 does the trick.
Calling web-service using WSE on Android
-
28-09-2022 - |
Pregunta
I've been using the ksoap2 library for all of my SOAP calls and they have all been successful. But when I try to call a web-service that uses WSE I receive the following error...
Code: soap:Sender, Reason: WSE012: The input was not a valid SOAP message because the following information is missing: action.
From what I can tell, this means that the soap action is required in the header, but it clearly states in the documentation that SOAPAction is not a valid header for version 12. http://code.google.com/p/ksoap2-android/issues/detail?id=67
When I do add it as header I simply receive a "server was unable to process request" error. I've been stuck on this for a while and was hoping someone knows what's up. Here is the main code...
SoapObject request = new SoapObject(namespace, methodName);
request.addProperty(name, value);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER12);
envelope.dotNet = true;
envelope.setOutputSoapObject(request);
try {
HttpTransportSE transport = new HttpTransportSE(URL);
List<HeaderProperty> headers = new ArrayList<HeaderProperty>();
headers.add(new HeaderProperty("SOAPAction", soapAction));
transport.call(soapAction, envelope, headers);
} catch (Exception e) {
e.printStackTrace();
}
Solución 2
Otros consejos
Have you defined soap action in your code like (namespace/soapAction) as per your wsdl,
private static final String SOAP_ACTION_Auth = "http://AuthHeaderImplementation/Authentication";
One thing in your code,
transport.call(soapAction, envelope, headers);
According to this ksoap2 doc, It takes only action and envelope as input parameter.
call(java.lang.String soapAction, SoapEnvelope envelope)
set the desired soapAction header field
And this is how i add empty header in my code, if required by server,
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER12);
//Create empty Header
Element [] header = new Element[1];
header[0]=new Element();
// add header to envelope
envelope.headerOut = header;
envelope.setOutputSoapObject(request);