CXF生成的Web服务的切入点是什么? [英] What is the entry point in a CXF generated web service?

查看:231
本文介绍了CXF生成的Web服务的切入点是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用契约优先方法,我使用CXF从WSDL生成Web服务。

Using a contract-first approach, I generated a web service from a WSDL, using CXF.

Tomcat 7加载Web服务并正确响应SOAP消息。

The web service loads fine by Tomcat 7 and responds properly to SOAP messages.

但是当我理解WSDL和XSD中自动生成的Java类时,我不确定我知道入口点在哪里(所以我可以< a href =http://blog.bdoughan.com/2010/12/jaxb-and-marshalunmarshal-schema.html\"rel =nofollow noreferrer>启用验证,例如)。

But while I understand the auto-generated Java classes from the WSDL and XSD, I am not sure I know where the entry point is (so that I can enable validation, for example).

由于熟悉的main()方法只是一个默认入口点,并且不是强制性的,我假设CXF为此目的使用了不同的入口点。

Since the familiar main() method is only a default entry point and is not mandatory, I am assuming that CXF uses a different entry point for that purpose.

当我构建Web服务时(使用包含CXF插件的pom.xml) ,只生成2个包(足以建立工作 Web服务):

When I build the web service (using a pom.xml that contains the CXF plugin), only 2 packages are generated (sufficient for establishing a working web service):


  1. 一个用于WSDL本身,仅包含3个Java模块:ObjectFactor y.java,MyBinding.java,MyService.java

  2. 第二个用于XSD架构,包含架构中定义的每种类型的Java类。

我怀疑扩展名为 Service 的类的MyService.java是我应该寻找的地方对于那个入口点。但是它是如何神奇的?

I am suspecting that MyService.java, which extends a class named Service is where I should be looking for that entry point. But how does it do "the magic"?

BTW,我试过从Tomcat控制台搞清楚这一点,但这就是所有的网络服务启动时记录:

BTW, I tried figuring this out from the Tomcat console, but that's all the web service logs upon startup:

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.springframework.beans.factory.support.DefaultListableBeanFactory@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似乎很好地隐藏了实现细节,但我想知道在哪里挂钩我的初始化定制。

CXF seems to be hiding the implementation details very well, but I would like to know where to hook my initialization customization.

推荐答案

CXFServlet通常是您服务的切入点。 Tomcat将HTTP请求路由到您的webapp,servlet-mapping定义接收请求的Servlet。如果你想在它到达CXF之前拦截请求,你可以编写一个Servlet 过滤

CXFServlet is generally the entry point for your service. Tomcat routes the HTTP request to your webapp, and the servlet-mapping defines the Servlet that receives the request. If you want to intercept the request before it reaches CXF, you could write a Servlet Filter.

对于简单的验证需求,CXF确实支持通过配置进行架构验证

For simple validation needs, CXF does support schema validation via configuration.

如果您希望在邮件到达您的服务之前对邮件做更好的事情,并从中获益CXF的功能,我建议熟悉CXF拦截器。它们非常强大,可以在到达服务之前在任何阶段拦截消息,并在它退出服务之后。 CXF文档有有关编写拦截器的阶段和说明的详细信息

If you want to do fancier things to a message before it reaches your service, and benefit from the functionality of CXF, I would recommend becoming familiar with CXF Interceptors. They are very powerful, and can intercept a message at any number of phases before it reaches the service, and after it exits the service. The CXF documentation has details on the phases and instructions on writing an Interceptor.

这篇关于CXF生成的Web服务的切入点是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆