[英]WebService works with Jetty but not with Tomcat
I am banging my head against a wall at the moment. 此刻,我的头撞在墙上。 I did some development to create a WebService using CXF and Spring. 我做了一些开发,以使用CXF和Spring创建一个WebService。 It all worked fine with Jetty 8, but when I try and run it with Tomcat 6 I can't even get the WSDL from the request. 在Jetty 8上一切正常,但是当我尝试在Tomcat 6上运行它时,我什至无法从请求中获得WSDL。 Below are the details: 以下是详细信息:
My webservice interface: 我的网络服务界面:
@WebService(name="AlertService")
public interface AlertWebService {
@WebMethod
HandleAlertResponse openHandleAlert(@WebParam(name = "request") HandleAlertRequest request) throws ServiceException;
}
My webservice impl: 我的网络服务暗示:
@WebService(endpointInterface = "c.h.g.p.service.ws.alert.AlertWebService", serviceName = "AlertService")
public class AlertWebServiceImpl implements AlertWebService {
@Override
public HandleAlertResponse openHandleAlert(HandleAlertRequest request) throws ServiceException {
//Do some stuff
}
My web.xml: 我的web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app ...>
<display-name>Prime Service Webapp</display-name>
<listener>
<listener-class> org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<servlet>
<servlet-name>CXFServlet</servlet-name>
<servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>CXFServlet</servlet-name>
<url-pattern>/prime-service-webapp/*</url-pattern>
</servlet-mapping>
</web-app>
Endpoint definition 端点定义
<import resource="classpath:META-INF/cxf/cxf.xml" />
<import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
<import resource="classpath:META-INF/cxf/cxf-servlet.xml" />
<bean id="alertWebService" class="c.h.g.p.service.ws.alert.AlertWebServiceImpl" />
<jaxws:endpoint implementor="#alertWebService" address="/AlertService" />
URL that I hit which gives me 404 error 我命中的网址给我404错误
http://localhost:8090/prime-service-webapp/AlertService?wsdl
I have changed my tomcat config to look at port 8090. I just drop my war called prime-service-webapp into webapps directory of tomcat. 我已经更改了tomcat的配置以查看端口8090。我只是将名为prime-service-webapp的战争放到了tomcat的webapps目录中。 Adding an index.html file into the prime-service-webapp directory also seems to resolve ok. 将index.html文件添加到prime-service-webapp目录中似乎也可以解决。 But I can't get the wsdl at all. 但是我根本无法获得wsdl。
Any ideas - let me know. 任何想法-让我知道。 Is there anything in specific to tomcat 6 server config I need to change to get this working? 我需要更改特定于tomcat 6服务器配置的任何东西才能使它正常工作吗?
I admit i know nothing about jetty, but in tomcat, the way you put it, you need to use this URL: 我承认我对码头一无所知,但是在tomcat中,按照您所说的方式,您需要使用以下URL:
http://localhost:8090/prime-service-webapp/prime-service-webapp/AlertService?wsdl
Have a try with that. 试试看。 The reason is tomcat assigns the war name as context root by default, and you have instructed your cxf servlet to listen to 原因是tomcat默认将war名称分配为上下文根,并且您已指示cxf servlet监听
<url-pattern>/prime-service-webapp/*</url-pattern>
which means another level under context root (even if it is the same) 这意味着上下文根目录下的另一个级别(即使相同)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.