首先AXIS提供的是Document方式的Webservice实现,而不是远程对象调用。webservice的请求和应答都是基于SOAP协议的XML。当你需要通过webservice传递一个java对象时,这个对象一定要是可序列化的,序列化之后通过Webservice传输,再另外一端收到之后进行反序列化。

解决方案 »

  1.   

    首先AXIS提供的是Document方式的Webservice实现,而不是远程对象调用。webservice的请求和应答都是基于SOAP协议的XML。当你需要通过webservice传递一个java对象时,这个对象一定要是可序列化的,序列化之后通过Webservice传输,再另外一端收到之后进行反序列化。
      

  2.   

    谢谢!再请教一下:用上述方法我实现了“查询远程多条数据记录”的功能,服务器端接到用户端的请求后,会执行查询数据库操作,然后把多条记录以一个数组的方式返回,我打开soapmonitor看到,返回的soap消息是一个标准的xml格式,就是:
    <?xml version="1.0" encoding="UTF-8"?>
    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
      <soapenv:Body>
        <ns1:getAllDangjianInfoResponse soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="urn:DangjianService3">
          <getAllDangjianInfoReturn soapenc:arrayType="ns1:Dangjian[7]" xsi:type="soapenc:Array" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
            <getAllDangjianInfoReturn href="#id0"/>
            <getAllDangjianInfoReturn href="#id1"/>
            <getAllDangjianInfoReturn href="#id2"/>
            <getAllDangjianInfoReturn href="#id3"/>
            <getAllDangjianInfoReturn href="#id4"/>
            <getAllDangjianInfoReturn href="#id5"/>
            <getAllDangjianInfoReturn href="#id6"/>
          </getAllDangjianInfoReturn>
        </ns1:getAllDangjianInfoResponse>
        <multiRef id="id3" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns2:Dangjian" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns2="urn:DangjianService3">
          <college xsi:type="soapenc:string">cs</college>
          <date xsi:type="soapenc:string">d</date>
          <name xsi:type="soapenc:string">d</name>
          <nation xsi:type="soapenc:string">d</nation>
          <sex xsi:type="soapenc:string">d</sex>
        </multiRef>
        <multiRef id="id6" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns3:Dangjian" xmlns:ns3="urn:DangjianService3" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
          <college xsi:type="soapenc:string">cs</college>
          <date xsi:type="soapenc:string">g</date>
          <name xsi:type="soapenc:string">g</name>
          <nation xsi:type="soapenc:string">g</nation>
          <sex xsi:type="soapenc:string">g</sex>
        </multiRef>
        <multiRef id="id4" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns4:Dangjian" xmlns:ns4="urn:DangjianService3" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
          <college xsi:type="soapenc:string">cs</college>
          <date xsi:type="soapenc:string">e</date>
          <name xsi:type="soapenc:string">e</name>
          <nation xsi:type="soapenc:string">e</nation>
          <sex xsi:type="soapenc:string">e</sex>
        </multiRef>
        <multiRef id="id1" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns5:Dangjian" xmlns:ns5="urn:DangjianService3" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
          <college xsi:type="soapenc:string">cs</college>
          <date xsi:type="soapenc:string">b</date>
          <name xsi:type="soapenc:string">b</name>
          <nation xsi:type="soapenc:string">b</nation>
          <sex xsi:type="soapenc:string">b</sex>
        </multiRef>
        <multiRef id="id0" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns6:Dangjian" xmlns:ns6="urn:DangjianService3" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
          <college xsi:type="soapenc:string">cs</college>
          <date xsi:type="soapenc:string">a</date>
          <name xsi:type="soapenc:string">a</name>
          <nation xsi:type="soapenc:string">a</nation>
          <sex xsi:type="soapenc:string">a</sex>
        </multiRef>
        <multiRef id="id5" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns7:Dangjian" xmlns:ns7="urn:DangjianService3" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
          <college xsi:type="soapenc:string">cs</college>
          <date xsi:type="soapenc:string">f</date>
          <name xsi:type="soapenc:string">f</name>
          <nation xsi:type="soapenc:string">f</nation>
          <sex xsi:type="soapenc:string">f</sex>
        </multiRef>
        <multiRef id="id2" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns8:Dangjian" xmlns:ns8="urn:DangjianService3" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
          <college xsi:type="soapenc:string">cs</college>
          <date xsi:type="soapenc:string">c</date>
          <name xsi:type="soapenc:string">c</name>
          <nation xsi:type="soapenc:string">c</nation>
          <sex xsi:type="soapenc:string">c</sex>
        </multiRef>
      </soapenv:Body>
    </soapenv:Envelope>
    请问:服务器端具体是怎样实现将查询的结果从一个数组形式转换成xml形式的呢?
    请高手耐心指教!确实急等回答~~谢谢!