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

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" />

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

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="" >
xsi:schemaLocation=" ">

<bean name="WSS4JOutInterceptor" class="">
<entry key="action" value="UsernameToken" />
<entry key="user" value="myUser" />
<entry key="passwordType" value="PasswordText" />
<entry key="passwordCallbackRef" value-ref="clientCallback" />

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

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

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,

bobs99 (5) [Avatar] Offline
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" />

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:

and for schema you use..">

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 *
* '{"":beans, *
* "":bean, *
* "":property-placeholder, *
* "":global-property, *
* "":configuration, *
* "":notifications, *
* "":abstract-extension, *
* "":abstract-security-manager, *
* "":abstract-transaction-manage *
* r, "":abstract-connector, *
* "":abstract-global-endpoint, *
* "":abstract-transformer, *
* "":abstract-filter, *
* "":abstract-model, *
* "":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" />

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
2. Correct schema to use for this transport (for CXF 2.1 & Mule 2.1).
Would be very much appreciated.

Many thanks.