我在网上找了个公开的web service   wsdl地址为:http://www.fundxy.com/fundxy/Common/FundxyService.asmx?WSDL客户端用java编写web service公开一方法为GetNewFundValue , 是接收三个整形参数(FundType,SortType,AscFlag),然后返回一个对象数组,对象为FundValue我在客户端进行了FundValue对象自定义序列化,写了个javabean:import java.io.Serializable;public class FundValueBean implements Serializable{
  private String fundName;
  private String fundID;
  private String valueDate;
  private Float todayValue;
  private Float totalValue;
  private Float varPercent;
  private Float varValue;
  public FundValueBean() {
  }
  public String getFundName() {
    return fundName;
  }
  public void setFundName(String fundName) {
    this.fundName = fundName;
  } .......................... 
}
我在客户端的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;.
大家看看问题出在哪里,怎么解决?  解决完就结帖,分不够再加!!

解决方案 »

  1.   

    在客户端输入三个整型,传递给服务端进行处理,处理完毕后服务端再返回个FundValue对象数组,结果我在客户端用自定义的FundValue对象进行接收的时候,就出错了~~真搞不懂
      

  2.   

    LFundValue;.  Missi
    ng default constructor?  Error was: java.lang.InstantiationException: [LFundValu
    e;.意思是说FundValue没有默认的构造方法,但是那也不对,我已经定义了构造方法了,所以我觉的应该是说FundValue[]数组没有构造方法,但是这样也不对啊~~~~~~而且奇怪的是,我对客户端axis代码编译完的class进行反编译,得到的跟先前的java文件不一样,原来里面定义的FundValue[],全部变成LFundValue,真奇怪....难道是BUG?
      

  3.   

    不需要注册对象数组..直接在返回类型中指明返回是FundValue[]就可以~~
    就是用
    call.setReturnType(new QName("http://www.fundxy.com/fundxy/common/fundxyservice","GetNewFundValue"),FundValue[].class);