你这样肯定是不行的,你不明确的告诉系统,他怎么可能知道你ArrayList里面是什么对象呢?他不知道是什么东西,当然就不能够反序列化(deserialize)了。你还是自己写一个类,封装一下你要返回的信息吧。写个bean就OK了。

解决方案 »

  1.   

    请问一下,我应该怎么去写这个BEAN呢?同时还应该怎么样去做一些设置呢?
    象我知道下面这种类型,在WSDL中,方法doGoogleSearch的参数类型为一个复合类型,所以我们在WSDL中定义好,然后我们写一个相应的javabean(GoogleSearchResult.java)来实现这个这个复合类型:
     <types>
        <xsd:schema xmlns="http://www.w3.org/2001/XMLSchema" 
                    targetNamespace="urn:GoogleSearch">
                
          <xsd:complexType name="GoogleSearchResult">
            <xsd:all>
              <xsd:element name="documentFiltering"           type="xsd:boolean"/>
              <xsd:element name="searchComments"              type="xsd:string"/>
              <xsd:element name="estimatedTotalResultsCount"  type="xsd:int"/>
              <xsd:element name="estimateIsExact"             type="xsd:boolean"/>
              <xsd:element name="resultElements"              type="typens:ResultElementArray"/>
              <xsd:element name="searchQuery"                 type="xsd:string"/>
              <xsd:element name="startIndex"                  type="xsd:int"/>
              <xsd:element name="endIndex"                    type="xsd:int"/>
              <xsd:element name="searchTips"                  type="xsd:string"/>
              <xsd:element name="directoryCategories"         type="typens:DirectoryCategoryArray"/>
              <xsd:element name="searchTime"                  type="xsd:double"/>
            </xsd:all>
          </xsd:complexType>
        </xsd:schema>
      </types> 
    <!---------------------Port -------------------------------->
      <message name="doGoogleSearchResponse">
        <part name="return"         type="typens:GoogleSearchResult"/>           
      </message><!--------------- Port for Google Web APIs, "GoogleSearch" -------------------->
      <portType name="GoogleSearchPort">
        <operation name="doGoogleSearch">
          <input message="typens:doGoogleSearch"/>
          <output message="typens:doGoogleSearchResponse"/>
        </operation>
      </portType>,但是如果我的这个返回值类型为ArrayList或者Vector时,我应该怎么样来定义我的WSDL呢?
      

  2.   

    SOAP(简单对象访问协议)----它支持一些简单的对象类型。如果调用服务的程序是用Java开发,我们一般很喜欢使用ArrayList或者Vector。但就我手头的资料而言:目前尚不支持这两
    种类型(**个人观点**)。如果要使用需要重新实现:
     java2XMLClassName="org.apache.soap.encoding.soapenc.BeanSerializer"
     xml2JavaClassName="org.apache.soap.encoding.soapenc.BeanSerializer"

    换个角度考虑:
       Soap与语言无关,与平台无关。如何做到与语言无关呢----需要达到一个平衡点:各种语言都可以支持通用的数据类型。以Delphi为例,我们无法找到与ArrayList或者Vector对等的数据类型,当我们发布服务时,Delphi是无法调用的。我们可以选用数组。两种语言都支持。例如:
    在Apache Soap中发布如下服务:<isd:service xmlns:isd="http://xml.apache.org/xml-soap/deployment"
                 id="urn:jifangDemo">
      <isd:provider type="java"
                    scope="Request"
                    methods="findByCondition">
        <isd:java class="com.dfkj.demo.MainBusiness" static="false"/>
      </isd:provider>  <isd:faultListener>org.apache.soap.server.DOMFaultListener</isd:faultListener>  <isd:mappings>
        <isd:map encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
                 xmlns:x="urn:xml-soap-jifang-demo" qname="x:device"
                 javaType="com.dfkj.demo.sDeviceVO"
                 java2XMLClassName="org.apache.soap.encoding.soapenc.BeanSerializer"
                 xml2JavaClassName="org.apache.soap.encoding.soapenc.BeanSerializer"/>    
      </isd:mappings>    
    </isd:service>//根据条件返回机房设备的位置信息
      

  3.   

    如下定义:
    <?xml version="1.0" ?><definitions name="urn:jifangDemo" 
                 targetNamespace="urn:jifangDemo"
                 xmlns:typens="urn:xml-soap-jifang-demo"             
                 xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
                 xmlns="http://schemas.xmlsoap.org/wsdl/"
                 xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
                 xmlns:s="http://www.w3.org/2001/XMLSchema">  <!-- type defs -->
      <types>
        <s:schema targetNamespace="urn:xml-soap-jifang-demo"
                    xmlns:s9="http://www.w3.org/1999/XMLSchema"
                    xmlns="http://www.w3.org/2000/10/XMLSchema">
          <s:complexType name="device">
          <s:sequence>
            <!-- 
            <s:element minOccurs="1" maxOccurs="1" name="user_id" type="s:string"/>
            <s:element minOccurs="1" maxOccurs="1" name="user_name" type="s:string"/>
            <s:element minOccurs="1" maxOccurs="1" name="user_age" type="s:string"/>
            <s:element minOccurs="1" maxOccurs="1" name="user_sex" type="s:string"/>
            <s:element minOccurs="1" maxOccurs="1" name="user_birth" type="s:string"/>
            <s:element minOccurs="1" maxOccurs="1" name="user_isMarried" type="s:string"/>
            <s:element minOccurs="1" maxOccurs="1" name="user_hometown" type="s:string"/>        
            <s:element minOccurs="1" maxOccurs="1" name="user_address" type="s:string"/>
            -->
            <s:element minOccurs="1" maxOccurs="1" name="deviceId" type="s:string"/>
            <s:element minOccurs="1" maxOccurs="1" name="deviceName" type="s:string"/>
    <s:element minOccurs="1" maxOccurs="1" name="deviceCode" type="s:string"/>
    <s:element minOccurs="1" maxOccurs="1" name="factoryCode" type="s:string"/>
    <s:element minOccurs="1" maxOccurs="1" name="stationId" type="s:string"/>
    <s:element minOccurs="1" maxOccurs="1" name="roomId" type="s:string"/>
    <s:element minOccurs="1" maxOccurs="1" name="displayLocate" type="s:string"/>
    <s:element minOccurs="1" maxOccurs="1" name="side" type="s:string"/>
    <s:element minOccurs="1" maxOccurs="1" name="factoryName" type="s:string"/>
    <s:element minOccurs="1" maxOccurs="1" name="detailType" type="s:string"/>
    <s:element minOccurs="1" maxOccurs="1" name="professionType" type="s:string"/>
    <s:element minOccurs="1" maxOccurs="1" name="structId" type="s:string"/>
    <s:element minOccurs="1" maxOccurs="1" name="structName" type="s:string"/>
    <s:element minOccurs="1" maxOccurs="1" name="projectCode" type="s:string"/>
    <s:element minOccurs="1" maxOccurs="1" name="assetCode" type="s:string"/>
    <s:element minOccurs="1" maxOccurs="1" name="installDate" type="s:string"/>
    <s:element minOccurs="1" maxOccurs="1" name="monitorAddress" type="s:string"/>
    <s:element minOccurs="1" maxOccurs="1" name="slotNum" type="s:string"/>
    <s:element minOccurs="1" maxOccurs="1" name="imp" type="s:string"/>
    <s:element minOccurs="1" maxOccurs="1" name="elec" type="s:string"/>
    <s:element minOccurs="1" maxOccurs="1" name="powerType" type="s:string"/>
    <s:element minOccurs="1" maxOccurs="1" name="parentId" type="s:string"/>
    <s:element minOccurs="1" maxOccurs="1" name="status" type="s:string"/>
    <s:element minOccurs="1" maxOccurs="1" name="structType" type="s:string"/>
    <s:element minOccurs="1" maxOccurs="1" name="re" type="s:string"/>
    <s:element minOccurs="1" maxOccurs="1" name="locateScript" type="s:string"/>
    <s:element minOccurs="1" maxOccurs="1" name="logicLocate" type="s:string"/>
    <s:element minOccurs="1" maxOccurs="1" name="width" type="s:string"/>
    <s:element minOccurs="1" maxOccurs="1" name="height" type="s:string"/>
    <s:element minOccurs="1" maxOccurs="1" name="deep" type="s:string"/>
    <s:element minOccurs="1" maxOccurs="1" name="dataOrigin" type="s:string"/>
    <s:element minOccurs="1" maxOccurs="1" name="constructCompany" type="s:string"/>
    <s:element minOccurs="1" maxOccurs="1" name="constructDate" type="s:string"/>
    <s:element minOccurs="1" maxOccurs="1" name="completeDate" type="s:string"/>
    <s:element minOccurs="1" maxOccurs="1" name="buyDate" type="s:string"/>
    <s:element minOccurs="1" maxOccurs="1" name="xmin" type="s:string"/>
    <s:element minOccurs="1" maxOccurs="1" name="ymin" type="s:string"/>
    <s:element minOccurs="1" maxOccurs="1" name="xmax" type="s:string"/>
    <s:element minOccurs="1" maxOccurs="1" name="ymax" type="s:string"/>
    <s:element minOccurs="1" maxOccurs="1" name="msetId" type="s:string"/>
    <s:element minOccurs="1" maxOccurs="1" name="pxmin" type="s:string"/>
    <s:element minOccurs="1" maxOccurs="1" name="pymin" type="s:string"/>
    <s:element minOccurs="1" maxOccurs="1" name="pxmax" type="s:string"/>
    <s:element minOccurs="1" maxOccurs="1" name="pymax" type="s:string"/>
          </s:sequence>  
          </s:complexType>
          <s:complexType name="ArrayOfDevice">
            <s:complexContent mixed="false">
              <s:restriction base="soapenc:Array">
                <s:attribute n1:arrayType="typens:device[]" ref="soapenc:arrayType" xmlns:n1="http://schemas.xmlsoap.org/wsdl/" />
              </s:restriction>
            </s:complexContent>
          </s:complexType>                  
        </s:schema>
      </types>  <!-- message declns -->  
      <!-- 1-->
      <message name="GetFindByConditionRequest">
        <part name="station_id" type="s:string"/>
        <part name="room_id" type="s:string"/>
        <part name="struct_type" type="s:string"/>
      </message>  <message name="GetFindByConditionResponse">
        <part name="address" type="typens:ArrayOfDevice"/>
      </message>    <!-- port type declns -->
      <portType name="house">   
        <operation name="findByCondition">
          <input message="GetFindByConditionRequest"/>
          <output message="GetFindByConditionResponse"/>
        </operation>    
      </portType>  <!-- binding declns -->
      <binding name="houseSOAPBinding" type="house">
        <soap:binding style="rpc" 
                      transport="http://schemas.xmlsoap.org/soap/http"/>    
        <operation name="findByCondition">
          <soap:operation soapAction=""/>
          <input>
            <soap:body use="encoded"
                       namespace="urn:jifangDemo"
                       encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
          </input>
          <output>
            <soap:body use="encoded" 
                       namespace="urn:jifangDemo"
                       encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
          </output>
        </operation>    
      </binding>  <!-- service decln -->
      <service name="houseService">
        <port name="house" binding="houseSOAPBinding">
          <soap:address location="http://171.71.10.155:8123/soap/servlet/rpcrouter"/>
        </port>
      </service></definitions>
      

  4.   

    这里:
       <s:complexType name="ArrayOfDevice">
            <s:complexContent mixed="false">
              <s:restriction base="soapenc:Array">
                <s:attribute n1:arrayType="typens:device[]" ref="soapenc:arrayType" xmlns:n1="http://schemas.xmlsoap.org/wsdl/" />
              </s:restriction>
            </s:complexContent>
          </s:complexType>      
    我们定义数组用于传输数据
      

  5.   

    不知道怎么样情况,我测试 map 和 collection----map[]服务器端是 java 代码的,客户端是 delphi 7的。
    没有问题,只不过需要自己在 delphi 中重新组合一下。但传递数据是没有问题的。