cxf-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Seumas Soltysik (Created) (JIRA)" <>
Subject [jira] [Created] (CXF-4130) Server using Provider implementation writes contents of SOAP body in SOAP header
Date Wed, 22 Feb 2012 18:51:48 GMT
Server using Provider implementation writes contents of SOAP body in SOAP header

                 Key: CXF-4130
             Project: CXF
          Issue Type: Bug
    Affects Versions: 2.5.2
            Reporter: Seumas Soltysik
             Fix For: 2.6

When using a server using a Provider implementation in conjunction with a WSDL that defines
a SOAP header as part of its output, the contents out the SOAP body will be written as a SOAP
header depending on the order of the parts defined in the output message.

For example if an output message is defined like this:

	<message name="FooResponse">
		<part name="FooResponseHeader" element="tns:FooResponseHeader"/>
		<part name="FooResponse" element="tns:FooResponse"/>

and the SOAP binding operation is defined like this:

		<operation name="Foo">
				<soap:header message="tns:FooRequest" part="FooRequestHeader" use="literal"/>
				<soap:body parts="FooRequest" use="literal"/>
				<soap:header message="tns:FooResponse" part="FooResponseHeader" use="literal"/>
				<soap:body use="literal"/>

because the FooResponseHeader is defined as the first part in the output message, CXF writes
out the following message:

<SOAP-ENV:Envelope xmlns:SOAP-ENV="">
    <FooResponseHeader xmlns:ns2="">FooResponseHeader</FooResponseHeader>
    <ns2:FooResponse xmlns:ns2="">
      <ns2:Return>Foo Response Body</ns2:Return>

The basic reason for this is that the SoapOutInterceptor uses the part index of the part defining
the output header to look up the instance of that part in the MessageContentList contained
in the Message. However, in the Provider use case, the MessageModeOutInterceptorInternal interceptor
puts the contents of the SOAP body into the first slot of the MessageContentList. So in the
case where the index of the SOAP header part is 0, the contents of the SOAP body get written
out as a SOAP header.

Additional details are available as part of the CXF developers mailing list here:

A possible solution to this problem is to place the contents of the SOAP body in the appropriate
location in the MessageContentList in MessageModeOutInterceptorInternal. This solution would
look something like this:


            DocumentFragment frag = soapMessage.getSOAPPart().createDocumentFragment(); 
            try { 
                Node body = soapMessage.getSOAPBody(); 
                Node nd = body.getFirstChild(); 
                while (nd != null) { 
                    nd = soapMessage.getSOAPBody().getFirstChild(); 

                int index = 0; 
                Exchange exchange = message.getExchange(); 
                BindingOperationInfo operation = (BindingOperationInfo)exchange.get(BindingOperationInfo.class


                List<MessagePartInfo> parts = null; 
                BindingMessageInfo bmsg = null; 
                boolean client = isRequestor(message); 

                if (!client) { 
                    if (operation.getOutput() != null) { 
                        bmsg = operation.getOutput(); 
                        parts = bmsg.getMessageParts(); 
                } else { 
                    bmsg = operation.getInput(); 
                    parts = bmsg.getMessageParts(); 
                if (parts != null && parts.size() > 0) { 
                index = parts.get(0).getIndex(); 
                list.set(index, frag);

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:!default.jspa
For more information on JIRA, see:


View raw message