Java Spring CXF Webservice 未正确部署
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21079103/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Spring CXF Webservice doesn't get deployed correctly
提问by actc
this is the situation: we have a Spring-MVC application that should now provide a contract-first SOAP webservice. After looking at a CXF example (wsdl_first), I finally managed to get this far:
情况是这样的:我们有一个 Spring-MVC 应用程序,它现在应该提供一个契约优先的 SOAP 网络服务。在查看了 CXF 示例 (wsdl_first) 后,我终于做到了这一点:
I generated the skeleton classes and also implemented the service interface.
我生成了骨架类并实现了服务接口。
Tomcat 7 seems to deploy something:
Tomcat 7 似乎部署了一些东西:
12 Jan 2014 19:32:08,386 INFO org.apache.cxf.service.factory.ReflectionServiceFactoryBean:411 - Creating Service {urn:webservice.x.com:wsdl}IdmAdapterService from WSDL: classpath:IdmAdapterService.wsdl
I created a second servlet which should handle the webservice calls. WEB-INF/web.xml contains:
我创建了第二个 servlet 来处理 webservice 调用。WEB-INF/web.xml 包含:
<servlet>
<servlet-name>webservices</servlet-name>
<servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>webservices</servlet-name>
<url-pattern>/services/*</url-pattern>
</servlet-mapping>
WEB-INF/cxf-servlet.xml contains:
WEB-INF/cxf-servlet.xml 包含:
<jaxws:endpoint xmlns:tns="urn:webservice.x.com:wsdl"
id="idmAdapterImpl" address="/services/IdmAdapterService"
serviceName="tns:IdmAdapterService" endpointName="tns:IdmAdapterSoapPort"
implementor="de.y.idm.IdmAdapterImpl"
/>
src/main/resources/cxf.xml contains:
src/main/resources/cxf.xml 包含:
<jaxws:endpoint name="{urn:webservice.x.com:wsdl}:IdmAdapterSoapPort"
wsdlLocation="IdmAdapterService.wsdl">
<jaxws:properties>
<entry key="schema-validation-enabled" value="true" />
</jaxws:properties>
</jaxws:endpoint>
src/main/resources/server-applicationContext.xml contains:
src/main/resources/server-applicationContext.xml 包含:
<!-- HTTP Endpoint -->
<jaxws:endpoint xmlns:tns="urn:webservice.x.com:wsdl"
id="idmAdapterImpl"
address="/services/IdmAdapterService"
serviceName="tns:IdmAdapterService"
endpointName="tns:IdmAdapterSoapPort"
implementor="de.y.idm.IdmAdapterImpl">
<jaxws:features>
<bean class="org.apache.cxf.feature.LoggingFeature" />
</jaxws:features>
</jaxws:endpoint>
When I call the URL
当我调用 URL 时
http://localhost:8080/application/services/IdmAdaptorService?wsdl
I always end up with
我总是以
No service was found.
and on the console
并在控制台上
12 Jan 2014 19:51:53,731 DEBUG org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter:136 - Opening JPA EntityManager in OpenEntityManagerInViewFilter
12 Jan 2014 19:51:53,732 DEBUG org.springframework.security.util.FilterChainProxy:205 - Converted URL to lowercase, from: '/services/idmadapterservice'; to: '/services/idmadapterservice'
12 Jan 2014 19:51:53,732 DEBUG org.springframework.security.util.FilterChainProxy:212 - Candidate is: '/services/idmadapterservice'; pattern is /services/**; matched=true
12 Jan 2014 19:51:53,733 DEBUG org.springframework.security.util.FilterChainProxy:165 - has an empty filter list
12 Jan 2014 19:51:53,733 WARN org.apache.cxf.transport.servlet.ServletController:175 - Can't find the the request for http://localhost:8080/application/services/IdmAdapterService's Observer
12 Jan 2014 19:51:53,734 DEBUG org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter:154 - Closing JPA EntityManager in OpenEntityManagerInViewFilter
12 Jan 2014 19:51:53,734 DEBUG org.springframework.orm.jpa.EntityManagerFactoryUtils:338 - Closing JPA EntityManager
What am I missing, what might be the problem?
我错过了什么,可能是什么问题?
Thanks in advance.
提前致谢。
采纳答案by Biju Kunjummen
the /services/IdmAdapterService
in server-applicationContext.xml
is relative to the servlet-mapping of CXFServlet
which is /services/*
. So your actual path of the service should be:
的/services/IdmAdapterService
在server-applicationContext.xml
相对于该Servlet映射的CXFServlet
是/services/*
。所以你的服务的实际路径应该是:
http://localhost:8080/application/services/services/IdmAdapterService
http://localhost:8080/application/services/services/IdmAdapterService