sun-jaxws.xml中的JAX-WS多个端点 [英] JAX-WS multiple endpoints in sun-jaxws.xml

查看:130
本文介绍了sun-jaxws.xml中的JAX-WS多个端点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

刚开始使用JAX-WS.我在一个WAR文件中创建了2个测试Web服务,如下所示....

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()
public class AddTwoInts {

    public int performAdd(int firstNum, int secondNum) {
        return firstNum + secondNum;
    }
}

还有.....

package com.djs;

import javax.jws.WebService;

@WebService()
public class SayHello {

    public String sayHello(String inwards) {
        return "Hello " + inwards;
    }
}

这是我的web.xml

This is my web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee 
                             http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4">

    <listener>
        <listener-class>
            com.sun.xml.ws.transport.http.servlet.WSServletContextListener
        </listener-class>
    </listener>

    <servlet>
        <servlet-name>jaxws</servlet-name>
        <servlet-class>com.sun.xml.ws.transport.http.servlet.WSServlet</servlet-class>
    </servlet>

    <servlet-mapping>
        <servlet-name>jaxws</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>

</web-app>

这是sun-jaxws.xml

This is the sun-jaxws.xml

<?xml version="1.0" encoding="UTF-8"?>
<endpoints xmlns='http://java.sun.com/xml/ns/jax-ws/ri/runtime' version='2.0'>  
    <endpoint name='performAdd' implementation='com.djs.AddTwoInts' url-pattern='/AddTwoInts' />
    <endpoint name='sayHello' implementation='com.djs.SayHello' url-pattern='/SayHello' />
</endpoints> 


我部署到Tomcat 7中,并使用http://localhost:8080/MyApp/AddTwoInts?wsdl来获取AddTwoInts的WSDL.....但是当我执行http://localhost:8080/MyApp/SayHello?wsdl时,我得到了一个404页面未找到错误....


I deploy into Tomcat 7 and use http://localhost:8080/MyApp/AddTwoInts?wsdl to get the WSDL for AddTwoInts OK.... But when I execute http://localhost:8080/MyApp/SayHello?wsdl I get a 404 page not found error....

任何建议表示赞赏.

推荐答案

戴夫,

我想您缺少两个端点的servlet映射.

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

将以下内容添加到您的web.xml中,然后重试.让我知道这是否可以解决问题.

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>

这篇关于sun-jaxws.xml中的JAX-WS多个端点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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