AXIS2最简单客户端jar包说明及错误对照

 参照网上的例子写了一个AXIS2的客户端例子,在此感谢各位前辈的无私奉献!同时也分享一下,供各位朋友指导!



服务端代码:


import java.util.Random;

public class HelloWorldService {

    public String sayHello(String name) {
        return name + "! say:hello [axis2 ]";
    }

    public int getAge(int i) {
        return i + new Random().nextInt(100);
    }
}


客户端代码:


package client;

import javax.xml.namespace.QName;

import org.apache.axis2.AxisFault;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.client.Options;
import org.apache.axis2.rpc.client.RPCServiceClient;

public class HelloWordClient {
	public static void main(String[] args) throws AxisFault {
		
		RPCServiceClient client = new RPCServiceClient();
		Options options = client.getOptions();
		String address = "http://localhost:8080/axis2/services/HelloWorldService";
		EndpointReference epf = new EndpointReference(address);
		options.setTo(epf);
		
		QName qName = new QName("http://ws.apache.org/axis2","sayHello");
		Object[] result = client.invokeBlocking(qName, new Object[]{"winter"}, new Class[]{String.class});
		System.out.println(result[0]);
		
		qName=new QName("http://ws.apache.org/axis2","getAge");
		result = client.invokeBlocking(qName, new Object[]{ new Integer(22) } , new Class[] {int.class});
		System.out.println(result[0]);
	}
}

以上代码接来源于网络!



下面才是我重点想说的内容,也是我一样的初学者比较困惑的jar包问题,经我实际测试所需的最少jar包为


axiom-api-1.2.13.jar
axiom-impl-1.2.13.jar
axis2-adb-1.6.2.jar
axis2-kernel-1.6.2.jar
axis2-transport-http-1.6.2.jar
axis2-transport-local-1.6.2.jar
commons-codec-1.3.jar
commons-httpclient-3.1.jar
commons-logging-1.1.1.jar
httpcore-4.0.jar
neethi-3.0.2.jar
wsdl4j-1.6.2.jar
XmlSchema-1.4.7.jar




下面是缺少jar包和相关的错误说明:

XmlSchema-1.4.7.jar			
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/ws/commons/schema/resolver/URIResolver

axiom-impl-1.2.13.jar			
Exception in thread "main" org.apache.axiom.om.OMException: No meta factory found for feature 'default'; this usually means that axiom-impl.jar is not in the classpath 

neethi-3.0.2.jar			
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/neethi/PolicyComponent

axis2-transport-http-1.6.2.jar		
Exception in thread "main" org.apache.axis2.deployment.DeploymentException: org.apache.axis2.transport.http.CommonsHTTPTransportSender

axis2-transport-local-1.6.2.jar		
Exception in thread "main" org.apache.axis2.deployment.DeploymentException: org.apache.axis2.transport.local.LocalTransportSender	

commons-codec-1.3.jar			
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/codec/DecoderException

commons-httpclient-3.1.jar		
Exception in thread "main" org.apache.axis2.deployment.DeploymentException: org/apache/commons/httpclient/HttpException

httpcore-4.0.jar			
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/http/HttpResponseFactory

wsdl4j-1.6.2.jar			
Exception in thread "main" java.lang.NoClassDefFoundError: javax/wsdl/xml/WSDLLocator





评论 9
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值