axis客户端调用服务器端方法,返回对象数组(web service求助)

07-04-03 zqx1984
我在网上找了个公开的web service wsdl地址为:http://www.fundxy.com/fundxy/Common/FundxyService.asmx?WSDL

客户端用java编写

web service公开一方法为GetNewFundValue , 是接收三个整形参数(FundType,SortType,AscFlag),然后返回一个对象数组,对象为FundValue

我在客户端进行了FundValue对象自定义序列化,写了个javabean

我在客户端的axis代码是:

public class returnFundValue {

public static void main(String[] args) {

try {

Integer i = new Integer(1);

Integer j = new Integer(0);

Integer z = new Integer(0);

String endpoint="http://www.fundxy.com/fundxy/Common/FundxyService.asmx";

Service service = new Service();

Call call = (Call)service.createCall();

//注册对象

QName qn=new QName("http://www.fundxy.com/fundxy/common/fundxyservice", "FundValue");

call.registerTypeMapping(FundValue.class, qn,

new org.apache.axis.encoding.ser.

BeanSerializerFactory(FundValue.class, qn),

new org.apache.axis.encoding.ser.

BeanDeserializerFactory(FundValue.class, qn));

//注册对象数组

QName qname=new QName("http://www.fundxy.com/fundxy/common/fundxyservice","ArrayOfFundValue");

call.registerTypeMapping(FundValue[].class,qname,

new org.apache.axis.encoding.ser.BeanSerializerFactory(FundValue[].class,qname),

new org.apache.axis.encoding.ser.BeanDeserializerFactory(FundValue[].class,qname));

call.setTargetEndpointAddress(new java.net.URL(endpoint));

call.setOperationName(new QName("http://www.fundxy.com/fundxy/common/fundxyservice","GetNewFundValue"));

//添加参数:

call.addParameter("FundType",new QName("http://www.w3.org/2001/XMLSchema","int"),javax.xml.rpc.ParameterMode.IN);

call.addParameter("SortType",new QName("http://www.w3.org/2001/XMLSchema","int"),javax.xml.rpc.ParameterMode.IN);

call.addParameter("AscFlag",new QName("http://www.w3.org/2001/XMLSchema","int"),javax.xml.rpc.ParameterMode.IN);

//call.setReturnType(org.apache.axis.encoding.XMLType.SOAP_ARRAY);

//call.setReturnType(new QName("http://www.fundxy.com/fundxy/common/fundxyservice","GetNewFundValue"),FundValue[].class);

call.setReturnType(qname);

call.setUseSOAPAction(true);

call.setSOAPActionURI("http://www.fundxy.com/fundxy/common/fundxyservice/GetNewFundValue");

FundValue[] k= (FundValue[])call.invoke(new Object[]{i,j,z});

System.out.println( "result is " + k[1].getFundID());

}

catch (Exception e) {System.err.println(e.toString()); }

}

}

但是执行的时候就报下面的错误:

org.xml.sax.SAXException: Unable to create JavaBean of type [LFundValue;. Missi

ng default constructor? Error was: java.lang.InstantiationException: [LFundValu

e;.

at org.apache.axis.encoding.ser.BeanDeserializer.startElement(BeanDeseri

alizer.java:147)

at org.apache.axis.encoding.DeserializationContext.startElement(Deserial

izationContext.java:1048)

at org.apache.axis.message.SAX2EventRecorder.replay(SAX2EventRecorder.ja

va:165)

at org.apache.axis.message.MessageElement.publishToHandler(MessageElemen

t.java:1141)

at org.apache.axis.message.RPCElement.deserialize(RPCElement.java:236)

at org.apache.axis.message.RPCElement.getParams(RPCElement.java:384)

at org.apache.axis.client.Call.invoke(Call.java:2467)

at org.apache.axis.client.Call.invoke(Call.java:2366)

at org.apache.axis.client.Call.invoke(Call.java:1812)

at returnFundValue.main(returnFundValue.java:75)

org.xml.sax.SAXException: Unable to create JavaBean of type [LFundValue;. Missi

ng default constructor? Error was: java.lang.InstantiationException: [LFundValu

e;.

能看出问题吗?

zuly
2007-04-05 10:01
把wsdl的schema贴给我看!

解决ws的问题,肯定从wsdl入手,用jaxb生成测试类,然后单步求解!

猜你喜欢