Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

SOAPFaultException when using webservice with http header cookie

843833Sep 10 2008
Hi All,

I'm reading from an axis web service - with client java stubs that were generated from the corresponding WSDL file. It has two methods - "HelloWorld" and "HelloSayFirstName". I'm setting up the client-side service and port as follows:

QName serviceName = new QName("http://tempuri.org/", "MyService");
QName portName = new QName("http://tempuri.org/", "BasicHttpBinding_IMyService");
String endpointAddress = "http://example/WebServices/WCFService/Service.svc";

Service service = Service.create(serviceName);
service.addPort(portName, SOAPBinding.SOAP11HTTP_BINDING, endpointAddress);
IMyService servicePort = (IMyService)service.getPort(portName, IMyService.class);

This works fine, and I am able to call the two methods:
servicePort.helloSayFirstName()
servicePort.helloWorld()

However, I need to send a http header cookie - so I use the following:
List<String> cookies = new ArrayList<String>();
cookies.add("mycookie=mytoken");
HashMap<String, List<String>> httpHeaders = new HashMap<String, List<String>>();
httpHeaders.put(HTTPConstants.HEADER_COOKIE, cookies);
java.util.Map<String, Object> requestContext = ((javax.xml.ws.BindingProvider) servicePort).getRequestContext();
requestContext.put(MessageContext.HTTP_REQUEST_HEADERS, httpHeaders);

This works when the first method is called (cookie is sent), but when the second method is called I get the following SOAPFaultException.
Would anyone have any ideas on this? Thanks

Caused by: org.apache.cxf.binding.soap.SoapFault: OperationFormatter encountered an invalid Message body. Expected to find node type 'Element' with name 'HelloSayFirstName' and namespace 'http://tempuri.org/'. Found node type 'Element' with name 'HelloWorld' and namespace 'http://tempuri.org/'
at org.apache.cxf.binding.soap.interceptor.Soap11FaultInInterceptor.handleMessage(Soap11FaultInInterceptor.java:70)
at org.apache.cxf.binding.soap.interceptor.Soap11FaultInInterceptor.handleMessage(Soap11FaultInInterceptor.java:1)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:207)
at org.apache.cxf.interceptor.AbstractFaultChainInitiatorObserver.onMessage(AbstractFaultChainInitiatorObserver.java:90)
at org.apache.cxf.binding.soap.interceptor.ReadHeadersInterceptor.handleMessage(ReadHeadersInterceptor.java:179)
at org.apache.cxf.binding.soap.interceptor.ReadHeadersInterceptor.handleMessage(ReadHeadersInterceptor.java:1)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:207)
at org.apache.cxf.endpoint.ClientImpl.onMessage(ClientImpl.java:402)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponse(HTTPConduit.java:1948)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1791)
at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:66)
at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:575)
at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:207)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:254)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:205)
at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:73)
at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:140)
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 8 2008
Added on Sep 10 2008
0 comments
386 views