311.4. Java DSL 사용
다음 예제에서는 com.example.customerservice 패키지로 구성된 DataFormat of soap 을 사용하여 JAXBContext 를 초기화합니다. 두 번째 매개변수는 ElementNameStrategy입니다. 경로는 일반 오브젝트와 예외를 마샬링할 수 있습니다. (아래에서 SOAP Envelope를 대기열로 보냅니다. 웹 서비스 공급자는 실제로 SOAP 호출이 발생하기 위해 큐를 수신 대기해야 합니다. 이 경우 SOAP 요청의 한 가지 방법이 됩니다. 요청 응답이 필요한 경우 다음 예제를 살펴봐야 합니다.)
SoapJaxbDataFormat soap = new SoapJaxbDataFormat("com.example.customerservice", new ServiceInterfaceStrategy(CustomerService.class));
from("direct:start")
.marshal(soap)
.to("jms:myQueue");작은 정보
또한 SOAP dataformat에서 JAXB 데이터 형식을 상속하기 때문에 대부분의 설정도 여기에도 적용됨을 참조하십시오.
311.4.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을 사용할 때 version 속성이 있으면 <soapjaxb> 요소에 설정할 수 있습니다.
<!-- 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>