2013-10-04 2 views
0

계약 우선 접근 방식을 사용하여 CXF를 사용하여 WSDL에서 웹 서비스를 생성했습니다.CXF 생성 웹 서비스의 진입 점은 무엇입니까?

웹 서비스가 Tomcat 7에서 제대로로드되고 SOAP 메시지에 올바르게 응답합니다.

그러나 WSDL 및 XSD에서 자동 생성 된 Java 클래스를 이해하는 동안 엔트리 포인트가 어디인지 알 수 없습니다 (예 : enable validation).

익숙한 main() 메소드는 기본 엔트리 포인트이고 not mandatory이므로, CXF는 그 목적을 위해 다른 진입 점을 사용한다고 가정합니다. WSDL에 대한

  1. 하나 : I합니다 (CXF 플러그인을 포함하는 pom.xml 파일을 사용하여) 웹 서비스를 빌드 할 때

    는 만 2 패키지 (A 작업 웹 서비스를 구축하기위한 충분한) 발생 그 자체는 3 개의 Java 모듈 만 포함합니다. ObjectFactory.java, MyBinding.java, MyService.java

  2. 두 번째는 스키마에 정의 된 모든 유형의 Java 클래스를 포함하는 XSD 스키마입니다.

Service이라는 클래스를 확장하는 MyService.java가 해당 진입 점을 찾고 있어야한다고 생각합니다. 그러나 "마술"은 어떻게합니까?

BTW, 나는 톰캣 콘솔에서이 문제를 파악했지만, 그 시작시 모든 웹 서비스 로그입니다 :

Oct 4, 2013 11:27:47 AM org.springframework.web.context.ContextLoader initWebApplicationContext 
INFO: Root WebApplicationContext: initialization started 

Oct 4, 2013 11:27:47 AM org.springframework.context.support.AbstractApplicationContext prepareRefresh 
INFO: Refreshing Root WebApplicationContext: startup date [Fri Oct 04 11:27:47 EDT 2013]; root of context hierarchy 

Oct 4, 2013 11:27:47 AM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions 
INFO: Loading XML bean definitions from class path resource [beans.xml] 

Oct 4, 2013 11:27:47 AM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions 
INFO: Loading XML bean definitions from class path resource [META-INF/cxf/cxf.xml] 

Oct 4, 2013 11:27:47 AM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions 
INFO: Loading XML bean definitions from class path resource [META-INF/cxf/cxf-extension-soap.xml] 

Oct 4, 2013 11:27:47 AM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions 
INFO: Loading XML bean definitions from class path resource [META-INF/cxf/cxf-servlet.xml] 

Oct 4, 2013 11:27:47 AM org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons 
INFO: Pre-instantiating singletons in org.s[email protected]17392df: defining beans [org.springframework.context. 
annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.anno 
tation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,cxf,org.apache.cxf.bus.spring.BusWiringBeanF 
actoryPostProcessor,org.apache.cxf.bus.spring.Jsr250BeanPostProcessor,org.apache.cxf.bus.spring.BusExtensionPostProcessor,org.apache.cxf.binding.soap.SoapBindin 
gFactory,org.apache.cxf.binding.soap.SoapTransportFactory,org.apache.cxf.binding.soap.customEditorConfigurer,myserviceWS,myserviceBinding]; root of factor 
y hierarchy 

Oct 4, 2013 11:27:47 AM org.apache.cxf.service.factory.ReflectionServiceFactoryBean buildServiceFromWSDL 
INFO: Creating Service {http://myws.example.com/ns}MyService from WSDL: file:/C:/Users/Daniel/myws/src/main/wsdl/myws.wsdl 

Oct 4, 2013 11:27:48 AM org.apache.cxf.endpoint.ServerImpl initDestination 
INFO: Setting the server's publish address to be /myservice/soap 

Oct 4, 2013 11:27:48 AM org.springframework.web.context.ContextLoader initWebApplicationContext 
INFO: Root WebApplicationContext: initialization completed in 1107 ms 

CXF 아주 잘 구현 세부 사항을 숨기는 것 같다,하지만 난 싶습니다 내 초기화 사용자 정의를 연결할 위치를 알아야합니다.

답변

2

일반적으로 CXFServlet은 서비스의 시작점입니다. Tomcat은 HTTP 요청을 웹 애플리케이션으로 라우트하고 서블릿 맵핑은 요청을 수신하는 Servlet을 정의합니다. CXF에 도달하기 전에 요청을 가로 채고 싶다면 서블릿 Filter을 작성할 수 있습니다.

간단한 검증이 필요한 경우 CXF는 schema validation via configuration을 지원합니다.

서비스에 도달하기 전에 메시지에 멋진 것들을하고 CXF의 기능을 활용하려면 CXF 인터셉터에 익숙해지는 것이 좋습니다. 그것들은 매우 강력하며 서비스에 도달하기 전에 그리고 서비스를 종료 한 후에 여러 단계에서 메시지를 가로 챌 수 있습니다. CXF 설명서는 details on the phases and instructions on writing an Interceptor입니다.

+0

우수하고 교육적인 답변 주셔서 감사합니다. 설정 *을 통한 * 스키마 유효성 검사에 관해서는, 웹 서비스에 의해 수행되는 검증을 이미 볼 수 있기 때문에, 이것이 기본적으로 켜져 있다고 가정하고 있으므로 가 필요하지 않을 수도 있습니다. 내가 맞습니까? 그러나 유효성 검사는 스키마에 지정된 모든 규칙을 다루지 않으므로 [cxf.xml] (http://cxf.apache.org/docs/configuration.html)이 필요하다고 생각됩니다. 나는 올바른 방향으로 나아가고 있는가? – Withheld

+0

OK, (구성 *를 통한 스키마 유효성 검사와 관련하여) : cxf.xml에 대한 참조가 실제로 혼란 스러웠다. 어쨌든 반드시 존재해야하는 "응용 프로그램 컨텍스트"XML이었고 ** 아무거나 **라는 이름을 붙일 수 있습니다.xml' 그리고 스키마 유효성 검증을 가능하게하기 위해서해야 할 일은''를 이미 정의 된 ' Withheld

관련 문제