views:

597

answers:

1

Hi,

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"&gt;
    <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

+2  A: 

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"&gt;
  <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/&lt;mycontext&gt;/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.
Pascal Thivent
Hmm... didn't know about this. Sry I'm still a student. I'll have a look into installing Metro on Tomcat. Thanks for the insight!Regards,Krt_Malta
Krt_Malta
@Krt_Malta No problem. I've added some pointers explaining how to do that (assuming you're using Tomcat 6.x, which would be my recommendation).
Pascal Thivent
Hmm...no luck. I installed metro as per http://blogs.sun.com/arungupta/entry/metro_on_tomcat_6_x, restarted Tomcat (which is Tomcat 6.0.24) and re-copied the war file again, but I'm till getting a 404 error when trying to access the wsdl file. Any ideas please? 10x. Krt_Malta
Krt_Malta
@Krt_Malta Then your web service is very likely not deployed. Can you show your `web.xml` and your `sun-jaxws.xml`?
Pascal Thivent
Thanks a lot! It worked :) Thanks for all the patience, much appreciated. Regards, Krt_Malta
Krt_Malta