Hi:
  I am working on the POJO web service in the Axis2 (version 1.2)
samples and I added a method in there to return a Map of String to
'Entry' objects. 
The new service is below:
 
AddressBookService.java
 
public Map<String, Entry[]> findEntriesByState() 
 {
  Map<String, Entry[]> stateToEntriesMap = new HashMap<String, Entry[]>(
entries.size() );
  for(Iterator iter = entries.keySet().iterator(); iter.hasNext();)
  {
   Entry value = (Entry) entries.get( iter.next() );
   if ( stateToEntriesMap.containsKey( value.getState() ) )
   {
    Entry[] entryArray = (Entry[]) stateToEntriesMap.get(
value.getState() );
    Entry[] newEntryArray = new Entry[ entryArray.length + 1] ;
    System.arraycopy( entryArray, 0, newEntryArray, 0, entryArray.length
);
    newEntryArray[ newEntryArray.length - 1 ] = value;
 
    stateToEntriesMap.put( value.getState(), newEntryArray );
   } else
   {
    stateToEntriesMap.put( value.getState(), new Entry[] { value } );
   }
  }
  System.out.println("Num Entries in STATE - 2 - ENTRY MAp?" +
stateToEntriesMap.size() );
  return stateToEntriesMap;
 }
 
  I then changed the sample client provided, AddressBookRPCClient.java,
to call this service and display the 
results. The new code added is as below:
 
AddressBookRPCClient.java
 
  /*
   Find STATE - 2 - ENTRIES Map
  */
  System.out.println("\n ** Executing Find Entries By State *** \n " );
        QName opFindEntriesByState = new QName("
http://service.addressbook.sample/xsd";, "findEntriesByState");
 

        Object[] opFindEntriesByStateArgs = new Object[0] ;
  Map<String, Entry[]> stateToEntriesProto = new HashMap<String,
Entry[]>(0);
//        Class[]  entriesByStatereturnTypesList = new Class[] {
HashMap.class };
        Class[]  entriesByStatereturnTypesList = new Class[] {
stateToEntriesProto.getClass() };
 
        Object[] entriesByStateResponse =
serviceClient.invokeBlocking(opFindEntriesByState,
                 opFindEntriesByStateArgs, 
               entriesByStatereturnTypesList);
 
  System.out.println("Find Entries By State: Num RESPONSE Entries = " + 
    (null != entriesByStateResponse ? entriesByStateResponse.length : 0
) );
  System.out.println("Find Entries By State: RESPONSE Entry class = " +
entriesByStateResponse[0].getClass()  );
 
  Map entries2StateMap = (HashMap) entriesByStateResponse[0];
  System.out.println("Num Entries in STATE - TO - ENTRIES Map:" +
entries2StateMap.size() );
 
    When I run this using 'ant rpc.client', the execution is successful
but the returned map is empty i.e. I see this in the output.
 
     [java]  ** Executing Find Entries By State ***
     [java]
     [java] Find Entries By State: Num RESPONSE Entries = 1
     [java] Find Entries By State: RESPONSE Entry class = class
java.util.HashMa
p
     [java] Num Entries in STATE - TO - ENTRIES Map:0
 
    As cen be seen from the last line, the returned Map is empty even
though there service returns a non-empty Map. This can be verified by
the system 
out on the server :
  
2007-08-16 13:29:31,504 INFO  [STDOUT] Num Entries in STATE - 2 - ENTRY
MAp? 4
 
   Any ideas how this can resolved ? Should serializers / deserializers
be specified for the Map object ?
 
   I have attached the WSDL for reference.
 
Other info:
    JRE ver:         1.5
    App Server:    JBoss 4.0.3
 
Thanx !!
Santosh
 
  
 
 
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 

Attachment: AddressBookService.wsdl
Description: AddressBookService.wsdl

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to