我有一个源 Web 服务,它有一个不将任何主体作为请求的操作。这是它期望的请求:<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope"> <soap:Header/> <soap:Body/></soap:Envelope>我有一个消费者服务,它使用camel-cxf:cxfEndpoint 调用此操作。端点配置为将 dataFormat 设置为“Payload”。像这样的东西:<camel-cxf:cxfEndpoint address="SOURCE_ENDPOINT" id="abcEndpoint" serviceClass="PATH_TO_GENERATED_SERVICE_CLASS"> <camel-cxf:properties> <entry key="dataFormat" value="PAYLOAD"/> </camel-cxf:properties> <camel-cxf:outInterceptors> <ref component-id="wss4jOutInterceptor"/> </camel-cxf:outInterceptors> </camel-cxf:cxfEndpoint>我在调用此操作时将主体设置为 null,期望 CXFInterceptor 用 SOAPEnvelope 包装主体。但是,当我调用该服务时,我得到:java.lang.IllegalArgumentException:PayLoad 元素无法适应 BindingOperation 的消息部分。请检查 BindingOperation 和 PayLoadMessage我检查了源 wsdl 中生成的 ServiceClass 以检查操作是否需要任何主体。这是它期望的方法:@WebMethod(operationName = "SomeOperation", action = "SomeOperation") @WebResult(name = "Result", targetNamespace = "namespace_for_the_service", partName = "data") public Result someOperation();我还尝试使用 XSLT 转换为不添加任何元素但不能解决任何问题的 XML。我错过了什么吗?是因为数据格式是 Payload 吗?
2 回答
蓝山帝景
TA贡献1843条经验 获得超7个赞
我能够通过创建一个空的 CxfPayload 来解决这个问题:
List<Source> elements = new ArrayList<Source>();
CxfPayload<SoapHeader> cxfPayload = new CxfPayload<SoapHeader>(null, elements, null);
exchange.getIn().setBody(cxfPayload);
这对我有用!!!!
四季花海
TA贡献1811条经验 获得超5个赞
您的 SOAP 信封不需要包含至少包含目标调用方法的最小主体吗?
<soap:Body>
<m:SomeOperation xmlns:m="..."/>
</soap:Body>
添加回答
举报
0/150
提交
取消
