您的位置:首页 > 编程语言 > Java开发

jdk自带发布webservice服务

2014-10-09 14:00 281 查看
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
看到下面文件即成功发布:





                                            
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: