我在尝试在我的CXF Web服务端点配置中使用相对发布地址时遇到了很多困难。CXF jaxws端点相对发布地址
我有以下配置文件的简单Java的第一个JAX-WS项目:
applicationContent-cxf.xml:
<beans xmlns=...>
...
<jaxws:endpoint
id="helloWorldService"
implementorClass="org.helloworld.ws.HelloWorldServiceImpl"
implementor="#helloWorldServiceImpl" <!-- spring managed -->
endpointName="sayHello"
address="HelloWorldService"/>
</beans>
的web.xml:
<web-app>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
WEB-INF/applicationContext.xml
WEB-INF/applicationContext-cxf.xml
</param-value>
</context-param>
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<servlet>
<servlet-name>HelloWorldServlet</servlet-name>
<display-name>Hello World Servlet</display-name>
<servlet-class>
org.apache.cxf.transport.servlet.CXFServlet
</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>HelloWorldServlet</servlet-name>
<url-pattern>/services/*</url-pattern>
</servlet-mapping>
</web-app>
根据到http://cxf.apache.org/docs/servlet-transport.html,似乎我应该能够指定发布地址HelloWorldService
,服务的URL将解析为(例如)http://localhost:8080/services/HelloWorldService。但是当我尝试去http://localhost:8080/services/HelloWorldService?wsdl时,我得到了404。如果我将我的jaxws端点中的发布地址更改为绝对URL http://localhost:8080/services/HelloWorldService
,我可以访问wsdl。
如果可能,我想指定一个相对的端点地址。我是使用CXF(和编写Web服务)的新手,因此非常感谢任何帮助!
更新1:
请注意,我部署我的web服务到Tomcat 7。我不知道什么是记录,但在我开始了日志指出Setting the server's publish address to be HelloWorldService
的线路之一。如果有人需要更多信息来帮助我,请告诉我。
更新2:
似乎CXF检测是否一个CXFServlet为“正在使用”,并使用嵌入的码头例如,如果它不是。 http://cxf.apache.org/docs/xfire-migration-guide.html#XFireMigrationGuide-HTTPandServletSetup。所以,由于某些原因,CXF正在使用嵌入式码头实例而不是我的servlet。但是,除了web.xml中的HelloWorldServlet之外,我不知道需要哪些进一步的配置,CXF文档对我没有帮助。
+1在你的桌子上敲打你的头 –
感谢你发布解决方案,我有完全相同的问题,几乎把我的头撞在桌子上:-) – user1339772