我正在尝试使用 Tomcat6、CXF 2.2、Spring 3 实现一个简单的 Web 服务提供程序,实际上该服务本身运行良好(我可以使用原始 WSDL 和 SoapUI 调用 Web 方法)。但是,Tomcat 在“?wsdl”请求上返回空白页。另外,当我尝试通过将 publishedEndpointURL
属性添加到 jaxws:endpoint
元素来操作(可能的)已发布的 WSDL 时,Tomcat 将发出 XML 解析异常(某就像元素 jaxws:endpoint 中不允许使用属性publishedEndpointURL
)
<jaxws:endpoint
id="service"
implementor="org.sample.ServiceImpl"
implementorClass="org.sample.ServiceImpl"
address="/service"
publishedEndpointURL="http://localhost:8080/MyService/service">
我使用了“契约第一”的风格。
编辑: 到目前为止我做了什么:
1.使用Spring3安装tomcat6
2.使用maven生成CXF实现类
3.提供web.xml(仅显示相关部分)
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<servlet>
<servlet-name>cxf</servlet-name>
<servlet-class>
org.apache.cxf.transport.servlet.CXFServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>cxf</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
</web-app>
4.提供applicationContext.xml(仅显示相关部分)
<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"/>
<jaxws:endpoint
id="service"
implementor="org.sample.ServiceImpl"
implementorClass="org.sample.ServiceImpl"
address="/service"/>
5.将生成的东西打包到war中并部署
最佳答案
结果我没有看到 WSDL,因为我使用的是 Chrome。在 Firefox 中查看时,它显示了 WSDL。
此外,endpointURL 在更改为 endpointUrl 后也能正常工作(CXF 网站中的文档错误)。
关于java - 如何让Tomcat为其提供的WS发布WSDL(CXF 2.2、Spring 3、Tomcat6),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2649632/