Apache CXF and servlet-mapping

匿名 (未验证) 提交于 2019-12-03 10:24:21

问题:

I am trying to learn some basics of Apache CXF and generally about servlet-mappings. and I have modified the code here:

https://subversion.assembla.com/svn/pablo-examples/spring-cxf-example

I have configured CXFServlet mapping as below in web.xml

<servlet-mapping>     <servlet-name>CXFServlet</servlet-name>     <url-pattern>/services/*</url-pattern> </servlet-mapping> 

in the spring xml(webservice-definition-beans.xml) I have generated the service as below

<jaxws:endpoint id="helloWorld" implementor="#helloWorldService" address="/services/HelloWorld" /> 

I was expecting to access to the service wsdl via this url

http://localhost:8080/services/HelloWorld?wsdl 

but it is

http://localhost:8080/services/services/HelloWorld?wsdl 

Do I know something wrong here ?

Does not servlet-mapping only show which url pattern maps to which servlet to process ?

In here It seems it also changes context.

回答1:

The JAX-WS path is relative to servlet mapping. If you want

http://localhost:8080/services/HelloWorld?wsdl 

use either

<servlet-mapping>     <servlet-name>CXFServlet</servlet-name>     <url-pattern>/*</url-pattern> </servlet-mapping>  <jaxws:endpoint id="helloWorld" implementor="#helloWorldService" address="/services/HelloWorld" /> 

or

<servlet-mapping>     <servlet-name>CXFServlet</servlet-name>     <url-pattern>/services/*</url-pattern> </servlet-mapping>  <jaxws:endpoint id="helloWorld" implementor="#helloWorldService" address="/HelloWorld" /> 


标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!