JAX-WS multiple endpoints in sun-jaxws.xml

前端 未结 2 1421
太阳男子
太阳男子 2021-01-05 17:19

Just started using JAX-WS. I created 2 test web services in the one WAR file as follows....

package com.djs;

import javax.jws.WebService;

@WebService()
pub         


        
相关标签:
2条回答
  • 2021-01-05 17:35

    You want the web.xml to reference only one servlet, at urlMapping /:

      <servlet>
        <servlet-name>services</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>services</servlet-name>
        <url-pattern>/</url-pattern>
      </servlet-mapping>
    

    Then, include multiple endpoints at the full desired path in sun-jaxws.xml:

    <endpoint name='performAdd' implementation='com.djs.AddTwoInts' url-pattern='/AddTwoInts' />
    <endpoint name='sayHello' implementation='com.djs.SayHello' url-pattern='/couldhavemore/SayHello' />
    

    Note the "couldhavemore" in there... you can add to the relevant path in the sun-jaxws.xml file to get the full desired path. I've gotten a single service to work with a web.xml entry of something other than /, but then you need a web.xml entry for every service. It seems to get multiple to work you need to use / and then put the full path in sun-jaxws.xml.

    0 讨论(0)
  • 2021-01-05 17:49

    Dave,

    I guess you are missing the servlet-mapping for the two end points you have.

    Add the following to your web.xml and try again. Let me know if this solve the problem.

    <servlet>
        <servlet-name>AddTwoInts</servlet-name>
        <servlet-class>com.sun.xml.ws.transport.http.servlet.WSServlet</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>AddTwoInts</servlet-name>
        <url-pattern>/AddTwoInts</url-pattern>
    </servlet-mapping>
    
    <servlet>
        <servlet-name>SayHello</servlet-name>
        <servlet-class>com.sun.xml.ws.transport.http.servlet.WSServlet</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>SayHello</servlet-name>
        <url-pattern>/SayHello</url-pattern>
    </servlet-mapping>
    
    0 讨论(0)
提交回复
热议问题