axis客戶端呼叫伺服器端方法,返回物件陣列(web service求助)
我在網上找了個公開的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;.
能看出問題嗎?
客戶端用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;.
能看出問題嗎?
相關文章
- webService 客戶端呼叫 axis2Web客戶端
- 【知識積累】伺服器端獲取客戶端的IP地址(當客戶端呼叫由Axis開發的WebService)伺服器客戶端Web
- 求救!!關於Web Service客戶端的程式,Web客戶端
- 求助:c#客戶端如何跟java伺服器通訊C#客戶端Java伺服器
- 移動端圖片開啟及返回客戶端客戶端
- .net客戶端呼叫activeMQ程式碼客戶端MQ
- Web 應用客戶端渲染和伺服器端渲染的比較Web客戶端伺服器
- .Net Remoting服務端與客戶端呼叫示例REM服務端客戶端
- CouchBase C 客戶端介面呼叫例項客戶端
- 以 Laravel 的方式呼叫 ai 客戶端LaravelAI客戶端
- xfire 客戶端呼叫webservice的問題客戶端Web
- 命令列客戶端MySQL如何使用命令列客戶端MySql
- ElasticSearch-命令列客戶端操作Elasticsearch命令列客戶端
- Oracle 客戶端生成AWR方法Oracle客戶端
- MQTT伺服器搭建服務端和客戶端MQQT伺服器服務端客戶端
- oracle 客戶端與伺服器端的關係Oracle客戶端伺服器
- js 客戶端與伺服器端的通訊JS客戶端伺服器
- 客戶端序列化JSON物件客戶端JSON物件
- 客戶端,服務端客戶端服務端
- 服務端,客戶端服務端客戶端
- 如果呼叫遠端遠端url介面為https,且存在客戶端證書驗證,如何在客戶端處理HTTP客戶端
- 獲得客戶端ip的方法,排除代理伺服器客戶端伺服器
- 在指令碼中呼叫cassandra客戶端命令指令碼客戶端
- 在客戶端儲存對EJB的遠端呼叫是否可行?客戶端
- 小弟求救伺服器-客戶端程式伺服器客戶端
- Irssi:命令列下的IRC客戶端命令列客戶端
- 客戶端到伺服器端的通訊過程客戶端伺服器
- ftp客戶端軟體,ftp客戶端軟體哪個好用,使用方法FTP客戶端
- EJB客戶端如何不用任何client jar去動態呼叫遠端伺服器的EJB?客戶端clientJAR伺服器
- JavaScript客戶端document物件和window物件的區別JavaScript客戶端物件
- dubbo客戶端客戶端
- Pulsar客戶端客戶端
- mqtt 客戶端MQQT客戶端
- 如何使用python爬蟲直接返回客戶端IP?Python爬蟲客戶端
- spring mina整合(客戶端進行呼叫)Spring客戶端
- Web端與Client客戶端資料互動方案選擇Webclient客戶端
- Nacos - 客戶端心跳續約及客戶端總結客戶端
- Slack使用React重寫Web客戶端ReactWeb客戶端