complex types in axis2 - Map

帅比萌擦擦* 提交于 2019-12-11 12:42:12

问题


I m implementing web service using axis2. The problem i m facing is with returning a complex structure in one of the methods. Here is what i want to do:

as a return type - Map<String, Pair[]> where Pair is

    public class Pair {

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

i m testing it with SoapUI

and the return is always empty here is a simple response i got

<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

where pairResponse should contains the result...


回答1:


Java generics (contrary to arrays types for instance) are erased during compilation, thus for Axis Map<String, Pair[]> is the same thing as Map.

The usual way of representing key-to-object mapping in Java SOAP is to use an array where objects contain their key.

In your case, if your Map is indexed by Pair.key value, then using a Pair[] should work.



来源:https://stackoverflow.com/questions/8615154/complex-types-in-axis2-map

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!