2011-12-23 79 views
1

我使用axis2實現web服務。 我面臨的問題是在其中一種方法中返回一個複雜的結構。 這是我想做的事:axis2中的複雜類型 - 地圖

作爲返回類型 - Map<String, Pair[]>其中對被

public class Pair { 

     private String key; 
     private String value; 
........... 
} 

IM用了SoapUI

測試它和回報永遠是空的 這裏是一個簡單的反應我得到

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"> 
    <soapenv:Body> 
     <ns:getSNSTrendsResponse xmlns:ns="http://soap.sso.vwdcrm.app.mailprofiler.com"> 
     <ns:return xsi:type="ax211:SNSData" xmlns:ax212="http://util.java/xsd" xmlns:ax211="http://objects.soap.sso.vwdcrm.app.mailprofiler.com/xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 
      <ax211:errorCode>1</ax211:errorCode> 
      <ax211:errorMessage xsi:nil="true"/> 
      <ax211:pairsResponse xsi:type="axis2ns2:anyType"> 
       <empty xmlns="http://www.w3.org/2001/XMLSchema">false</empty> 
      </ax211:pairsResponse> 
      <ax211:response xsi:nil="true"/> 
     </ns:return> 
     </ns:getSNSTrendsResponse> 
    </soapenv:Body> 
</soapenv:Envelope 

其中pairResponse應該包含結果...

回答

2

在編譯期間,Java泛型(與陣列類型相反)將被擦除,因此Axis Map<String, Pair[]>Map的作用相同。

在Java SOAP中表示鍵到對象映射的常用方法是使用其中對象包含其鍵的數組。

在你的情況,如果你的地圖索引值爲Pair.key值,那麼使用Pair[]應該工作。