Axis创建webservice客户端和服务端
2014-10-12 13:38
363 查看
原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 、作者信息和本人声明。否则将追究法律责任。 作者:永恒の_☆ 地址:/article/2048074.html
axis.jar
jaxrpc.jar
saaj.jar
wsdl4j-1.5.1.jar
commons-discovery-0.2.jar
xbean.jar
下载地址:http://download.csdn.net/detail/ch656409110/5747129
View Code
public String getHouseList(String xmlStr);
2、实现该接口HouseWebServiceImpl.java
可以随便返回一些字符串即可。
如下:
这就表示Axis发布的webservice服务端成功了。
在这里面传递的xml规范由 服务端自己规范好了,然后去解析、获取参数,执行相应的操作,返回想要的结果给调用的客户端。。
如果用axis调用axis的服务端使用使用起来很方便,但是调用cxf的服务端容易出错。
比如:如果在调用的时候没有指定命名空间,就不行。
在调用的时候不指定调用的参数以及返回的结果类型,就收不到客户端发送的参数。可以看看:http://blog.csdn.net/ch656409110/article/details/9310789
一、Axis的介绍
Web Service是现在最适合实现SOA的技术,而Axis是实现Web Service的一种技术框架(架构)。二、Axis的准备条件
所需要的jar包:axis.jar
jaxrpc.jar
saaj.jar
wsdl4j-1.5.1.jar
commons-discovery-0.2.jar
xbean.jar
下载地址:http://download.csdn.net/detail/ch656409110/5747129
三、创建webservice服务端
1、先将jar包放入lib目录
2、在web.xml中配置axis监听器和核心servlet
<?xml version="0" encoding="UTF-8"?> <deployment xmlns="http://xml.apache.org/axis/wsdd/" xmlns:java="http://xml.apache.org/axis/wsdd/providers/java"> <handler name="URLMapper" type="java:org.apache.axis.handlers.http.URLMapper"/> <service name="houseWebService" provider="java:RPC"> <parameter name="allowedMethods" value="*"/> <parameter name="className" value="com.strutswebservice.server.HouseWebServiceImpl"/> </service> <transport name="http"> <requestFlow> <handler type="URLMapper"/> </requestFlow> </transport> </deployment>
View Code
4、根据配置再创建webservice服务端的实现类
1、定义接口HouseWebService.javapublic String getHouseList(String xmlStr);
2、实现该接口HouseWebServiceImpl.java
可以随便返回一些字符串即可。
5、保存,发布项目,启动tomcat
在地址栏输入:http://localhost:8080/house/services/houseWebService?wsdl 即可看到发布的服务端的明细。如下:
这就表示Axis发布的webservice服务端成功了。
6、通过客户端调用服务端webservice
/** * 调用webservice路口 * @param endpoint 地址 * @param methodName 调用的方法 * @param xmlStr 传递的xml字符串参数 * @return */ public String invoke(String endpoint,String methodName,String xmlStr){ Service service = new Service(); Call call = null; try { call = (Call) service.createCall(); } catch (ServiceException e) { e.printStackTrace(); } QName qn = new QName(methodName); call.setOperationName(qn); call.setTargetEndpointAddress(endpoint); call.setUseSOAPAction(true); String result = ""; try { // 给方法传递参数,并且调用方法 result = (String) call.invoke(new Object[] { xmlStr }); } catch (RemoteException e) { e.printStackTrace(); } System.out.println("result is " + result); return result; } public List<House> getHouseList() { String xmlStr = "<?xml version=\"0\" encoding=\"UTF-8\"?>" + " <house>" + " <condition>" + " <title>便宜</title>" + " <price></price>" + " <streetname></streetname>" + " <typename></typename>" + " <floorage>100</floorage>" + " <pageno></pageno>" + " <pagesize></pagesize>" + " </condition>" + " </house>"; String result = invoke("http://localhost:8080/house/services/houseWebService","getHouseList",xmlStr); }
在这里面传递的xml规范由 服务端自己规范好了,然后去解析、获取参数,执行相应的操作,返回想要的结果给调用的客户端。。
如果用axis调用axis的服务端使用使用起来很方便,但是调用cxf的服务端容易出错。
比如:如果在调用的时候没有指定命名空间,就不行。
在调用的时候不指定调用的参数以及返回的结果类型,就收不到客户端发送的参数。可以看看:http://blog.csdn.net/ch656409110/article/details/9310789
相关文章推荐
- 使用axis技术创建webservice(服务端+客户端)
- Axis创建webservice客户端和服务端
- Axis创建webservice客户端和服务端
- Axis创建webservice客户端和服务端
- 创建WebService简单服务端和客户端
- Webservice_17_客户端创建Handler,服务端接受Handler
- 通过eclipse 的axis1插件,快速开发webservice服务端和客户端
- WebService--使用Axis2创建服务端和客户端
- 创建简单Eclipse插件实现Axis WebService客户端
- 创建简单Eclipse插件实现Axis WebService客户端
- (转载)webservice 客户端,axis调用cxf 发布的webservices服务端
- 通过jaxws-ri创建webservice服务端和客户端
- 创建简单Eclipse插件实现Axis WebService客户端
- 创建webservice服务端以及生成客户端进行调用
- 通过eclipse 的axis1插件,快速开发webservice服务端和客户端
- CXF创建webservice客户端和服务端
- CXF创建webservice客户端和服务端
- 用axis实现webService--服务端+客户端
- axis1 创建service服务端 , axis1 客户端
- 通过eclipse 的axis1插件,快速开发webservice服务端和客户端