当前位置: 首页 > 知识库问答 >
问题:

Apache Camel如何将SOAP消息从JMS队列传递到CXFendpoint

拓拔玺
2023-03-14

我正在尝试创建一条骆驼路线,它将:

  1. 从队列中获取JMS消息,消息体是SOAP请求

这是我的代码:

private void setupRequestRoute() {

    from("jms:queue:input")

    .setHeader(CxfConstants.OPERATION_NAME, simple("XXXXXX"))
    .setHeader(CxfConstants.OPERATION_NAMESPACE, simple("XXXXXX"))

    .log("Route headers : ${headers}")

    .to("cxf:bean:myEndpoint")
    .to("jms:queue:response")
        .end();
}

endpoint配置

<cxf:cxfEndpoint id="myServiceEndpoint"
                 address="http://localhost:8080/MyService/V2"
                 wsdlURL="schemas/MyService.wsdl"
                 xmlns:c="http://xxxx.xxxx/xxxxxxxx/XXX/MyService/V2">
 <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>

我觉得我误解了这个场景中骆驼工作的一些基本原理。似乎是soap信封的存在导致了此问题。我曾假设camel能够获取原始soap消息并将其转换为cxfendpoint的正确消息格式。

有人能向我解释一下如何将SOAP请求传递给CXFendpoint吗?

2018-12-03 12:27:32,222 | ERROR | INPUT] | DefaultErrorHandler              | 43 - org.apache.camel.camel-core - 2.16.4 | Failed delivery for (MessageId: ID:xxxxxxxxxxxx-46588-1543829293785-1:21:1:1:1 
on ExchangeId: ID-xxxxxxxxxxxx-35264-1543835233229-2-1). Exhausted after delivery attempt: 1 caught: java.lang.IllegalArgumentException: The PayLoad elements cannot fit with the message parts of the BindingOpera
tion. Please check the BindingOperation and PayLoadMessage.

Message History
---------------------------------------------------------------------------------------------------------------------------------------
RouteId              ProcessorId          Processor                                                                        Elapsed (ms)
[from.XS.to.xsb?dat] [from.XS.to.xsb?dat] [jms://queue:input                                                             ] [        17]
[from.XS.to.xsb?dat] [setHeader7        ] [setHeader[operationName]                                                      ] [         0]
[from.XS.to.xsb?dat] [setHeader8        ] [setHeader[operationNamespace]                                                 ] [         0]
[from.XS.to.xsb?dat] [log6              ] [log                                                                           ] [        12]
[from.XS.to.xsb?dat] [to45              ] [cxf:bean:myEndpoint                                                           ] [         3]

Exchange
---------------------------------------------------------------------------------------------------------------------------------------
Exchange[
        Id                  ID-xxxxxxxxxxxx-35264-1543835233229-2-1
        ExchangePattern     InOut
        Headers             {breadcrumbId=ID:xxxxxxxxxxxx-46588-1543829293785-1:21:1:1:1, CamelRedelivered=false, CamelRedeliveryCounter=0, JMSCorrelationID=null, JMSCorrelationIDAsBytes=null, JMSDeliveryMode=2,
 JMSDestination=queue://input, JMSExpiration=0, JMSMessageID=ID:xxxxxxxxxxxx-46588-1543829293785-1:21:1:1:1, JMSPriority=4, JMSRedelivered=false, JMSReplyTo=queue://response, JMSTimestamp=1543840052184, JMSType=null, JMSXGroupID=null, JMSXUserID=null, operationName=MyOperation, operationNamespace=MyOperationNameSpace}
        BodyType            String
        Body                <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v2="http://xxxx.xxxx/xxxxxxxx/xxx/xxxxxxxxxxxxxxxxxx/V2" xmlns:v21="http://xxxx.xxxx/xxxxxxxx/xxx/xxxxxx/V2">   
        <soapenv:Header><wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecur
ity-utility-1.0.xsd"><wsse:UsernameToken wsu:Id="UsernameToken-xxxx"><wsse:Username>username</wsse:Username><wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-ws
s-username-token-profile-1.0#PasswordDigest">xxxx</wsse:Password><wsse:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">
xxxxx</wsse:Nonce><wsu:Created>2018-12-03T12:27:32.183Z</wsu:Created></wsse:UsernameToken></wsse:Security></soapenv:Header>   <soapenv:Body>      <v2:MyRequest>
...
...
</v2:MyRequest>   </soapenv:Body></soapenv:Envelope>
]

Stacktrace



Stacktrace
---------------------------------------------------------------------------------------------------------------------------------------
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)[44:org.apache.camel.camel-cxf:2.16.4]
        at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:470)[57:org.apache.cxf.cxf-core:3.1.5]
        at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:416)[57:org.apache.cxf.cxf-core:3.1.5]
        at org.apache.camel.component.cxf.CxfProducer.process(CxfProducer.java:134)[44:org.apache.camel.camel-cxf:2.16.4]
        at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:145)[43:org.apache.camel.camel-core:2.16.4]
        at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:77)[43:org.apache.camel.camel-core:2.16.4]
        at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:460)[43:org.apache.camel.camel-core:2.16.4]
        at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:196)[43:org.apache.camel.camel-core:2.16.4]
        at org.apache.camel.processor.Pipeline.process(Pipeline.java:121)[43:org.apache.camel.camel-core:2.16.4]
        at org.apache.camel.processor.Pipeline.process(Pipeline.java:83)[43:org.apache.camel.camel-core:2.16.4]
        at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:196)[43:org.apache.camel.camel-core:2.16.4]
        at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:109)[43:org.apache.camel.camel-core:2.16.4]
        at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:91)[43:org.apache.camel.camel-core:2.16.4]
        at org.apache.camel.component.jms.EndpointMessageListener.onMessage(EndpointMessageListener.java:112)[46:org.apache.camel.camel-jms:2.16.4]
        at org.springframework.jms.listener.AbstractMessageListenerContainer.doInvokeListener(AbstractMessageListenerContainer.java:555)[154:org.apache.servicemix.bundles.spring-jms:3.2.17.RELEASE_1]
        at org.springframework.jms.listener.AbstractMessageListenerContainer.invokeListener(AbstractMessageListenerContainer.java:515)[154:org.apache.servicemix.bundles.spring-jms:3.2.17.RELEASE_1]
        at org.springframework.jms.listener.AbstractMessageListenerContainer.doExecuteListener(AbstractMessageListenerContainer.java:485)[154:org.apache.servicemix.bundles.spring-jms:3.2.17.RELEASE_1]
        at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.doReceiveAndExecute(AbstractPollingMessageListenerContainer.java:325)[154:org.apache.servicemix.bundles.spring-jms:3.2.17.RELEASE_1]
        at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute(AbstractPollingMessageListenerContainer.java:263)[154:org.apache.servicemix.bundles.spring-jms:3.2.17.RELEASE_1]
        at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:1103)[154:org.apache.servicemix.bundles.spring-jms:3.2.17.RELEASE_1]
        at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.executeOngoingLoop(DefaultMessageListenerContainer.java:1095)[154:org.apache.servicemix.bundles.spring-jms:3.2.17.RELEASE_1]
        at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:992)[154:org.apache.servicemix.bundles.spring-jms:3.2.17.RELEASE_1]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)[:1.8.0_181]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)[:1.8.0_181]
        at java.lang.Thread.run(Thread.java:748)[:1.8.0_181]

共有1个答案

阎令
2023-03-14

您可以指定有效负载数据格式,但要根据用于soap:body处理的文档。您可以用XPath将主体导出到当前exchange中,还是需要所有WSE头?

或者尝试其他数据格式(我想在以后的版本中称为“原始数据”)或者,CXF\U消息听起来更接近您想要实现的目标。

 类似资料:
  • 那么,在JMS之前,我必须自己将消息转换为POJO吗?我对Camel完全陌生,但我得到的印象是Camel应该自动处理类型转换。

  • 我正在使用AWS sdk开发基于SQS的队列pub-sub。 在非常基本的原型中,我将消息并发地推送到我已经创建的队列中。但是,如何才能确定我的消息正在被推送到队列中呢?

  • 我第一次使用Spring集成 脚本: 从源JMS队列读取消息,然后推送到目标JMS队列使用的通道。如果目标Jndi名称错误,重试机制就会启动。 重试耗尽后,消息推送到异常JMS队列中。 所有队列都在我本地的Weblogic 12c中。该应用程序是Spring Boot 2.1.10。释放Spring集成5.1.9。释放 当目标JMS队列的Jndi正确时,则消息发送成功。这正在工作,我可以看到消息,

  • Artemis 2.2.0的新版本有一个,它显然是在内部消息ID(而不是JMS消息ID)上操作的。 问题是:如何在Artemis Version2.x中使用JMS消息ID将消息从一个队列移动到另一个队列?

  • 我设置了一个EJB项目,使用JMS将持久性实体对象发送到MDB。我使用JBoss EAP 7,使用Apache ActiveMQ作为消息传递提供程序。我像这样设置ConnectionFactory和队列: 这是我的消息生成器,它接收“Account”实体对象作为参数并将其发送到队列: EntityEnqueueBean。Java语言 MDB从队列接收消息并对其进行处理: java账户 不确定我做错

  • 我是Spring JMS的新手。我的应用程序是使用Spring Boot开发的,并部署在JBoss EAP7.2.0中。我有一个远程队列,它是一个活动的MQ Artemis队列,也嵌入在JBoss EAP7.2.0中。有人能建议我如何使用Spring Boot的JmsTemplate向远程JMS队列发送消息吗?基本上,我不知道应该如何定义远程connectionFactory来连接到远程队列。