springMVC 基于jws的webservice建立

在已有的springmvc+spring+mybatis框架的基础上,基于jws创建webservice很简单,跟平常写接口一样,只是多个@WebService的注解。

示例如下:

1、接口

@WebService(serviceName="example")

public interface IWsExample{

@WebMethod

public String getInfo(String id);

}

2、实现类:

@Service

@WebService(endpointInterface="com.test.IWsExample")---对应上面接口

public class wsExampleImpl implements IWsExample{

@Override

public String getInfo(String id){

System.out.println("webservice测试");

}

}

增加配置文件spring-context-jaxws.xml


3、生成客户端代码

使用jdk自带的wsimport工具生成。

wsimport -d d:  -keep -p  "com.test" http://192.168.1.10:8088/example?wsdl

生成的客户端代码在d:盘com/test下

4、写个测试类,调用webService方法

public void main(String[] args){

ExampleImplService server=new ExampleImplService ();

IExample serverImpl=server.getExampleImplPort();

System.out.println(serverImpl.getInfo("lalala"));

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值