ActionMismatch while using web service
I'm trying to connect and use a web service method. I'm getting the following error:
The SOAP action specified on the message, '', does not match the HTTP 开发者_开发问答SOAP Action, 'http://tempuri.org/xpto/foobar'.
In fact, the code says this:
_state.getMessageContext().setProperty("http.soap.action", "http://yadayadayada");
but it doesn't state anything about the message.
The WSDL states this:
<wsdl:input wsaw:Action="http://tempuri.org/foo/bar" message="tns:xpto"/>
This question has been solved. I had to alter the code auto generated by WSDL2Java. In the Stub class, the auto generated code looks like this;
(...)
org.apache.axis.client.Call _call = createCall();
_call.setOperation(_operations[11]);
_call.setUseSOAPAction(true);
_call.setSOAPActionURI("http://tempuri.org/foo/bar");
_call.setEncodingStyle(null);
_call.setProperty(org.apache.axis.client.Call.SEND_TYPE_ATTR, Boolean.FALSE);
_call.setProperty(org.apache.axis.AxisEngine.PROP_DOMULTIREFS, Boolean.FALSE);
_call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP12_CONSTANTS);
_call.setOperationName(new javax.xml.namespace.QName("http://tempuri.org/", "bar"));
setRequestHeaders(_call);
setAttachments(_call);
I had to add the following, before the setRequestHeaders:
setHeader("http://www.w3.org/2005/08/addressing", "To", "http://WSDL.URL");
setHeader("http://www.w3.org/2005/08/addressing", "Action", "http://tempuri.org/foo/bar");
SOAPHeaderElement[] headers = getHeaders();
for (SOAPHeaderElement h : headers) { h.setRole(null); }
setRequestHeaders(_call);
setAttachments(_call);
精彩评论