Axis 2 客户端必须的一些包

 

今天试着用eclipse+maven2创建一个wtp web应用,在这个应用中,我想试着去写一个axis2的客户端。首先我把一些dependencies都加到项目中,具体的有:

 

Xml代码   收藏代码
  1. <dependency>  
  2.         <groupId>org.apache.axis2</groupId>  
  3.         <artifactId>axis2</artifactId>  
  4.         <version>1.5.1</version>  
  5.         <type>pom</type>  
  6.         <scope>compile</scope>  
  7.     </dependency>  
  8.     <dependency>  
  9.         <groupId>org.apache.axis2</groupId>  
  10.         <artifactId>axis2-adb</artifactId>  
  11.         <version>1.5.1</version>  
  12.         <type>jar</type>  
  13.         <scope>compile</scope>  
  14.     </dependency>  
  15.     <dependency>  
  16.         <groupId>org.apache.axis2</groupId>  
  17.         <artifactId>axis2-kernel</artifactId>  
  18.         <version>1.5.1</version>  
  19.         <type>jar</type>  
  20.         <scope>compile</scope>  
  21.     </dependency>  

 加了这些依赖后,maven会自动把这些包的依赖包都加载进来,这样就省去了很多麻烦,即使我并不知道axis2的客户端需要引入哪些包。

客户端代码是:

Java代码   收藏代码
  1. public class RPCClient {  
  2.   
  3.     public static void main(String[] args) throws Exception {  
  4.           
  5.         //call web service by RPC method  
  6.         RPCServiceClient serviceClient = new RPCServiceClient();  
  7.         Options options = serviceClient.getOptions();  
  8.           
  9.         //specify URL for invoking  
  10.         EndpointReference targetEPR = new EndpointReference("http://localhost:8080/axis2/services/SimpleService");  
  11.         options.setTo(targetEPR);  
  12.           
  13.         //specify parameter value for remote getGreeting method  
  14.         Object[] opAddEntryArgs = new Object[]{"超人"};  
  15.           
  16.         //specify returned type for getGreeting method  
  17.         Class[] classes = new Class[]{String.class};  
  18.           
  19.         //specify method name for calling and WSDL namespace  
  20.         QName opAddEntry = new QName("http://ws.apache.org/axis2","getGreeting");  
  21.         //opAddEntry.equals(objectToTest);  
  22.         System.out.println(serviceClient.invokeBlocking(opAddEntry, opAddEntryArgs, classes)[0]);  
  23.           
  24.           
  25.     }  
  26.       
  27. }  

 通过命令行mvn compile后,运行改java文件,一直报错,找不到org.apache.axis2.transport.local.localTransportSender.class, 通过调试,原来是在初始化RPCServiceClient的时候需要加载LocalTranportSender,所以我们必须加载相应的包。通过google找改包位于org.apache.axis2.osgi 下,所以我加了一个dependency:

Xml代码   收藏代码
  1. <dependency>  
  2.        <groupId>org.apache.axis2</groupId>  
  3.        <artifactId>org.apache.axis2.osgi</artifactId>  
  4.        <version>1.5.1</version>  
  5. </dependency>  

 重新运行后一切正常。看来maven真的方便很多。呵呵~~

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值