ws-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gene...@ws.apache.org
Subject [Apache Web Services Wiki] New: FrontPage/Axis/DotNetInteropMapInfo
Date Tue, 11 Jan 2005 09:06:22 GMT
   Date: 2005-01-11T01:06:22
   Editor: ToshiyukiKimura
   Wiki: Apache Web Services Wiki
   Page: FrontPage/Axis/DotNetInteropMapInfo
   URL: http://wiki.apache.org/ws/FrontPage/Axis/DotNetInteropMapInfo

   Importing old wiki ...

New Page:

##language:en
'''Q: Can you provide a recommendation of how to transport a java.util.Map to C#?'''

A: The easiest solution is to implement a typed array with a {{{JavaBean}}}.

{{{ 
   public class MapEntryVO { 
     private Object  key; 
     private Object  value; 

     public MapEntryVO() { 
     } 

     public MapEntryVO(Object key, Object value) { 
       this.key   = key; 
       this.value = value; 
     } 

     public Object getKey() { 
       return key; 
     } 
     public void setKey(Object value) { 
       key = value; 
     } 

     public Object getValue() { 
       return value; 
     } 
     public void setValue(Object value) { 
       this.value = value; 
     } 
   } 
}}}

--------------------------------------------------------------------------------

{{{
  import java.util.*;  

   public class WebServicesUtils { 
     public static MapEntryVO[] convertMapToMapEntryVO(Map conv) { 
       MapEntryVO[] result = new MapEntryVO[conv.size()]; 
       int i = 0; 
       Iterator iter = conv.entrySet().iterator(); 

       while (iter.hasNext()) { 
         Map.Entry item = (Map.Entry) iter.next(); 
         result[i++] = new MapEntryVO(item.getKey(),item.getValue()); 
       } 

       return result; 
     } 
   } 
}}}

--------------------------------------------------------------------------------

{{{
  // Example WebService  
   public class TestService { 
      public MapEntryVO[] testMethod() { 
        java.util.Map value = new java.util.HashMap(); 

        value.put("Key 1","Value 1"); 
        value.put("Key 2","Value 2"); 

        return WebServicesUtils.convertMapToMapEntryVO(value); 
      } 
   }
}}}

Mime
View raw message