64.3. Java DSL を使用
次の例では、com.example.customerservice パッケージで設定された soap の名前付き DataFormat を使用して JAXBContext を初期化します。2 番目のパラメーターは ElementNameStrategy です。ルートは通常のオブジェクトと例外をマーシャリングできます。(以下は SOAP Envelope をキューに送信するだけです。Web サービスプロバイダーは、実際には SOAP 呼び出しのためにキューをリッスンする必要があります。この場合は、SOAP リクエストになります。リクエスト応答が必要な場合は、次の例を確認してください。)
SoapJaxbDataFormat soap = new SoapJaxbDataFormat("com.example.customerservice", new ServiceInterfaceStrategy(CustomerService.class));
from("direct:start")
.marshal(soap)
.to("jms:myQueue");
また、
を 参照してください。SOAP データ形式は、JAXB データフォーマットから継承するもので、ほとんどの設定はここでも適用されます。
64.3.1. SOAP 1.2 の使用 リンクのコピーリンクがクリップボードにコピーされました!
Camel 2.11 以降
SoapJaxbDataFormat soap = new SoapJaxbDataFormat("com.example.customerservice", new ServiceInterfaceStrategy(CustomerService.class));
soap.setVersion("1.2");
from("direct:start")
.marshal(soap)
.to("jms:myQueue");
XML DSL を使用する場合は、<soapjaxb> 要素に設定できる version 属性があります。
<!-- Defining a ServiceInterfaceStrategy for retrieving the element name when marshalling -->
<bean id="myNameStrategy" class="org.apache.camel.dataformat.soap.name.ServiceInterfaceStrategy">
<constructor-arg value="com.example.customerservice.CustomerService"/>
<constructor-arg value="true"/>
</bean>
Camel ルートで および
<route>
<from uri="direct:start"/>
<marshal>
<soapjaxb contentPath="com.example.customerservice" version="1.2" elementNameStrategyRef="myNameStrategy"/>
</marshal>
<to uri="jms:myQueue"/>
</route>