Skip to main content
Announcements
A fresh, new look for the Data Integration & Quality forums and navigation! Read more about what's changed.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

[resolved] cxf endpoint with 2004/08 ws-addressing

Hello all,
I have another interesting riddle, as well related to cxf and camel, but maybe there's someone who already solved the problem..
We need to invoke a web service requiring WS-Addressing. By default, I would use following cxf endpoint:
   <camelcxf:cxfEndpoint id="wsService" 
address="${ws.endpoint}"
xmlns:crabws="..."
serviceClass="..."
serviceName="..."
endpointName="..."
wsdlURL="....?WSDL"
>
<camelcxf:features>
<wsa:addressing xmlns:wsa="http://cxf.apache.org/ws/addressing"/>
</camelcxf:features>
<camelcxf:properties>
<entry key="dataFormat" value="PAYLOAD"/>
</camelcxf:properties>
<camelcxf:outInterceptors>
<bean id="wssOutInterceptor"
class="org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor">
<property name="properties">
<map>
<entry key="action" value="Timestamp UsernameToken"/>
<entry key="passwordType" value="PasswordDigest"/>
<entry key="user" value="${ws.login}"/>
<entry key="passwordCallbackRef">
<bean id="passwordProvider" class="com.apogado.ws.PasswordProvider">
<property name="login" value="${ws.login}" />
<property name="password" value="${ws.password}" />
</bean>
</entry>
<entry key="precisionInMilliseconds" value="false"/>
</map>
</property>
</bean>
</camelcxf:outInterceptors>
</camelcxf:cxfEndpoint>

the problem is, that this way the CXF framework uses WSA using namespace http://www.w3.org/2005/08/addressing, but required namespace is http://schemas.xmlsoap.org/ws/2004/08/addressing . The called service is a third party's endpoint, we have no control over it. The WSDL has no WS-Policy statements to enforce using the correct WS-Addressing namespace.

If we invoke the WS by coded endpoint, it's easy, setting a simple property will do the magic:
                 AddressingPropertiesImpl addrProps =
new AddressingPropertiesImpl("http://schemas.xmlsoap.org/ws/2004/08/addressing");
((BindingProvider) this.client).getRequestContext().put("javax.xml.ws.addressing.context", addrProps);

nevertheless we'd like to do proxy services by camel mediation routes, so - the our question is, how to achieve using WS-Addressing http://schemas.xmlsoap.org/ws/2004/08/addressing in the camel cxf endpoint using OSGi blueprint XML or Spring?
Thank in advance for any hit or advice.
Best regards
Gabriel Vince
Labels (6)
1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

Hi all,
took a little time, but I found out by myself, the RequestContext map must be set in a route header
Carpe diem
Gabriel
    <bean id="wsaddrProp" class="org.apache.cxf.ws.addressing.impl.AddressingPropertiesImpl">
<argument value="http://schemas.xmlsoap.org/ws/2004/08/addressing" />
</bean>

<bean id="reqContext" class="java.util.HashMap">
<argument>
<map>
<entry key="javax.xml.ws.addressing.context">
<ref component-id="wsaddrProp" />
</entry>
</map>
</argument>
</bean>

<camelcxf:cxfEndpoint id="wsEndpoint"
address="/....Proxy"
xmlns:crabws="h...."
serviceClass="....."
>
<camelcxf:properties>
<entry key="dataFormat" value="PAYLOAD"/>
</camelcxf:properties>

</camelcxf:cxfEndpoint>

<camelcxf:cxfEndpoint id="wsService"
address="${ws.endpoint}"
xmlns:crabws="..."
serviceClass="...."
serviceName="..."
endpointName="...."
wsdlURL="classpath:META-INF/wsdl/....wsdl"

>
<camelcxf:features>
<wsa:addressing xmlns:wsa="http://cxf.apache.org/ws/addressing"/>
</camelcxf:features>
<camelcxf:properties>
<entry key="dataFormat" value="PAYLOAD"/>
</camelcxf:properties>

</camelcxf:cxfEndpoint>

<camelContext xmlns="http://camel.apache.org/schema/blueprint" id="wsProxyCtx">
<route id="wsProxy" >
<from uri="wsEndpoint" />
<to uri="log:ws" />
<setHeader headerName="RequestContext">
<simple>${ref:reqContext}</simple>
</setHeader>
<to uri="wsService" />
</route>
</camelContext>

View solution in original post

2 Replies
Anonymous
Not applicable
Author

Hi all,
took a little time, but I found out by myself, the RequestContext map must be set in a route header
Carpe diem
Gabriel
    <bean id="wsaddrProp" class="org.apache.cxf.ws.addressing.impl.AddressingPropertiesImpl">
<argument value="http://schemas.xmlsoap.org/ws/2004/08/addressing" />
</bean>

<bean id="reqContext" class="java.util.HashMap">
<argument>
<map>
<entry key="javax.xml.ws.addressing.context">
<ref component-id="wsaddrProp" />
</entry>
</map>
</argument>
</bean>

<camelcxf:cxfEndpoint id="wsEndpoint"
address="/....Proxy"
xmlns:crabws="h...."
serviceClass="....."
>
<camelcxf:properties>
<entry key="dataFormat" value="PAYLOAD"/>
</camelcxf:properties>

</camelcxf:cxfEndpoint>

<camelcxf:cxfEndpoint id="wsService"
address="${ws.endpoint}"
xmlns:crabws="..."
serviceClass="...."
serviceName="..."
endpointName="...."
wsdlURL="classpath:META-INF/wsdl/....wsdl"

>
<camelcxf:features>
<wsa:addressing xmlns:wsa="http://cxf.apache.org/ws/addressing"/>
</camelcxf:features>
<camelcxf:properties>
<entry key="dataFormat" value="PAYLOAD"/>
</camelcxf:properties>

</camelcxf:cxfEndpoint>

<camelContext xmlns="http://camel.apache.org/schema/blueprint" id="wsProxyCtx">
<route id="wsProxy" >
<from uri="wsEndpoint" />
<to uri="log:ws" />
<setHeader headerName="RequestContext">
<simple>${ref:reqContext}</simple>
</setHeader>
<to uri="wsService" />
</route>
</camelContext>
Anonymous
Not applicable
Author

thanks for sharing. Good to know.