[英]Creating SOAP message in Apache Camel when dataFormat is MESSAGE or CXF_MESSAGE
我想通过Apache Camel调用Web服务,dataFormat是MESSAGE。 我想构造下面的SOAP消息:
<soapenv:Envelope`enter code here`
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Header>
<platformMsgs:documentInfo
xmlns:platformMsgs="urn:messages_2015_1.platform.webservices.netsuite.com">
<platformMsgs:nsId>WEBSERVICES_3479023</platformMsgs:nsId>
</platformMsgs:documentInfo>
</soapenv:Header>
<soapenv:Body>
<addListResponse
xmlns="">
<platformMsgs:writeResponseList
xmlns:platformMsgs="urn:messages_2015_1.platform.webservices.netsuite.com">
<platformCore:status isSuccess="true"
xmlns:platformCore="urn:core_2015_1.platform.webservices.netsuite.com"/>
<platformMsgs:writeResponse>
<platformCore:status isSuccess="false"
xmlns:platformCore="urn:core_2015_1.platform.webservices.netsuite.com">
<platformCore:statusDetail type="ERROR">
<platformCore:code>DUP_ENTITY</platformCore:code>
<platformCore:message>This entity already exists.</platformCore:message>
</platformCore:statusDetail>
</platformCore:status>
</platformMsgs:writeResponse>
</platformMsgs:writeResponseList>
</addListResponse>`enter code here`
</soapenv:Body>
</soapenv:Envelope>
任何人都可以帮我一些代码片段或示例来说明如何创建这个SOAP消息吗?
我可以为您提供有关如何在Spring DSL中使用CXF POJO格式的一些想法。
Spring Context可能如下所示:
<?xml version="1.0" encoding="UTF-8"?>
<spring:beans xmlns:spring="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:camel-cxf="http://camel.apache.org/schema/cxf"
xmlns:camel-spring="http://camel.apache.org/schema/spring"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://camel.apache.org/schema/cxf http://camel.apache.org/schema/cxf/camel-cxf.xsd
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
<!-- inbound Service endpoint -->
<camel-cxf:cxfEndpoint id="my-test-endpoint"
address="/myTest" serviceName="mySrv:MyService"
serviceClass="com.foo.myservice.MyServicePortPortType"
endpointName="mySrv:MyServicePortPort"
wsdlURL="classpath:myTest.wsdl"
xmlns:mySrv="http://foo.com/myService/">
<camel-cxf:properties>
<spring:entry key="dataFormat" value="POJO" />
...
</camel-cxf:properties>
</camel-cxf:cxfEndpoint>
...
<camel-spring:camelContext id="MyTestService_Ctx">
...
<camel-spring:route id="myTest-route">
<camel-spring:from uri="cxf:bean:my-test-endpoint"
id="inbound-myTest-service" />
...
很简单:
在Spring中,您将cxf端点定义为{http://camel.apache.org/schema/cxf}cxfEndpoint
bean,
那么你的参考,将其从骆驼航线from
或to
由URI组件,它看起来像: uri="cxf:bean:{endpoint bean id}"
然后您可能有两种情况:情况1. WSDL将Header定义为消息的一部分。 由Maven CXF插件生成的服务之后:
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
只需检查Service Interface的外观。
情况2:WSDL没有定义自定义标头,您需要添加它。
看看我对另一个问题的回答: 无法在使用dataFormat作为POJO通过Camel调用Web Service时设置SOAP Header
PS如果由于某些原因不需要,明确编组/解组JAXB POJO,则不需要任何其他内容。 您不关心SOAP等.CXF将从您的WSDL定义中为您完成。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.