服务热线:13616026886

技术文档 欢迎使用技术文档,我们为你提供从新手到专业开发者的所有资源,你也可以通过它日益精进

位置:首页 > 技术文档 > JAVA > 新手入门 > 基础入门 > 查看文档

使用jwsdp完成web service在java的入门三(图)


  本例要使用的材料:
  
  1 helloif.java,一个sei接口,它扩展了remote接口.
  
  2 helloimpl.java,实现了sei接口.
  
  3 web.xml ,这个文件可以是你的任何web应用的部署描述符文件,这个例子可以发布到你的现有web应用,只需要把那个应用的部署描述符文件放在开发环境的web-inf文件夹下.
  
  4 config-interface.xml,描述sei接口.
  
  5 config-wsdl.xml,使用wsdl描述服务接口,本例不介绍这个文件的使用方法,通常这个使用场景多是为访问服务生成客户端stub文件.另一个场景就是加入自定义的java类型到soap类型的影射等等很多细微的控制,或者是完全替代sei接口.
  
  以上文件的位置,可参看下图:
  
使用jwsdp完成web service在java的入门三(图)

  1 编写sei,helloif:
  
  package helloservice;
  
  import java.rmi.remote;
  
  import java.rmi.remoteexception;
  
  public interface helloif extends remote {
  
  public string sayhello(string s) throws remoteexception;
  
  }
  
  2 实现sei:
  
  package helloservice;
  
  public class helloimpl implements helloif {
  
  public string message ="hello";
  
  public string sayhello(string s) {
  
  return message + s;
  
  }
  
  }
  
  3 配置文件 config-interface.xml
  
  
  
  
  
    
  typenamespace="urn:foo" packagename="helloservice">
  
    
  servantname="helloservice.helloimpl" />
  
  

  
  

  
  4 构建服务,下面是一个ant构建脚本.
  
  
  
  
  
  
  
  

  
  
  
  

  
  
  
  

  
  
  
  

  
  
  
  

  
  
  
  

  
  
  
  

  
  
  
  

  
  
  
  

  
  
  
  
  
  
  
  

  
  
  
  
  
  

  
  

  
  
  
  
  
  
  
  

  
  
  
  
  
  

  
  

  
  
  
  

  
  
  
  

  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  

  
  
  
  
  
  
  
  
  
  

  
  

  
  
  
  
  
  
  
  
  
  

  
  

  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  

  
  
  
  
  
  

  
  
  
  
  
  
  
  
  
  

  
  
  
  

  
  
  
  
  
  
  
  
  
  

  
  

  
  
  
  
  
  
  
  
  
  

  
  

  
  

扫描关注微信公众号