我有一个源web服务,它有一个不接受任何主体请求的操作。这是它期望的请求:
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
<soap:Header/>
<soap:Body/>
</soap:Envelope>我有一个使用者服务,它使用camel-cxf:cxfEndpoint调用此操作。端点被配置为将dataFormat作为“有效负载”。就像这样:
<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>在调用此操作时,我将body设置为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,XML不添加任何元素,但不能解决任何问题。我是不是遗漏了什么?这是因为dataFormat是有效载荷吗?
发布于 2018-10-26 13:25:52
我能够通过创建一个空的CxfPayload来解决这个问题:
List<Source> elements = new ArrayList<Source>();
CxfPayload<SoapHeader> cxfPayload = new CxfPayload<SoapHeader>(null, elements, null);
exchange.getIn().setBody(cxfPayload);这对我有用!
发布于 2018-10-26 10:17:01
您的SOAP信封不需要包含至少被调用的目标方法的最小主体吗?
<soap:Body>
<m:SomeOperation xmlns:m="..."/>
</soap:Body>https://stackoverflow.com/questions/53005043
复制相似问题