Spring CXF Webservice无法正确部署

时间:2014-01-12 19:18:32

标签: java spring web-services wsdl cxf

情况就是这样:我们有一个Spring-MVC应用程序,现在应该提供契约优先的SOAP Web服务。在查看了一个CXF示例(wsdl_first)后,我终于成功了:

我生成了骨架类,并且还实现了服务接口。

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

我创建了第二个应该处理webservice调用的servlet。 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包含:

<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包含:

<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包含:

<!-- 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>

当我调用网址

 http://localhost:8080/application/services/IdmAdaptorService?wsdl

我总是以

结束
 No service was found.

并在控制台上

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

我错过了什么,可能是什么问题?

提前致谢。

1 个答案:

答案 0 :(得分:7)

/services/IdmAdapterService中的server-applicationContext.xmlCXFServlet的{​​{1}}的servlet映射相关,即/services/*。所以你的实际服务路径应该是:

http://localhost:8080/application/services/services/IdmAdapterService