首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何以dataFormat作为有效负载调用webservice

如何以dataFormat作为有效负载调用webservice
EN

Stack Overflow用户
提问于 2015-11-09 08:51:50
回答 1查看 2.9K关注 0票数 0

我用的是骆驼2.16.0

创建了一个camel路由来调用web服务,dataFormat作为MESSAGE和我正常地得到响应。使用ProducerTemlate调用此路由。

代码语言:javascript
复制
//payloadXml is a string which contains SOAP Request Message.
Object response = producerTemplate.requestBody("direct:invokeWS", payloadXml);

<route id="my_Sample_Camel_Route_with_CXF">
<from uri="direct:invokeWS" />
    <to uri="cxf://http://localhost:8111/camel_MQ/TestService?wsdlURL=http://localhost:8111/camel_MQ/TestService?wsdl&amp;serviceName={http://www.test.org/interface/test/ws}camel_MQ-ws&amp;portName={http://www.test.org/interface/test}TestEndpoint&amp;dataFormat=MESSAGE" />
<log message="------------->> ${body}" />
</route>

但是一旦我将dataFormat更改为“有效负载

我有例外。

代码语言:javascript
复制
Caused by: 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:1171)

尝试创建CxfPayload,然后在调用WS时将其发送给producerTeamplate,但仍然是相同的异常,

EN

回答 1

Stack Overflow用户

发布于 2015-11-12 05:29:19

最后,我能够使用dataFormat作为有效负载来调用WS。创建了CxfPayload对象,并向其添加了SOAP头和主体。

但我还是得到了同样的例外:“PayLoad元素不能与BindingOperation的消息部分相匹配”

然后,我在调用webservice时添加了defaultOperationName & defaultOperationNamespace头,如下所示。

代码语言:javascript
复制
<to uri="cxf:bean:camel_MQ_MQ-ws?dataFormat=PAYLOAD&amp;defaultOperationName=TestService&amp;defaultOperationNamespace=http://www.camel_MQ.org/interface&amp;loggingFeatureEnabled=true" />

希望这有帮助;-)

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/33605423

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档