16.5. Spring으로 CXF 엔드 포인트를 구성
아래 표시된 Spring 구성 파일을 사용하여 CXF 엔드 포인트를 구성할 수 있으며, endpoint를 camelContext 태그에 포함할 수도 있습니다. 서비스 끝점을 호출할 때 operationName 및 operationNamespace 헤더를 명시적으로 설정하여 호출하는 작업을 명시적으로 표시할 수 있습니다.
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:cxf="http://camel.apache.org/schema/cxf"
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">
<cxf:cxfEndpoint id="routerEndpoint" address="http://localhost:9003/CamelContext/RouterPort"
serviceClass="org.apache.hello_world_soap_http.GreeterImpl"/>
<cxf:cxfEndpoint id="serviceEndpoint" address="http://localhost:9000/SoapContext/SoapPort"
wsdlURL="testutils/hello_world.wsdl"
serviceClass="org.apache.hello_world_soap_http.Greeter"
endpointName="s:SoapPort"
serviceName="s:SOAPService"
xmlns:s="http://apache.org/hello_world_soap_http" />
<camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
<route>
<from uri="cxf:bean:routerEndpoint" />
<to uri="cxf:bean:serviceEndpoint" />
</route>
</camelContext>
</beans>
루트 빈 요소에 지정된>-<-WS schemaLocation 속성을 포함해야 합니다. 이를 통해 CXF는 파일의 유효성을 검증할 수 있으며 필수입니다. 또한 < cxf:cxfEndpoint/ > 태그 끝에 네임스페이스 선언도 기록해 둡니다. 결합된 {namespace}localName 구문이 현재 이 태그의 속성 값에 대해 지원되지 않기 때문에 이러한 선언이 필요합니다.
cxf:cxfEndpoint 요소는 많은 추가 특성을 지원합니다.
| 이름 | 현재의 |
|---|---|
|
|
이 서비스가 구현되고 있는 엔드포인트 이름은 |
|
|
이 서비스가 구현하는 서비스 이름은 |
|
| WSDL의 위치입니다. classpath, 파일 시스템에 있거나 원격으로 호스팅될 수 있습니다. |
|
|
사용할 서비스 모델의 |
|
| 서비스 게시 주소입니다. |
|
| GDB-WS 엔드포인트에서 사용할 버스 이름입니다. |
|
| SEI(Service Endpoint Interface) 클래스의 클래스 이름입니다. 이 클래스에는 주석이 있거나 주석이 없을 수 있습니다. |
또한 여러 자식 요소를 지원합니다.
| 이름 | 현재의 |
|---|---|
|
|
이 끝점에 대해 들어오는 인터셉터입니다. <ECDHE& |
|
|
이 엔드포인트에 대해 들어오는 오류 인터셉터입니다. <ECDHE& |
|
|
이 끝점에 대한 발신 인터셉터입니다. <ECDHE& |
|
|
이 엔드포인트에 대한 발신 오류 인터셉터입니다. <ECDHE& |
|
| CloudEvent-WS 엔드포인트에 제공해야 하는 속성 맵입니다. 아래를 참조하십시오. |
|
| 192.0.2.-WS 엔드포인트에 제공해야 하는 handler 목록입니다. 아래를 참조하십시오. |
|
|
끝점에서 사용할 |
|
|
이 끝점에서 사용할 |
|
| 이 끝점의 인터셉터를 보유하는 기능입니다. 빈 또는 ref 목록 |
|
| 사용할 끝점의 스키마 위치입니다. schemaLocations 목록 |
|
|
이 끝점에서 사용할 서비스 팩토리입니다. Spring <ovn |
CXFECDHE -WS 구성 페이지에서 인터셉터, 속성 및 처리기를 제공하는 방법을 보여주는 고급 예제를 찾을 수 있습니다.
cxf:properties를 사용하여 spring 구성 파일에서 camel-cxf 끝점의 dataFormat 및 setDefaultBus 속성을 설정할 수 있습니다.
<cxf:cxfEndpoint id="testEndpoint" address="http://localhost:9000/router"
serviceClass="org.apache.camel.component.cxf.HelloService"
endpointName="s:PortName"
serviceName="s:ServiceName"
xmlns:s="http://www.example.com/test">
<cxf:properties>
<entry key="dataFormat" value="RAW"/>
<entry key="setDefaultBus" value="true"/>
</cxf:properties>
</cxf:cxfEndpoint>
SpringBoot에서는 Spring XML 파일을 사용하여 camel-cxf 를 구성하고 다음 예제와 유사한 코드를 사용하여 XML 구성 빈을 생성할 수 있습니다.
@ImportResource({
"classpath:spring-configuration.xml"
})
그러나 구성된 Java 코드(다른 예와 같이) 구성된 빈을 사용하는 것이 SpringBoot에서 가장 좋습니다.