我有三个类,TimeoutUwPolicyFile,TimeoutUwPolicyDetails和TimeoutUwPolicyDetail。它们的关系是TimeoutUwPolicyDetails属于TimeoutUwPolicyFile一个属性,TimeoutUwPolicyDetail是属于TimeoutUwPolicyDetails的列表元素,用XML形式描述是这样的关系:
<?xml version="1.0" encoding="GBK"?>
<timeout-uw-policy-file>
<timeout-uw-policy-details>
<timeout-uw-policy-detail>
<bank-zone>00200</bank-zone>
<dept>00020</dept>
<insure>008</insure>
<bank-seq>19823471237417412748</bank-seq>
<send-code>000397533642307</send-code>
<holder-name>name</holder-name>
<uw-flag>1</uw-flag>
<hold-date>20090330</hold-date>
<create-file-date>20090331</create-file-date>
</timeout-uw-policy-detail>
                <timeout-uw-policy-detail>
<bank-zone>00200</bank-zone>
<dept>00020</dept>
<insure>008</insure>
<bank-seq>19823471237417412748</bank-seq>
<send-code>000397533642307</send-code>
<holder-name>name</holder-name>
<uw-flag>1</uw-flag>
<hold-date>20090330</hold-date>
<create-file-date>20090331</create-file-date>
</timeout-uw-policy-detail>
</timeout-uw-policy-details>
</timeout-uw-policy-file>这三个类传输时在前台的关系能显示出来,但传输到后台,TimeoutUwPolicyFile对象中的列表大小变成0了,很是奇怪,请高手帮忙分析分析原因。代码我一部分一部分上传过来。

解决方案 »

  1.   

    前台调:
      import javax.xml.namespace.QName;import org.apache.axis.client.Call;
    import org.apache.axis.client.Service;
    import org.apache.axis.encoding.ser.BeanDeserializerFactory;
    import org.apache.axis.encoding.ser.BeanSerializerFactory;
    import org.apache.commons.logging.Log;
    import org.apache.commons.logging.LogFactory;import com.ulic.life.webservice.xml.*;import java.util.ArrayList;public class ServiceSoapBindingStub extends org.apache.axis.client.Stub  { public ServiceSoapBindingStub() throws org.apache.axis.AxisFault {
    this(null);
    } public ServiceSoapBindingStub(java.net.URL endpointURL, javax.xml.rpc.Service service) throws org.apache.axis.AxisFault {
    this(service);
    super.cachedEndpoint = endpointURL;
    } public ServiceSoapBindingStub(javax.xml.rpc.Service service) throws org.apache.axis.AxisFault {
    if (service == null) {
    super.service = new org.apache.axis.client.Service();
    } else {
    super.service = service;
    }
    }
    public static void registerBean(String classStr, Class myClass, Call call) {
    QName qn = new QName("urn:BeanService", classStr);
    call.registerTypeMapping(myClass, qn, new BeanSerializerFactory(myClass, qn), new BeanDeserializerFactory(myClass, qn));
    }
    public CheckBillReturnResult timeoutUwPolicyInfo(TimeoutUwPolicyFile timeoutUwPolicyFile) throws Exception {
    Service service = new Service();
    log.info("ServiceSoapBindingStub核保超时投保单文件总数:" + timeoutUwPolicyFile.getTimeoutUwPolicyDetails().getTimeoutUwPolicyListCount());
    //这里打印出来的数量是2,此时该对象未做任何的处理就直接传输给后台了。 Call call = (Call) service.createCall();
    // 注册 bean
    registerBean("ArrayList", ArrayList.class, call);
    registerBean("TimeoutUwPolicyDetail", TimeoutUwPolicyDetail.class, call);
    registerBean("TimeoutUwPolicyDetails", TimeoutUwPolicyDetails.class, call);

    registerBean("TimeoutUwPolicyFile", TimeoutUwPolicyFile.class, call);
    registerBean("CheckBillReturnResult", CheckBillReturnResult.class, call);

    call.setTargetEndpointAddress(super.cachedEndpoint);// endpoint) );
    call.setOperationName(new QName("http://soapinterop.org/", "timeoutUwPolicyInfo")); java.lang.Object _resp = call.invoke(new Object[]{timeoutUwPolicyFile}); if (_resp instanceof java.rmi.RemoteException) {
    throw (java.rmi.RemoteException) _resp;
    } else {
    return (CheckBillReturnResult) _resp; }
    }

    }
      

  2.   

    后台提供的接口函数: public CheckBillReturnResult timeoutUwPolicyInfo(TimeoutUwPolicyFile timeoutUwPolicyFile) throws Exception {
    System.out.println("---yuhm---"+timeoutUwPolicyFile.getTimeoutUwPolicyDetails().getTimeoutUwPolicyListCount());
                    //这个地方打印出来的数量是0了,中间传输过程中数据丢了。
    return null; }
      

  3.   

    后台的三个文件:TimeoutUwPolicyFile  
    package com.ulic.life.webservice.xml;import org.exolab.castor.xml.Validator; public class TimeoutUwPolicyFile  implements java.io.Serializable{

    static final long serialVersionUID = 1000000000028L;

    /**
     * 空构造函数
     */
    public TimeoutUwPolicyFile(){

    } private TimeoutUwPolicyDetails timeoutUwPolicyDetails;

        public boolean isValid()
        {
            try
            {
                validate();
            }
            catch(org.exolab.castor.xml.ValidationException validationexception)
            {
                return false;
            }
            return true;
        }     public void marshal(java.io.Writer writer)
            throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
        {
            org.exolab.castor.xml.Marshaller.marshal(this, writer);
        }     public void marshal(org.xml.sax.ContentHandler contenthandler)
            throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
        {
            org.exolab.castor.xml.Marshaller.marshal(this, contenthandler);
        }
        
        public void validate()throws org.exolab.castor.xml.ValidationException{
        org.exolab.castor.xml.Validator validator = new Validator();
        validator.validate(this);
    }
        public static TimeoutUwPolicyFile unmarshalTimeoutUwPolicyFile(java.io.Reader reader)
        throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
    {
        return (TimeoutUwPolicyFile)org.exolab.castor.xml.Unmarshaller.unmarshal(TimeoutUwPolicyFile.class, reader);
    }
    public void setTimeoutUwPolicyDetails(TimeoutUwPolicyDetails detail){
    this.timeoutUwPolicyDetails = detail;
    }
    public TimeoutUwPolicyDetails getTimeoutUwPolicyDetails(){
    return timeoutUwPolicyDetails;
    } }package com.ulic.life.webservice.xml;import org.exolab.castor.util.IteratorEnumeration;
    import org.exolab.castor.xml.Validator;
    import java.util.*;
    /**
     * 
     * 
     */
    public class TimeoutUwPolicyDetails implements java.io.Serializable {
    static final long serialVersionUID = 1000000000029L;
    // 超时文件列表
    private java.util.ArrayList timeoutUwPolicyList;
    public TimeoutUwPolicyDetails() {
    timeoutUwPolicyList = new ArrayList();
    }
    /**
     * 指定位置设置明细条目
     * 
     * @param i
     * @param detail
     * @throws java.lang.IndexOutOfBoundsException
     */
    public void setTimeoutUwPolicyDedail(int i,
    com.ulic.life.webservice.xml.TimeoutUwPolicyDetail detail)
    throws java.lang.IndexOutOfBoundsException {
    if (i < 0 || i > timeoutUwPolicyList.size()) {
    throw new IndexOutOfBoundsException();
    } else {
    timeoutUwPolicyList.set(i, detail);
    return;
    }
    } /**
     * 将明细数据的所有元素存放于明细表中
     * 
     * @param detail
     */
    public void setTimeoutUwPolicyDedail(
    com.ulic.life.webservice.xml.TimeoutUwPolicyDetail detail[]) {
    timeoutUwPolicyList.clear();
    for (int i = 0; i < detail.length; i++)
    timeoutUwPolicyList.add(detail[i]); }
    /**
     * 移去明细表中指定的元素值
     * 
     * @param checkbill
     * @return
     */
    public boolean removeTimeoutUwPolicyDetail(
    com.ulic.life.webservice.xml.TimeoutUwPolicyDetail timeoutUwPolicyDetail) {
    boolean flag = timeoutUwPolicyList.remove(timeoutUwPolicyDetail);
    return flag;
    }
    /**
     * 返回列表中的元素个数
     * 
     * @return
     */
    public int getTimeoutUwPolicyListCount() {
    return timeoutUwPolicyList.size();
    }
    /**
     * 得到列表中所有元素
     * 
     * @return
     */
    public com.ulic.life.webservice.xml.TimeoutUwPolicyDetail[] getTimeoutUwPolicyDetail() {
    int size = timeoutUwPolicyList.size();
    com.ulic.life.webservice.xml.TimeoutUwPolicyDetail returnDetail[] = new com.ulic.life.webservice.xml.TimeoutUwPolicyDetail[size];
    for (int j = 0; j < size; j++)
    returnDetail[j] = (com.ulic.life.webservice.xml.TimeoutUwPolicyDetail) timeoutUwPolicyList
    .get(j); return returnDetail;
    }
    /**
     * 得到指定位置中的元素
     * 
     * @param i
     * @return
     * @throws java.lang.IndexOutOfBoundsException
     */
    public com.ulic.life.webservice.xml.TimeoutUwPolicyDetail getTimeoutUwPolicyDetail(
    int i) throws java.lang.IndexOutOfBoundsException {
    if (i < 0 || i > timeoutUwPolicyList.size())
    throw new IndexOutOfBoundsException();
    else
    return (com.ulic.life.webservice.xml.TimeoutUwPolicyDetail) timeoutUwPolicyList
    .get(i);
    }
    /**
     * 清空明细表
     */
    public void clearTimeoutUwPolicyDetail() {
    timeoutUwPolicyList.clear();
    }
    /**
     * 获取该列表的循环
     * 
     * @return
     */
    public java.util.Enumeration enumerateTimeoutUwPolicyDetail() {
    return new IteratorEnumeration(timeoutUwPolicyList.iterator());
    }
    /**
     * 往列表中增加元素
     * 
     * @param detail
     * @throws java.lang.IndexOutOfBoundsException
     */
    public void addTimeoutUwPolicyDetail(
    com.ulic.life.webservice.xml.TimeoutUwPolicyDetail detail)
    throws java.lang.IndexOutOfBoundsException {
    timeoutUwPolicyList.add(detail);
    }
    /**
     * 往列表的指定位置增加元素
     * 
     * @param i
     * @param detail
     * @throws java.lang.IndexOutOfBoundsException
     */
    public void addTimeoutUwPolicyDetail(int i,
    com.ulic.life.webservice.xml.TimeoutUwPolicyDetail detail)
    throws java.lang.IndexOutOfBoundsException {
    timeoutUwPolicyList.add(i, detail);
    } public boolean isValid() {
    try {
    validate();
    } catch (org.exolab.castor.xml.ValidationException validationexception) {
    return false;
    }
    return true;
    } public void marshal(java.io.Writer writer)
    throws org.exolab.castor.xml.MarshalException,
    org.exolab.castor.xml.ValidationException {
    org.exolab.castor.xml.Marshaller.marshal(this, writer);
    } public void marshal(org.xml.sax.ContentHandler contenthandler)
    throws java.io.IOException, org.exolab.castor.xml.MarshalException,
    org.exolab.castor.xml.ValidationException {
    org.exolab.castor.xml.Marshaller.marshal(this, contenthandler);
    } public static TimeoutUwPolicyDetails unmarshalTimeoutUwPolicyDetails(
    java.io.Reader reader)
    throws org.exolab.castor.xml.MarshalException,
    org.exolab.castor.xml.ValidationException {
    return (TimeoutUwPolicyDetails) org.exolab.castor.xml.Unmarshaller
    .unmarshal(TimeoutUwPolicyDetails.class, reader);
    } public void validate() throws org.exolab.castor.xml.ValidationException {
    org.exolab.castor.xml.Validator validator = new Validator();
    validator.validate(this);
    }
    }
      

  4.   

    //TimeoutUwPolicyDetail 明细文件
    package com.ulic.life.webservice.xml;import org.exolab.castor.xml.Validator;public class TimeoutUwPolicyDetail implements java.io.Serializable { static final long serialVersionUID = 1000000000030L;
    public TimeoutUwPolicyDetail() {
    } private java.lang.String bankZone; private java.lang.String dept; private java.lang.String insure;
    private java.lang.String bankSeq; private java.lang.String sendCode;
    private java.lang.String holderName;
    private java.lang.String uwFlag; private java.lang.String holdDate; private java.lang.String createFileDate; public java.lang.String getCreateFileDate() {
    return createFileDate;
    }
    public void setCreateFileDate(java.lang.String createFileDate) {
    this.createFileDate = createFileDate;
    }
    public java.lang.String getBankZone() {
    return bankZone;
    }
    public void setBankZone(java.lang.String bankZone) {
    this.bankZone = bankZone;
    }
    public java.lang.String getDept() {
    return dept;
    }
    public void setDept(java.lang.String dept) {
    this.dept = dept;
    }
    public java.lang.String getInsure() {
    return insure;
    }
    public void setInsure(java.lang.String insure) {
    this.insure = insure;
    }
    public java.lang.String getSendCode() {
    return sendCode;
    }
    public void setSendCode(java.lang.String sendCode) {
    this.sendCode = sendCode;
    }
    public java.lang.String getHolderName() {
    return holderName;
    }
    public void setHolderName(java.lang.String holderName) {
    this.holderName = holderName;
    }
    public java.lang.String getUwFlag() {
    return uwFlag;
    }
    public void setUwFlag(java.lang.String uwFlag) {
    this.uwFlag = uwFlag;
    }
    public java.lang.String getHoldDate() {
    return holdDate;
    }
    public void setHoldDate(java.lang.String holdDate) {
    this.holdDate = holdDate;
    }
    public java.lang.String getBankSeq() {
    return bankSeq;
    }
    public void setBankSeq(java.lang.String bankSeq) {
    this.bankSeq = bankSeq;
    }
    public boolean isValid() {
    try {
    validate();
    } catch (org.exolab.castor.xml.ValidationException validationexception) {
    return false;
    }
    return true;
    } public void marshal(java.io.Writer writer)
    throws org.exolab.castor.xml.MarshalException,
    org.exolab.castor.xml.ValidationException {
    org.exolab.castor.xml.Marshaller.marshal(this, writer);
    } public void marshal(org.xml.sax.ContentHandler contenthandler)
    throws java.io.IOException, org.exolab.castor.xml.MarshalException,
    org.exolab.castor.xml.ValidationException {
    org.exolab.castor.xml.Marshaller.marshal(this, contenthandler);
    } public static TimeoutUwPolicyDetail unmarshalTimeoutUwPolicyDetail(
    java.io.Reader reader)
    throws org.exolab.castor.xml.MarshalException,
    org.exolab.castor.xml.ValidationException {
    return (TimeoutUwPolicyDetail) org.exolab.castor.xml.Unmarshaller
    .unmarshal(TimeoutUwPolicyDetail.class, reader);
    } public void validate() throws org.exolab.castor.xml.ValidationException {
    org.exolab.castor.xml.Validator validator = new Validator();
    validator.validate(this);
    }}
      

  5.   

    我后台的wsdd配置文件是这样的:
    <?xml version="1.0" encoding="UTF-8"?>
    <deployment xmlns="http://xml.apache.org/axis/wsdd/" xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">
    <globalConfiguration>
    <parameter name="adminPassword" value="admin"/>
    <parameter name="attachments.Directory" value="C:\eclipse\workspace\bookstore\WEB-INF\attachments"/>
    <parameter name="attachments.implementation" value="org.apache.axis.attachments.AttachmentsImpl"/>
    <parameter name="sendXsiTypes" value="true"/>
    <parameter name="sendMultiRefs" value="true"/>
    <parameter name="sendXMLDeclaration" value="true"/>
    <parameter name="axis.sendMinimizedElements" value="true"/>
    <requestFlow>
    <handler type="java:org.apache.axis.handlers.JWSHandler">
    <parameter name="scope" value="session"/>
    </handler>
    <handler type="java:org.apache.axis.handlers.JWSHandler">
    <parameter name="scope" value="request"/>
    <parameter name="extension" value=".jwr"/>
    </handler>
    </requestFlow>
    </globalConfiguration>
    <handler name="LocalResponder" type="java:org.apache.axis.transport.local.LocalResponder"/>
    <handler name="Authenticate" type="java:org.apache.axis.handlers.SimpleAuthenticationHandler"/>
    <handler name="URLMapper" type="java:org.apache.axis.handlers.http.URLMapper"/>
    <service name="Version" provider="java:RPC">
    <parameter name="allowedMethods" value="getVersion"/>
    <parameter name="className" value="org.apache.axis.Version"/>
    </service>
    <service name="ULWebService" provider="java:RPC">
    <parameter name="allowedMethods" value="*"/>
    <parameter name="className" value="com.ulic.life.webservice.webservice.WebserviceInterface"/> <beanMapping languageSpecificType="java:com.ulic.life.webservice.xml.CheckBillReturnResult" qname="ns:CheckBillReturnResult" xmlns:ns="urn:BeanService"/>

    <beanMapping languageSpecificType="java:java.util.ArrayList" qname="ns:ArrayList" xmlns:ns="urn:BeanService"/>
    <beanMapping languageSpecificType="java:com.ulic.life.webservice.xml.TimeoutUwPolicyDetail" qname="ns:TimeoutUwPolicyDetail" xmlns:ns="urn:BeanService"/>
    <beanMapping languageSpecificType="java:com.ulic.life.webservice.xml.TimeoutUwPolicyDetails" qname="ns:TimeoutUwPolicyDetails" xmlns:ns="urn:BeanService"/>
    <beanMapping languageSpecificType="java:com.ulic.life.webservice.xml.TimeoutUwPolicyFile" qname="ns:TimeoutUwPolicyFile" xmlns:ns="urn:BeanService"/>
    </service>
    <service name="AdminService" provider="java:MSG">
    <parameter name="allowedMethods" value="AdminService"/>
    <parameter name="enableRemoteAdmin" value="false"/>
    <parameter name="className" value="org.apache.axis.utils.Admin"/>
    <namespace>http://xml.apache.org/axis/wsdd/</namespace>
    </service>
    <transport name="local">
    <responseFlow>
    <handler type="LocalResponder"/>
    </responseFlow>
    </transport>
    <transport name="http">
    <requestFlow>
    <handler type="URLMapper"/>
    <handler type="java:org.apache.axis.handlers.http.HTTPAuthHandler"/>
    </requestFlow>
    </transport>
    </deployment>
      

  6.   

    setTimeoutUwPolicyDedail这个函数写错了,应该是setTimeoutUwPolicyDetail
    晕死了