在Apache的骆驼创建SOAP消息时DATAFORMAT是消息或CXF_MESSAGE
我想打电话给通过Apache骆驼Web服务和DATAFORMAT是MESSAGE。我想构建如下的SOAP消息:在Apache的骆驼创建SOAP消息时DATAFORMAT是消息或CXF_MESSAGE
<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>
能anyoneone帮助我做一些代码片段或例子说明如何创建这个SOAP消息?
我可以为您提供一些有关如何在Spring DSL中使用CXF POJO格式的想法。
Spring上下文可能看起来像:
<?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
豆,那么你从骆驼参考吧路线
from
或to
组件由uri看起来像这样:uri="cxf:bean:{endpoint bean id}"
则可能有两种情况: 情况1 WSDL已报头定义为消息的一部分。 Maven CXF插件生成服务后:
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
只需检查Service Interface的外观就好。
案例2:WSDL不具有自定义页眉定义的,您需要添加它。
两个看看我回答另一个问题: Unable to set SOAP Header while calling Web Service through Camel using dataFormat as POJO
附:如果你不需要某些原因,为了显式编组/解组JAXB POJO,你不需要其他任何东西。您不关心SOAP等。CXF将从您的WSDL定义中为您完成。
非常感谢Vadim! – Anirban
为什么“dataFormat是MESSAGE”用于SOAP?也许POJO或PAYLOAD可以是更好的选择?对于CXF Endpoint for SOAP,还必须有一个WSDL,您无需担心自己创建完整的SOAP。 CXF会照顾它。但是如果你仍然需要创建完整的SOAP Envelope,那么你可以使用XQuery,XSLT,DOM生成器...有很多选择,但是所有这些选择越来越慢,POJO使用JAXB – Vadim
其实我有一个WSDL太大从它创建POJO类。由于这个原因,我无法使用dataFormat POJO。另外我需要添加SOAP头,但dataFormat PAYLOAD只处理消息正文(很可能)。所以dataFormat MESSAGE是唯一的选择。但使用dataFormat我找到示例来读取传入的SOAP消息,但不创建SOAP消息。这方面的任何例子都非常有用。 – Anirban
你会走错方向。你的假设都不正确。这不是一个“大WSDL”的例子。你必须使用它。自定义SOAP创建是一个坏主意。使用PAYLOAD POJO格式,您可以创建标题或创建需要的标题。我仍然推荐POJO,并专注于您的实际功能,而不是花费大量时间重新发明。所有已经存在的:CXF,CAMEL,JAXB正是为了做你所需要的,正确,快速,优化的。 – Vadim