Axis 2 客户端必须的一些包
2015-08-26 15:58
295 查看
Xml代码
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2</artifactId>
<version>1.5.1</version>
<type>pom</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-adb</artifactId>
<version>1.5.1</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-kernel</artifactId>
<version>1.5.1</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
加了这些依赖后,maven会自动把这些包的依赖包都加载进来,这样就省去了很多麻烦,即使我并不知道axis2的客户端需要引入哪些包。
客户端代码是:
Java代码
public class RPCClient {
public static void main(String[] args) throws Exception {
//call web service by RPC method
RPCServiceClient serviceClient = new RPCServiceClient();
Options options = serviceClient.getOptions();
//specify URL for invoking
EndpointReference targetEPR = new EndpointReference("http://localhost:8080/axis2/services/SimpleService");
options.setTo(targetEPR);
//specify parameter value for remote getGreeting method
Object[] opAddEntryArgs = new Object[]{"超人"};
//specify returned type for getGreeting method
Class[] classes = new Class[]{String.class};
//specify method name for calling and WSDL namespace
QName opAddEntry = new QName("http://ws.apache.org/axis2","getGreeting");
//opAddEntry.equals(objectToTest);
System.out.println(serviceClient.invokeBlocking(opAddEntry, opAddEntryArgs, classes)[0]);
}
}
通过命令行mvn compile后,运行改java文件,一直报错,找不到org.apache.axis2.transport.local.localTransportSender.class, 通过调试,原来是在初始化RPCServiceClient的时候需要加载LocalTranportSender,所以我们必须加载相应的包。通过google找改包位于org.apache.axis2.osgi 下,所以我加了一个dependency:
Xml代码
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>org.apache.axis2.osgi</artifactId>
<version>1.5.1</version>
</dependency>
重新运行后一切正常。看来maven真的方便很多。呵呵~~
相关文章推荐
- linux 共享库的编译和连接
- PHP生成PDF文件
- 安卓5.0新特性
- UVO 120 Stacks of Flapjacks (整行输入+构造函数)
- 浅谈流形学习
- 并发编程网
- [LeedCode OJ]#162 Find Peak Element
- android使用library
- 安卓5.0新特性
- 倒计时
- 统计文件中单词个数
- webservice编程中的RPCServiceClient类在哪个jar包中?
- iOS开发--TDD的iOS开发初步以及Kiwi使用入门
- TextView和EditText的显示
- SPOJ COT Count on a tree(树上路径第k小 主席树)
- Mr. Process的一生-Linux内核的社会视角 (1) 调度
- Android Studio奇技淫巧一览 大幅度提升工作效率
- Office 365 IT Professional —— OneDrive
- Rust初步(六):在C#中使用Rust组件
- URL锚点定位