Hi there,

currently I'm trying to test a route starting with an cxf-endpoint using a
ProducerTemplate.
I add the necessary securityheaders like this:

Document document = message.getSOAPPart();

WSSecHeader securityHeader = new WSSecHeader();
securityHeader.setMustUnderstand(false);
securityHeader.insertSecurityHeader(document);

WSSecUsernameToken usernameToken = new WSSecUsernameToken();
usernameToken.setPasswordType(WSConstants.PASSWORD_TEXT);
usernameToken.setUserInfo("myUser", "######");
usernameToken.addCreated();
usernameToken.addNonce();
usernameToken.build(document, securityHeader);

WSSecTimestamp timestamp = new WSSecTimestamp();
timestamp.build(document, securityHeader);
message.saveChanges();

Printing the resulting message is looks quite like the one send by SoapUI
(which works by the way). Unfortunately when I use this message to call my
endpoint via a ProducerTemplate it fails with the following stacktrace:

Code used to call my route:

Map<String, Object>headers = new Hashtable<String, Object>();
headers.put(CxfConstants.CAMEL_CXF_MESSAGE, message);
String response = producerTemplate.requestBodyAndHeaders(
"cxf:bean:sst_3_3", new Object[1], headers, String.class );

Stacktrace:

2013-04-15 12:57:32,232 [main] WARN 
org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory - Could not find
endpoint/port for {http://adapter.cardprocessing.osplus/SST_3_3}SST_3_3Port
in wsdl. Using {http://adapter.cardprocessing.osplus/SST_3_3}SST_3_3SOAP.
2013-04-15 12:57:32,451 [default-workqueue-1] WARN 
org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor - Request does not
contain Security header, but it's a fault.
Exception in thread "main" org.apache.camel.CamelExecutionException:
Exception occurred during execution on the exchange: Exchange[Message: [Body
is null]]
        at
org.apache.camel.util.ObjectHelper.wrapCamelExecutionException(ObjectHelper.java:1286)
        at
org.apache.camel.util.ExchangeHelper.extractResultBody(ExchangeHelper.java:618)
        at
org.apache.camel.impl.DefaultProducerTemplate.extractResultBody(DefaultProducerTemplate.java:442)
        at
org.apache.camel.impl.DefaultProducerTemplate.sendBodyAndHeaders(DefaultProducerTemplate.java:247)
        at
org.apache.camel.impl.DefaultProducerTemplate.requestBodyAndHeaders(DefaultProducerTemplate.java:296)
        at
org.apache.camel.impl.DefaultProducerTemplate.requestBodyAndHeaders(DefaultProducerTemplate.java:292)
        at
org.apache.camel.impl.DefaultProducerTemplate.requestBodyAndHeaders(DefaultProducerTemplate.java:329)
        at
osplus.cardprocessing.adapter.sst_3_3.SOAPTestCaller.sendSOAPCall(SOAPTestCaller.java:78)
        at
osplus.cardprocessing.adapter.sst_3_3.SOAPTestCaller.main(SOAPTestCaller.java:39)
Caused by: org.apache.cxf.binding.soap.SoapFault: An error was discovered
processing the <wsse:Security> header
        at
org.apache.cxf.binding.soap.interceptor.Soap11FaultInInterceptor.unmarshalFault(Soap11FaultInInterceptor.java:75)
        at
org.apache.cxf.binding.soap.interceptor.Soap11FaultInInterceptor.handleMessage(Soap11FaultInInterceptor.java:46)
        at
org.apache.cxf.binding.soap.interceptor.Soap11FaultInInterceptor.handleMessage(Soap11FaultInInterceptor.java:35)
        at
org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:262)
        at
org.apache.cxf.interceptor.AbstractFaultChainInitiatorObserver.onMessage(AbstractFaultChainInitiatorObserver.java:112)
        at
org.apache.cxf.binding.soap.interceptor.CheckFaultInterceptor.handleMessage(CheckFaultInterceptor.java:69)
        at
org.apache.cxf.binding.soap.interceptor.CheckFaultInterceptor.handleMessage(CheckFaultInterceptor.java:34)
        at
org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:262)
        at org.apache.cxf.endpoint.ClientImpl.onMessage(ClientImpl.java:783)
        at
org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponseInternal(HTTPConduit.java:1694)
        at
org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream$1.run(HTTPConduit.java:1535)
        at
org.apache.cxf.workqueue.AutomaticWorkQueueImpl$3.run(AutomaticWorkQueueImpl.java:426)
        at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
        at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
        at
org.apache.cxf.workqueue.AutomaticWorkQueueImpl$AWQThreadFactory$1.run(AutomaticWorkQueueImpl.java:351)
        at java.lang.Thread.run(Thread.java:662)

I assume I need to put the security information somewhere else but I don't
have a clue where...

Anybody an idea?




--
View this message in context: 
http://camel.465427.n5.nabble.com/How-to-Use-ProducerTemplate-for-testing-secure-CXF-WS-tp5730894.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to