[英]Creating SOAP message in Apache Camel when dataFormat is MESSAGE or CXF_MESSAGE
I want to call a Web Service through Apache Camel and the dataFormat is MESSAGE. 我想通过Apache Camel调用Web服务,dataFormat是MESSAGE。 I want to construct the below SOAP 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>
Can anyoneone help me with some code snippet or example which shows how to create this SOAP message? 任何人都可以帮我一些代码片段或示例来说明如何创建这个SOAP消息吗?
I can provide you some idea about how to use CXF POJO format with Spring DSL. 我可以为您提供有关如何在Spring DSL中使用CXF POJO格式的一些想法。
Spring Context may look like: 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" />
...
It is simple: 很简单:
In Spring you define cxf endpoint as {http://camel.apache.org/schema/cxf}cxfEndpoint
bean, 在Spring中,您将cxf端点定义为{http://camel.apache.org/schema/cxf}cxfEndpoint
bean,
then your reference to it from Camel route from
or to
components by uri which looks like: uri="cxf:bean:{endpoint bean id}"
那么你的参考,将其从骆驼航线from
或to
由URI组件,它看起来像: uri="cxf:bean:{endpoint bean id}"
Then You may have two cases: Case 1. WSDL has Header defined as part of the message. 然后您可能有两种情况:情况1. WSDL将Header定义为消息的一部分。 After service generated by Maven CXF plugin: 由Maven CXF插件生成的服务之后:
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
Just check how Service Interface looks like. 只需检查Service Interface的外观。
Case 2: WSDL does not have Custom Header defined and you need to add it. 情况2:WSDL没有定义自定义标头,您需要添加它。
for both look at my answer to another question: Unable to set SOAP Header while calling Web Service through Camel using dataFormat as POJO 看看我对另一个问题的回答: 无法在使用dataFormat作为POJO通过Camel调用Web Service时设置SOAP Header
PS if you do not need for some reasons, to explicitly marshal/unmarshal JAXB POJOs, you do not need anything else. PS如果由于某些原因不需要,明确编组/解组JAXB POJO,则不需要任何其他内容。 You do not care about SOAP, etc. CXF will do it for you from your WSDL definition. 您不关心SOAP等.CXF将从您的WSDL定义中为您完成。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.