首页 > 学院 > 开发设计 > 正文

jdk自带发布webservice服务

2019-11-14 21:17:31
字体:
来源:转载
供稿:网友
jdk自带发布webservice服务

1.创建要发布的类

package com.test.webserive;import javax.jws.WebService;//targetNamespace定义命名空间@WebService(targetNamespace="http://www.mess.com")public class HelloServiceImpl {    public String sayHello(String name){        return "Hello:"+name;    }    public String syaHi(String username){        return "Hi:"+username;    }}

2.发布服务

package com.test.webserive;import javax.xml.ws.Endpoint;public class Service {    public static void main(String[] args){        /**         * 参数1:服务器的发布地址         * 参数2:服务的实现者         */        Endpoint.publish("http://10.90.2.17:6789/hello", new HelloServiceImpl());        System.out.PRintln("Server ready...");    }}

3.启动运行,打开浏览器输入

http://10.90.2.17:6789/hello?wsdl看到下面文件即成功发布:


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表