在axis2 - Map中的复杂类型 [英] complex types in axis2 - Map

查看:179
本文介绍了在axis2 - Map中的复杂类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用axis2实现Web服务。
我面临的问题是在一个方法中返回一个复杂的结构。
这是我想要做的:



作为返回类型 - Map< String,Pair []> where对是

  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:SNSDataxmlns:ax212 =http://util.java/xsdxmlns:ax211 =http://objects.soap.sso.vwdcrm。 app.mailprofiler.com/xsdxmlns: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应该包含结果...


解决方案

Java泛型(与数组类型相反)在编译期间被清除,因此对于Axis Map< String ,对[]> Map 相同。



在Java SOAP中表示关键对象映射的方法是使用对象包含其键的数组。



在您的情况下,如果您的地图由 Pair.key 值,然后使用 Pair [] 应该可以工作。


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...

解决方案

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.

这篇关于在axis2 - Map中的复杂类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆