首页 测试 体会 查看内容

Web service jws自带测试例子

2014-3-29 11:04| 发布者: tianzc| 查看: 995| 评论: 0

摘要:   新建一个服务端项目:  1、定义一个接口如下:/*** 定义webservices接口* @author Administrator**/@WebServicepublic interface IHelloService {public String sayHello(String name);public User getUser(Us ...
/*** 定义webservices接口* @author Administrator**/@WebServicepublic interface IHelloService {public String sayHello(String name);public User  getUser(User user);}  2.实现接口/*** 实现webservices接口* @author Administrator**/endpointInterface 实现的接口类@WebService(endpointInterface="com.chni.webservies.IHelloService")public class HelloServiceImpl implements IHelloService {public User getUser(User user) {// TODO Auto-generated method stubreturn null;}public String sayHello(String name) {// TODO Auto-generated method stubreturn name;}}  3、启动服务(执行下列main函数)public class TestService {public static void main(String[] args) {//服务地址String address="http://localhost:8989/u";Endpoint.publish(address, new HelloServiceImpl());}}  4、在浏览器上输入:http://127.0.0.1:8989/u?wsdl 看到以下信息:<!-- Published by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.1.6 in JDK 6. --><!-- Generated by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.1.6 in JDK 6. --><definitions targetNamespace="http://impl.webservies.chni.com/" name="HelloServiceImplService"><import namespace="http://webservies.chni.com/" location="http://127.0.0.1:8989/u?wsdl=1"/><binding name="HelloServiceImplPortBinding" type="ns1:IHelloService"><soap:binding transport="http://schemas.xmlsoap.org/soap/http" /><operation name="getUser"><soap:operation soapAction=""/><input><soap:body use="literal"/></input><output><soap:body use="literal"/></output></operation><operation name="sayHello"><soap:operation soapAction=""/><input><soap:body use="literal"/></input><output><soap:body use="literal"/></output></operation></binding><service name="HelloServiceImplService"><port name="HelloServiceImplPort" binding="tns:HelloServiceImplPortBinding"><soap:address location="http://127.0.0.1:8989/u"/></port></service></definitions>
  新建一个服务端项目:  1、定义一个接口如下:
12下一页

鲜花

握手

雷人

路过

鸡蛋

扫一扫关注最新动态

毒镜头:老镜头、摄影器材资料库、老镜头样片、摄影
爱评测 aipingce.com  
返回顶部