在Tomcat上访问wsdl [英] accessing wsdl on Tomcat

查看:315
本文介绍了在Tomcat上访问wsdl的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Web服务,我正在GlassFish上部署它。我通过 http:// localhost:10697 / APIService / APIServiceService?wsdl 访问了它的wsdl。

现在我将WAR文件移植到Tomcat 6.0.24并进行部署。不过,我正尝试使用 http:// localhost:8080 / APIService / APIServiceService?wsdl 但我得到一个404错误。我尝试了各种组合,但似乎没有工作。



如何访问wsdl文件plz?



感谢和问候,



更新:您在这里: web.xml

 <?xml version =1.0encoding =UTF-8?> 
< web-app version =2.5xmlns =http://java.sun.com/xml/ns/javaeexmlns:xsi =http://www.w3.org/2001/ XMLSchema-instancexsi:schemaLocation =http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd\">
< session-config>
< session-timeout>
30
< / session-timeout>
< / session-config>
< welcome-file-list>
< welcome-file> index.jsp< / welcome-file>
< / welcome-file-list>
< / web-app>

我找不到 sun-jaxws.xml 但是...非常感谢!问候

解决方案

访问WSDL的方式并不是真正的容器特定,它更多的是WS-stack特定的。 GlassFish中的WS-stack是Metro(Metro = JAX-WS RI + WSIT)。您是否在Tomcat上安装/部署Metro或JAX-WS RI?请参阅 Metro on Tomcat 6.x 使用Tomcat 6.x运行JAX-WS示例(对于您的情况,JAX-WS RI可能就足够了)

更新:您需要在中声明 WSServlet code> web.xml (请参阅部署Metro端点):

 <?xml version =1.0encoding =UTF-8?> 
< web-app version =2.5xmlns =http://java.sun.com/xml/ns/javaeexmlns:xsi =http://www.w3.org/2001/ XMLSchema-instancexsi:schemaLocation =http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd\">
< listener>
< listener-class>
com.sun.xml.ws.transport.http.servlet.WSServletContextListener
< / listener-class>
< / listener>
< servlet>
< servlet-name> WebServicePort< / servlet-name>
< servlet-class>
com.sun.xml.ws.transport.http.servlet.WSServlet
< / servlet-class>
1< / load-on-startup>
< / servlet>
< servlet-mapping>
< servlet-name> WebServicePort< / servlet-name>
< url-pattern> / services / *< / url-pattern>
< / servlet-mapping>
< session-config>
< session-timeout> 60< / session-timeout>
< / session-config>
< / web-app>

然后在 sun-jaxws.xml (也包装在WEB-INF中),声明您的服务端点接口(SEI):

 <?xml version = 1.0encoding =UTF-8?> 
< endpoints xmlns =http://java.sun.com/xml/ns/jax-ws/ri/runtimeversion =2.0>
<端点
名称=MyHello
实现=hello.HelloImpl
url-pattern =/ hello
/>
< / endpoints>

您可以在以下位置访问WSDL:

  http:// localhost:8080 /< mycontext> / services / hello?wsdl 
ABCD




  • A是servlet容器的主机和端口。

  • B是war文件的名称。

  • C来自web.xml文件中的url-pattern元素。

  • D来自url-pattern属性的结尾部分sun-jaxws.xml文件。


I have a web service and I was deploying it on GlassFish. I accessed its wsdl through http://localhost:10697/APIService/APIServiceService?wsdl.

Now I ported the WAR file to a Tomcat 6.0.24 and it is deployed. However I am trying to access its wsdl using http://localhost:8080/APIService/APIServiceService?wsdl but I'm getting a 404 error. I tried various combinations but none seem to work.

How can I access the wsdl file plz?

Thanks and regards,

Update: Here you are: web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
    <session-config>
        <session-timeout>
            30
        </session-timeout>
    </session-config>
    <welcome-file-list>
        <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>
</web-app>

I can't find sun-jaxws.xml however... Thanks a lot! Regards

解决方案

The way to access a WSDL is not really container specific, it's more WS-stack specific. The WS-stack in GlassFish is Metro (Metro = JAX-WS RI + WSIT). Did you install/deploy Metro or JAX-WS RI on Tomcat? See Metro on Tomcat 6.x or Running JAX-WS Samples with Tomcat 6.x (JAX-WS RI might be enough in your case) for the steps.

Update: You need to declare the WSServlet in the web.xml (see Deploying Metro endpoint):

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
  <listener>
    <listener-class>
    com.sun.xml.ws.transport.http.servlet.WSServletContextListener
    </listener-class>
  </listener>
  <servlet>
    <servlet-name>WebServicePort</servlet-name>
    <servlet-class>
    com.sun.xml.ws.transport.http.servlet.WSServlet
    </servlet-class>
    <load-on-startup>1</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>WebServicePort</servlet-name>
    <url-pattern>/services/*</url-pattern>
  </servlet-mapping>
  <session-config>
    <session-timeout>60</session-timeout>
  </session-config>
</web-app>

And then in the sun-jaxws.xml (also packaged in WEB-INF), declare your Service Endpoint Interface (SEI):

<?xml version="1.0" encoding="UTF-8"?>
<endpoints xmlns="http://java.sun.com/xml/ns/jax-ws/ri/runtime" version="2.0">
  <endpoint
  name="MyHello"
  implementation="hello.HelloImpl"
  url-pattern="/hello"
  />
</endpoints>

And you access the WSDL at:

http://localhost:8080/<mycontext>/services/hello?wsdl
           A               B         C       D

  • A is the host and port of the servlet container.
  • B is the name of the war file.
  • C comes from the url-pattern element in the web.xml file.
  • D comes from the ending stem of the url-pattern attribute in the sun-jaxws.xml file.

这篇关于在Tomcat上访问wsdl的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆