Spring axis2 webService 支持
来源:互联网 发布:用爬虫爬网页数据 编辑:程序博客网 时间:2024/06/03 00:43
Spring对WebService的支持
来源:http://ajava.org/readbook/open/spring2bd/15858.html
Spring使用ServletEndpointSupport来暴露WebService。假设有如下接口:
//业务接口
public interface Hello
{
public String hello(String name);
}
以及如下的实现类:
//实现类,实现上面的业务接口
public class HelloImpl implements Hello
{
//实现业务接口必须实现的方法
public String hello(String name)
{
return name + "你好,欢迎学习Spring和Axis";
}
}
上面是非常简单的面向接口编程的应用结构,一个接口以及对应的实现类。如果需要将该实现类暴露成WebService,则编写一个WebService类,让该类实现Hello接口,并继承ServletEndpointSupport类。该类的源代码如下:
//实现Hello接口,继承ServletEndpointSupport工具类
public class HelloEndpoint extends ServletEndpointSupport implements Hello
{
//将真实的业务bean包装成WebService
private Hello h;
//该方法由Spring调用,将目标业务bean注入。
protected void onInit()
{
this.h = (Hello) getWebApplicationContext().getBean("hello");
}
//将业务bean的业务方法暴露成WebService
public String hello(String name)
{
return h.hello(name);
}
}
然后提供Spring的配置文件,配置文件中部署业务bean,配置文件如下:
"http://www.springframework.org/dtd/spring-beans.dtd">
然后修改web.xml文件,让AxisServlet拦截某些请求,这是Axis必需的。web.xml的详细配置如下:
"http://java.sun.com/dtd/web-app_2_3.dtd">
配置文件中,看到所有匹配/axis/*模式的请求都由AxisServlet处理。即:Spring发布的WebService都在axis下。然后编写wsdl文件,或者使用工具生成。wsdl文件如下:
xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">
经过这些步骤,可将部署在Spring的普通bean发布成WebService。
- Spring axis2 webService 支持
- Spring + axis2 开发 webservice
- Spring + axis2 开发 webservice
- Spring axis2 webservice
- webservice axis2+spring整合
- Axis2+Spring构建WebService
- axis2+spring+hibernate(webservice工程)
- webservice+axis2+spring+http/https
- WebService之Axis2系列教程Axis2与Spring集成发布
- axis2+spring+Hibernate webservice 非aar方式
- Axis2与spring结合创建webService
- webservice框架(cxf, axis2, spring-ws)
- axis2+spring集成发布webservice服务
- axis2+spring+Hibernate webservice 非aar方式
- eclipse开发webservice-axis2/spring+maven
- eclipse开发webservice-axis2/spring+maven
- Axis2 WebService
- WebService axis2
- Could not synchronize database state with session
- mysql转oracle注意的问题
- 高兴
- 快速排序
- 史上最强弟子兼一
- Spring axis2 webService 支持
- 爱普生photo EX3打印机四个灯同时闪的解决方法
- Blizzard的MPQ文件格式搜索算法
- JSP学习经验总结-------转
- php 正则表达式
- C++与EXEL(CSV)
- HDU 动态规划(46道题目)倾情奉献~ 【只提供思路与状态转移方程】
- Ajax,AjaxPro说明
- make: *** [emigen] Error 255错误分析