首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 软件管理 > 软件架构设计 >

Axis 二 客户端必须的一些包

2012-09-06 
Axis 2 客户端必须的一些包今天试着用eclipse+maven2创建一个wtp web应用,在这个应用中,我想试着去写一个a

Axis 2 客户端必须的一些包

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

?

<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的客户端需要引入哪些包。

客户端代码是:

public class RPCClient {public static void main(String[] args) throws Exception {//call web service by RPC methodRPCServiceClient serviceClient = new RPCServiceClient();Options options = serviceClient.getOptions();//specify URL for invokingEndpointReference targetEPR = new EndpointReference("http://localhost:8080/axis2/services/SimpleService");options.setTo(targetEPR);//specify parameter value for remote getGreeting methodObject[] opAddEntryArgs = new Object[]{"超人"};//specify returned type for getGreeting methodClass[] classes = new Class[]{String.class};//specify method name for calling and WSDL namespaceQName 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:

<dependency>   <groupId>org.apache.axis2</groupId>   <artifactId>org.apache.axis2.osgi</artifactId>   <version>1.5.1</version></dependency>

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

热点排行