axis客戶端呼叫伺服器端方法,返回物件陣列(web service求助)

zqx1984發表於2007-04-03
我在網上找了個公開的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;.

能看出問題嗎?

相關文章