The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

bobs99 (5) [Avatar] Offline
#1
Hi

Using chapter 7 as a guide I am trying to get a WS-Security Username token send out with each Mule (ver 2.1.1) CXF SOAP request. My client takes in a test number and wraps this into a SOAP call which all works fine. A response is correctly returned from the remote service. However, using Ethereal to inspect the network packets, along with examining the Mule logs, I can see that no token is being sent out with my SOAP request.

It appears the client WSS4JOutInterceptor is not intercepting the outbound SOAP requests.

In my mule config file below I have defined the client password callback and the cxf external config file (wss-cxf-outconfig.xml), which I know is being read.

<file:file-to-string-transformer name="fileToString" />
<file:connector streaming="false" name="fileConnector"/>

<spring:bean name="clientCallback" class="test.opensource.test.ClientPasswordCallback" />

<cxf:connector name="cxfConnector">
<spring:property name="configurationLocation" value="wss-cxf-outconfig.xml" />
</cxf:connector>

<model name="consume-wsSecurity">
<service name="ServiceConsume">
<inbound>
<inbound-endpoint >
address="stdio://System.in?promptMessage=Enter the Test Number: " synchronous="true">
<transformers>
<custom-transformer class="org.mule.transformer.simple.StringToObjectArray" />
</transformers>
</inbound-endpoint>
</inbound>
<outbound>
<chaining-router>
<outbound-endpoint address="wsdl-cxf:http://localhost:8080/test?wsdl&method=getTheNum" synchronous="true" >
<properties>
<spring:entry key="service" value="{http://opensource.test/numtest/}testService" />
<spring:entry key="port" value="{http://opensource.test/numtest/}testSoap" />
</properties>
</outbound-endpoint>
<outbound-endpoint address="stdio://System.out" >
</outbound-endpoint>
</chaining-router>
</outbound>
</service>
</model>

Below is my wss-cxf-outconfig.xml file. In this file I don't define the SAAJOutInterceptor because I'm using cxf 2.1 (rather than cxf 2.0), so it's not necessary. I have setup the constructor for the WSS4JOutInterceptor and added this to the cxf bus(CXFBusImpl) assuming this would be enough to add my UsernameToken to all outgoing SOAP requests, but it does not seem to be happening.

I'm running Mule with debug logging and no errors are being reported - the client simply makes its SOAP request and the server returns the test data just fine, but no WS-Security Username token is being sent. Clearly, I have set something up wrong, but I can't see what.

Any help very much appreciated!

<beans xmlns="http://www.springframework.org/schema/beans" >
xmlnssmiliesi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:cxf="http://cxf.apache.org/core"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd ">

<bean name="WSS4JOutInterceptor" class="org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor">
<constructor-arg>
<map>
<entry key="action" value="UsernameToken" />
<entry key="user" value="myUser" />
<entry key="passwordType" value="PasswordText" />
<entry key="passwordCallbackRef" value-ref="clientCallback" />
</map>
</constructor-arg>
</bean>

<bean id="cxf" class="org.apache.cxf.bus.CXFBusImpl">
<property name="outInterceptors">
<list>
<ref bean="WSS4JOutInterceptor" />
</list>
</property>
</bean>

<bean id="clientCallback" class="test.opensource.test.ClientPasswordCallback" />
</beans>
tijs.rademakers (494) [Avatar] Offline
#2
Re: Problem with WSS4J interceptors and Mule
Hi,

In your config file you are using the cxf:connector element.
You should change this to the cxf-wsdl:connector element, because in the outbound endpoint configuration you're using the cxf:wsdl transport.

Best regards,

Tijs
bobs99 (5) [Avatar] Offline
#3
Re: Problem with WSS4J interceptors and Mule
Tijs, many thanks for your swift reply.

Yes, I have totally confused myself about this before. You write: "You should change this to the cxf-wsdl:connector element, because in the outbound endpoint configuration you're using the cxf:wsdl transport."

Well I thought I was using the 'wsdl-cxf' transport and not the 'cxf-wsdl' transport because in your chapter 7 examples you use wsdl-cxf: too. Ok, so I make the suggested change to my wsdl-cxf transport:

<wsdl-cxf:connector name="cxfConnector">
<spring:property name="configurationLocation" value="wss-cxf-outconfig.xml" />
</wsdl-cxf:connector>

then I get the following error:

* A Fatal error has occurred while the server was running: *

* The prefix "wsdl-cxf" for element "wsdl-cxf:connector" is not bound. *

* (org.xml.sax.SAXParseException) *

OK, so I presume this means that first my wsdl-cxf connector needs to be bound to a schema. So again looking at your code for chapter 7

For the wsdl-cxf namespace you use this:
xmlns:wsdl-cxf="http://www.mulesource.org/schema/mule/wsdl-xfire/2.0"

and for schema you use..

http://www.mulesource.org/schema/mule/cxf-wsdl/2.0 http://www.mulesource.org/schema/mule/cxf-wsdl/2.0/mule-cxf-wsdl.xsd">

But why does your schema here say cxf-wsdl and not wsdl-cxf???

Anyway, copying this namespace and schema into my config I still get errors, although different ones:

* A Fatal error has occurred while the server was running: *
* cvc-complex-type.2.4.a: Invalid content was found starting with element *
* 'wsdl-cxf:connector'. One of *
* '{"http://www.springframework.org/schema/beans":beans, *
* "http://www.springframework.org/schema/beans":bean, *
* "http://www.springframework.org/schema/context":property-placeholder, *
* "http://www.mulesource.org/schema/mule/core/2.1":global-property, *
* "http://www.mulesource.org/schema/mule/core/2.1":configuration, *
* "http://www.mulesource.org/schema/mule/core/2.1":notifications, *
* "http://www.mulesource.org/schema/mule/core/2.1":abstract-extension, *
* "http://www.mulesource.org/schema/mule/core/2.1":abstract-security-manager, *
* "http://www.mulesource.org/schema/mule/core/2.1":abstract-transaction-manage *
* r, "http://www.mulesource.org/schema/mule/core/2.1":abstract-connector, *
* "http://www.mulesource.org/schema/mule/core/2.1":abstract-global-endpoint, *
* "http://www.mulesource.org/schema/mule/core/2.1":abstract-transformer, *
* "http://www.mulesource.org/schema/mule/core/2.1":abstract-filter, *
* "http://www.mulesource.org/schema/mule/core/2.1":abstract-model, *
* "http://www.mulesource.org/schema/mule/core/2.1":abstract-interceptor-stack} *
* ' is expected. (org.xml.sax.SAXParseException) *

This time, I think it's binding OK, but the schema being used does not recognize the element 'connector' in the wsdl-cxf transport.

<wsdl-cxf:connector name="cxfConnector">
<spring:property name="configurationLocation" value="wss-cxf-outconfig.xml" />
</wsdl-cxf:connector>

And without this being recognized by the wsdl-cxf (or is it cxf-wsdl??) transport, then how can I tell it where its external cxf config file is to be found??

Any clarification on my:
1. wsdl-cxf (or cxf-wsdl) transport confusion
and
2. Correct schema to use for this transport (for CXF 2.1 & Mule 2.1).
Would be very much appreciated.

Many thanks.