Hi,
Inexperienced camel user here, I'm trying to connect a JMS queue to a CXF
endpoint. My wsdl has the following security policy on it:

  <wsp:UsingPolicy wsdl:required="true" />
  <wsp:Policy wsu:Id="SecurityPolicy">
    <sp:UsernameToken sp:IncludeToken="
http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702/IncludeToken/AlwaysToRecipient
">
      <wsp:Policy>
        <sp:HashPassword />
      </wsp:Policy>
    </sp:UsernameToken>
  </wsp:Policy>

Here is a condensed version of my CXF bean:
    <cxf:cxfEndpoint id="myServiceEndpoint"
                     address="${url}/MyService/V2"
                     wsdlURL="schemas/MyService.wsdl"
                     xmlns:c="http://xxxx.xxxx/xxxxxxxx/xxx/MyService/V2";>
     <cxf:inInterceptors>
       <ref bean="myAuthorizingInterceptor"/>
       <ref bean="logInInterceptor"/>
     </cxf:inInterceptors>
     <cxf:outInterceptors>
       <ref bean="logOutInterceptor"/>
     </cxf:outInterceptors>
     <cxf:outFaultInterceptors>
       <ref bean="interceptor.out.soap.fault"/>
     </cxf:outFaultInterceptors>
      <cxf:properties>
          <entry key="schema-validation-enabled" value="true" />
          <entry key="dataFormat" value="PAYLOAD" />
          <entry key="defaultBus" value="true" />
          <entry key="allowStreaming" value="false" />
      </cxf:properties>
    </cxf:cxfEndpoint>

Here's my route:
    from("jms:TO.MY.SERVICE")
        .setHeader(CxfConstants.OPERATION_NAME, simple(MYSERVICE_NAMESPACE))
        .setHeader(CxfConstants.OPERATION_NAMESPACE,
simple(MYSERVICE_NAMESPACE))
        .to(cxf:bean:myServiceEndpoint)

This is the error I get - I think its because the Soap envelope is included
in the message, but I need the headers to verify the security token against
an internal web service.

(I have masked the operation and namespaces, the web service works
correctly when envoked via http)

2018-12-11 01:10:33,230 | WARN  | TO.MY.SERVICE] |
DeadLetterChannel                | 53 - org.apache.camel.camel-core -
2.16.5 | Failed delivery for (MessageId:
ID:xxx-37140-1544445503462-1:9:1:1:1 on ExchangeId:
ID-dev-mgcp-n2-45116-1544445251173-17-1). On delivery attempt: 0 caught:
java.lang.IllegalArgumentException: The PayLoad elements cannot fit with
the message parts of the BindingOperation. Please check the
BindingOperation and PayLoadMessage.
java.lang.IllegalArgumentException: The PayLoad elements cannot fit with
the message parts of the BindingOperation. Please check the
BindingOperation and PayLoadMessage.
        at
org.apache.camel.component.cxf.CxfEndpoint$CamelCxfClientImpl.setParameters(CxfEndpoint.java:1189)[54:org.apache.camel.camel-cxf:2.16.5]
        at
org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:470)[70:org.apache.cxf.cxf-core:3.1.9]
        at
org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:416)[70:org.apache.cxf.cxf-core:3.1.9]
        at
org.apache.camel.component.cxf.CxfProducer.process(CxfProducer.java:134)[54:org.apache.camel.camel-cxf:2.16.5]
        at
org.apache.camel.processor.SendProcessor.process(SendProcessor.java:145)[53:org.apache.camel.camel-core:2.16.5]
        at
org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:77)[53:org.apache.camel.camel-core:2.16.5]
        at
org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:460)[53:org.apache.camel.camel-core:2.16.5]
        at
org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:196)[53:org.apache.camel.camel-core:2.16.5]
        at
org.apache.camel.processor.Pipeline.process(Pipeline.java:121)[53:org.apache.camel.camel-core:2.16.5]
        at
org.apache.camel.processor.Pipeline.process(Pipeline.java:83)[53:org.apache.camel.camel-core:2.16.5]
        at
org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:196)[53:org.apache.camel.camel-core:2.16.5]
        at
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:109)[53:org.apache.camel.camel-core:2.16.5]
        at
org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:91)[53:org.apache.camel.camel-core:2.16.5]
        at
org.apache.camel.component.jms.EndpointMessageListener.onMessage(EndpointMessageListener.java:112)[59:org.apache.camel.camel-jms:2.16.5]
        at
org.springframework.jms.listener.AbstractMessageListenerContainer.doInvokeListener(AbstractMessageListenerContainer.java:555)[171:org.apache.servicemix.bundles.spring-jms:3.2.18.RELEASE_1]
        at
org.springframework.jms.listener.AbstractMessageListenerContainer.invokeListener(AbstractMessageListenerContainer.java:515)[171:org.apache.servicemix.bundles.spring-jms:3.2.18.RELEASE_1]
        at
org.springframework.jms.listener.AbstractMessageListenerContainer.doExecuteListener(AbstractMessageListenerContainer.java:485)[171:org.apache.servicemix.bundles.spring-jms:3.2.18.RELEASE_1]
        at
org.springframework.jms.listener.AbstractPollingMessageListenerContainer.doReceiveAndExecute(AbstractPollingMessageListenerContainer.java:325)[171:org.apache.servicemix.bundles.spring-jms:3.2.18.RELEASE_1]
        at
org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute(AbstractPollingMessageListenerContainer.java:263)[171:org.apache.servicemix.bundles.spring-jms:3.2.18.RELEASE_1]
        at
org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:1103)[171:org.apache.servicemix.bundles.spring-jms:3.2.18.RELEASE_1]
        at
org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.executeOngoingLoop(DefaultMessageListenerContainer.java:1095)[171:org.apache.servicemix.bundles.spring-jms:3.2.18.RELEASE_1]
        at
org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:992)[171:org.apache.servicemix.bundles.spring-jms:3.2.18.RELEASE_1]
        at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)[:1.8.0_152]
        at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)[:1.8.0_152]
        at java.lang.Thread.run(Thread.java:748)[:1.8.0_152]



I tried updating the .to part of the route to
    .to(cxf:bean:myServiceEndpoint?dataFormat=RAW)

Which actually works if the security profile is removed from the wsdl, but
seems to fail on the CxfProducer when the security is enabled.

2018-12-12 03:00:56,456 | WARN  | TO.MY.SERVICE |
PhaseInterceptorChain            | 70 - org.apache.cxf.cxf-core - 3.1.9 |
Interceptor for {
http://xxxx.xxxx/xxxxxxxx/xxx/MyService/V2}MyService#{http://xxxx
.xxxx/xxxxxxxx/xxx/MyService/V2}MyService has thrown exception, unwinding
now
org.apache.cxf.ws.policy.PolicyException: No username available
        at
org.apache.cxf.ws.security.wss4j.AbstractTokenInterceptor.policyNotAsserted(AbstractTokenInterceptor.java:216)[104:org.apache.cxf.cxf-rt-ws-security:3.1.9]
        at
org.apache.cxf.ws.security.wss4j.UsernameTokenInterceptor.addUsernameToken(UsernameTokenInterceptor.java:440)[104:org.apache.cxf.cxf-rt-ws-security:3.1.9]
        at
org.apache.cxf.ws.security.wss4j.UsernameTokenInterceptor.addToken(UsernameTokenInterceptor.java:373)[104:org.apache.cxf.cxf-rt-ws-security:3.1.9]
        at
org.apache.cxf.ws.security.wss4j.AbstractTokenInterceptor.handleMessage(AbstractTokenInterceptor.java:102)[104:org.apache.cxf.cxf-rt-ws-security:3.1.9]
        at
org.apache.cxf.ws.security.wss4j.AbstractTokenInterceptor.handleMessage(AbstractTokenInterceptor.java:61)[104:org.apache.cxf.cxf-rt-ws-security:3.1.9]
        at
org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:308)[70:org.apache.cxf.cxf-core:3.1.9]
        at
org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:514)[70:org.apache.cxf.cxf-core:3.1.9]
        at
org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:416)[70:org.apache.cxf.cxf-core:3.1.9]
        at
org.apache.camel.component.cxf.CxfProducer.process(CxfProducer.java:134)[54:org.apache.camel.camel-cxf:2.16.5]
        at
org.apache.camel.processor.SendProcessor.process(SendProcessor.java:145)[53:org.apache.camel.camel-core:2.16.5]
        at
org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:77)[53:org.apache.camel.camel-core:2.16.5]
        at
org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:460)[53:org.apache.camel.camel-core:2.16.5]
        at
org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:196)[53:org.apache.camel.camel-core:2.16.5]
        at
org.apache.camel.processor.Pipeline.process(Pipeline.java:121)[53:org.apache.camel.camel-core:2.16.5]
        at
org.apache.camel.processor.Pipeline.process(Pipeline.java:83)[53:org.apache.camel.camel-core:2.16.5]
        at
org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:196)[53:org.apache.camel.camel-core:2.16.5]
        at
org.apache.camel.component.file.GenericFileConsumer.processExchange(GenericFileConsumer.java:442)[53:org.apache.camel.camel-core:2.16.5]
        at
org.apache.camel.component.file.GenericFileConsumer.processBatch(GenericFileConsumer.java:214)[53:org.apache.camel.camel-core:2.16.5]
        at
org.apache.camel.component.file.GenericFileConsumer.poll(GenericFileConsumer.java:178)[53:org.apache.camel.camel-core:2.16.5]
        at
org.apache.camel.impl.ScheduledPollConsumer.doRun(ScheduledPollConsumer.java:174)[53:org.apache.camel.camel-core:2.16.5]
        at
org.apache.camel.impl.ScheduledPollConsumer.run(ScheduledPollConsumer.java:101)[53:org.apache.camel.camel-core:2.16.5]
        at
java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)[:1.8.0_152]
        at
java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)[:1.8.0_152]
        at
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180)[:1.8.0_152]
        at
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)[:1.8.0_152]
        at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)[:1.8.0_152]
        at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)[:1.8.0_152]
        at java.lang.Thread.run(Thread.java:748)[:1.8.0_152]

Any help or suggestions on the approach to achieve this appreciated.

Reply via email to