1.Define the interface

 import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebResult;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import javax.jws.soap.SOAPBinding.Style; @WebService @SOAPBinding(style = Style.RPC)
public interface ISay {
@WebMethod(operationName="HansayHello")
@WebResult(name="myReturn")
public String sayHello(@WebParam(name="name") String name); @WebMethod(operationName="HansayGoodBye")
@WebResult(name="myReturn")
public String sayGoodbye(@WebParam(name="name")String name); @WebMethod(exclude=true)//当前方法不被发布出去
public String sayHello2(@WebParam(name="name")String name);
}

2.Implement the interface

 import javax.jws.WebService;

 /**
* WebService
* 将 Java 类标记为实现 Web Service,或者将 Java 接口标记为定义 Web Service 接口
*/
@WebService(endpointInterface = "com.mobile263.ISay")
public class SayImpl implements ISay { public String sayHello(String name){
System.out.println("sayHello got the request:"+name);
return "hello: " + name;
} public String sayGoodbye(String name){
System.out.println("sayGoodBye got the request:"+name);
return "goodbye: " + name;
} public String sayHello2(String name){
return "hello " + name;
} }

3. Publish the ws in server

 import javax.xml.ws.Endpoint;

 /**
* WebService
* 将 Java 类标记为实现 Web Service,或者将 Java 接口标记为定义 Web Service 接口
*/ public class Wsserver { public static void main(String[] args) {
/**
* 参数1:服务的发布地址
* 参数2:服务的实现者
* Endpoint 会重新启动一个线程
*/
Endpoint.publish("http://localhost:8090/WStest/com.mobile.Wsserver", new SayImpl());
System.out.println("Server ready...");
} }

4. Input the link on brouswer and enter,the wsdl will be shown.   --> http://localhost:8090/WStest/com.mobile.Wsserver?wsdl

5. Use wsimport to export the client files

wsimport -d d: -keep -verbose http://localhost:8090/WStest/com.mobile.Wsserver?wsdl

												

最新文章

  1. POJMatrix(二维树状数组)
  2. jsp EL 表达式
  3. php 上传大文件主要涉及配置upload_max_filesize和post_max_size两个选项
  4. C#自定义导出数据到Excel中的类封装
  5. mongo中查询Array类型的字段中元素个数
  6. 如何通过图片在 HTTPS 网站中获取 HTTP 接口数据
  7. apache 实用配置
  8. ActionBar 中setDisplayHomeAsUpEnabled和setHomeButtonEnabled和setDisplayShowHomeEnabled方法的理解
  9. FZU Problem 2150 Fire Game(bfs)
  10. JS原型--原型链
  11. 一、Swagger配置
  12. jdk下载及环境变量配置
  13. Migrating your code from 9.3 to 10.x
  14. Java编程的逻辑 (90) - 正则表达式 (下 - 剖析常见表达式)
  15. JBoss 7 里一个EJB依赖其他jar的几种方式
  16. 88个 Linux 系统管理员必备的监控工具
  17. hdu-4283 You Are the One 区间dp,
  18. 设置ubuntu 终端显示路径长度
  19. java程序调优系列(一)intern()代替equal()
  20. Python执行Linux系统命令方法

热门文章

  1. 关于cefsharp 获取js动态加载后的信息
  2. C++——代码风格
  3. JUC源码分析-线程池篇(三)Timer
  4. PXE装机
  5. C#WinForm 窗体单例模式 反射单例
  6. 33-Ubuntu-用户权限-04-修改目录权限
  7. 3-Windows-CMD启动mysql服务-连接本地mysql服务-连接远程mysql服务
  8. zabbix--添加用户
  9. ArcGis面要素空间连接,取相交面积最大者 C#
  10. qt5.9.1 VS2017 qalgorithms.h