Hi,

I just verified this is a bug, create SMXCOMP-632[1] to track it, the fix is coming soon.
The work around currently for you is add an interceptor as follows

public class ExtractHeaderPartIntercepor extends AbstractPhaseInterceptor<Message> {

    public ExtractHeaderPartIntercepor() {
        super(Phase.PRE_STREAM);
    }

    public void handleMessage(Message message) {

        extractHeaderFromMessagePart(message);
    }

    private void extractHeaderFromMessagePart(Message message) {
        Source source = message.getContent(Source.class);
        if (source == null) {
            return;
        }

        Element element;
        try {
            element = new SourceTransformer().toDOMElement(source);
        } catch (Exception e) {
            throw new Fault(e);
        }

        if (!JbiConstants.WSDL11_WRAPPER_NAMESPACE.equals(element
                .getNamespaceURI())
                || !JbiConstants.WSDL11_WRAPPER_MESSAGE_LOCALNAME
                        .equals(element.getLocalName())) {
            message.setContent(Source.class, new DOMSource(element));
            return;
        }

        BindingOperationInfo bop = message.getExchange().get(
                BindingOperationInfo.class);
        if (bop == null) {
            throw new Fault(
new Exception("Operation not bound on this message"));
        }
BindingMessageInfo msg = isRequestor(message) ? bop.getInput() : bop
                .getOutput();

SoapBindingInfo binding = (SoapBindingInfo) message.getExchange().get(
                Endpoint.class).getEndpointInfo().getBinding();
        String style = binding.getStyle(bop.getOperationInfo());
        if (style == null) {
            style = binding.getStyle();
        }

        Element partWrapper = DomUtil.getFirstChildElement(element);
        while (partWrapper != null) {
extractHeaderParts((SoapMessage) message, element, partWrapper, msg);
            partWrapper = DomUtil.getNextSiblingElement(partWrapper);
        }
        message.setContent(Source.class, new DOMSource(element));
    }

    private void extractHeaderParts(SoapMessage message,
Element element, Element partWrapper, BindingMessageInfo msg) {
        List<NodeList> partsContent = new ArrayList<NodeList>();
        if (partWrapper != null) {
            if (!JbiConstants.WSDL11_WRAPPER_NAMESPACE.equals(element
                    .getNamespaceURI())
                    || !JbiConstants.WSDL11_WRAPPER_PART_LOCALNAME
                            .equals(partWrapper.getLocalName())) {
                throw new Fault(new Exception(
                        "Unexpected part wrapper element '"
+ QNameUtil.toString(element) + "' expected '{"
                                + JbiConstants.WSDL11_WRAPPER_NAMESPACE
                                + "}part'"));
            }
            NodeList nodes = partWrapper.getChildNodes();
            partsContent.add(nodes);
        }

        List<Header> headerList = message.getHeaders();
List<SoapHeaderInfo> headers = msg.getExtensors(SoapHeaderInfo.class);
        for (SoapHeaderInfo header : headers) {
            if (partsContent.size() == 0) {
                break;
            }

            NodeList nl = partsContent.get(0);
if (header.getPart().getConcreteName().getNamespaceURI().equals(
                    nl.item(0).getNamespaceURI())
&& header.getPart().getConcreteName().getLocalPart()
                            .equals(nl.item(0).getLocalName())) {
headerList.add(new Header(header.getPart().getConcreteName(),
                        nl.item(0)));
                partsContent.remove(0);
            }

        }

    }

}

Then add ExtractHeaderPartIntercepor to your cxf bc consumer <cxfbc:outInterceptors>

[1]https://issues.apache.org/activemq/browse/SMXCOMP-632

Freeman
On 2009-9-7, at 下午9:47, inter wrote:


Hi,Freeman :
 I wrote a cxf-interceptor just before JbiOutWsdl1Interceptor  at
Phase.MARSHAL to trace the flow.
I found that the JbiOutWsdl1Interceptor has parsed the jbi- message as
expected.
 It got out the soap-headers and put it into the headlist,like :
 List<Header> headerList = message.getHeaders();
 headerList.add(new Header(header.getPart().getConcreteName(),
                       nl.item(0)));


I print out the header's name ,it was "AuthResult" and namespace was also
the expected.

But the SoapResponse to the client still has only the soap body.

How can i go ahead?

Is it the problem of SoapOutInterceptor$SoapOutEndingInterceptor,or
StaxOutInterceptor$StaxOutEndingInterceptor,or
MessageSenderInterceptor$MessageSenderEndingInterceptor?

This really confused me.

Expecting for your help!





Freeman Fang wrote:


It should work, ensure the jbi part you added has same namespace and
local name as it defined in the schema.
what's the servicemix version you are using?

Freeman
Freeman Fang wrote:

Hi,
Cxf bc provider parse JBI message and generate soap message based on
wsdl model.
So if the wsdl used for your cxf bc provider has no soap header in
binding def, the soap message sent out from your cxf bc provider
won't
have soap header, it's expected behavior.
You may need change your provider wsdl first.

Freeman
On 2009-9-6, at 上午11:58, inter wrote:


I used cxf-bc-consumer,cxf-bc-provider and camel like follows:

cxf-bc-consumer=(1)=>servicemix-camel=(2)=>cxf-bc-
provider=(3)=>external
server=(4)=>back to==>cxf-
-bc-provider=(5)=>servicemix-camel=(6)=>cxf-bc-consumer.

The  consumer and provider both have their  own wsdl  file.
The only difference of the two wsdl-files is that:the consumer's
wsdl has a
out-soap-header  in binding def

but the provider's does not have it.

So  in step(6),i add a camel-processor to add a soap-heaer part in
JBI msg
,the whole msg after my processor like this:
-------------------------------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<jbi:message xmlns:jbi="http://java.sun.com/xml/ns/jbi/wsdl-11-
wrapper"
        xmlns:msg="http://server"; xmlns:xsd="http://www.w3.org/2001/
XMLSchema"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
name="sayHelloResponse" type="msg:sayHelloResponse" version="1.0">
        <jbi:part>
                <ns1:sayHelloResponse xmlns:ns1="http://server";>
                        <ns1:out>Hello!!!boy</ns1:out>
                </ns1:sayHelloResponse>
        </jbi:part>
        <jbi:part>
                <wsse:AuthResult
                
xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd
"
                        mustUnderstand="true">
                        <wsse:ResultCode>0000</wsse:ResultCode>
                        <wsse:ResultDetail>success</wsse:ResultDetail>
                </wsse:AuthResult>
        </jbi:part>
</jbi:message>
------------------------------------------------------------------------------------------------

But when out of servicemix-cxf-bc,the soap message does not contain
soap-header at all,it just contains
the body message.
I am sure that I have added a soap-header to the binding def of the
consumer's wsdl.

I upload my whole sa ZIP , in the  cxf-bc-su.zip,there are all the
wsdl
files.
The proxy.wsdl  is the consumer's,and the service.wsdl is the
provider's,the
wsse.xsd is the imported schema in which the soap header is defined.

http://www.nabble.com/file/p25314469/test.zip test.zip

--
View this message in context:
http://www.nabble.com/Problems-with-adding-out-soap-header-for-cxf-bc..-tp25314469p25314469.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.



--
Freeman Fang
------------------------
Open Source SOA: http://fusesource.com




--
View this message in context:
http://www.nabble.com/Problems-with-adding-out-soap-header-for-cxf-bc..-tp25314469p25316117.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.



--
Freeman Fang
------------------------
Open Source SOA: http://fusesource.com




--
View this message in context: 
http://www.nabble.com/Problems-with-adding-out-soap-header-for-cxf-bc..-tp25314469p25330829.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.



--
Freeman Fang
------------------------
Open Source SOA: http://fusesource.com

Reply via email to