1 Reply Latest reply on Sep 4, 2009 8:29 AM by 2bEugene

    Problem: Receive java.util.hashmap from Apache Axis2 webService

    2bEugene

      Hi there,

       


      I'm new to this forum. I'm a software dev and working with Flex for a few months now.

       

      Until now I was doing well in acquiring Know-How and so on.

       


      But know I got stuck with a, in fact not that big issue. But I was Googling a lot and searching for solutions without success.

       


      We have built up an Apache Axis2 web service. At the backend we are loading data from a MySQL database and packing them into HashMaps (java.util.hashmap) to transfer them via SOAP to subscribers.

       

      For now I also want to built up a flex client, subscribing this service. I also used the Introspection Wizard (Main Menu -> Data -> "Import Web Service (WSDL)") which generated event classes, valueObject classes, the WebService and BaseWebService classes and a MapItem class (for the latter I assume the generated code should use it for a single item in the HashMap).

       


      Everything's cool, but here also the Problems come:

       

      After a successful response the result variables contained in my WebService instance simply remain NULL instead of pointing at the result set.

       

      I tried to step through the code too, and indeed, before Flex tries to encode the result I can see the raw data in a result var. So the data transfer itself works and obviously it all is about the understanding of the data type on Flex side.

       

      In one case it also happens that I get this exception:

       


      TypeError: Cannot unmarshall type 'http://www.w3.org/2001/XMLSchema::Map' from XML.
          at mx.rpc.xml::SchemaMarshaller/unmarshall()[C:\autobuild\3.3.0\frameworks\projects\rpc\src\ mx\rpc\xml\SchemaMarshaller.as:135]
          at mx.rpc.xml::SchemaManager/unmarshall()[C:\autobuild\3.3.0\frameworks\projects\rpc\src\mx\ rpc\xml\SchemaManager.as:441]
          at mx.rpc.xml::XMLDecoder/marshallBuiltInType()[C:\autobuild\3.3.0\frameworks\projects\rpc\s rc\mx\rpc\xml\XMLDecoder.as:1779]
          at mx.rpc.xml::XMLDecoder/decodeType()[C:\autobuild\3.3.0\frameworks\projects\rpc\src\mx\rpc \xml\XMLDecoder.as:1704]
          at mx.rpc.soap::SOAPDecoder/decodeType()[C:\autobuild\3.3.0\frameworks\projects\rpc\src\mx\r pc\soap\SOAPDecoder.as:772]
          at mx.rpc.xml::XMLDecoder/decode()[C:\autobuild\3.3.0\frameworks\projects\rpc\src\mx\rpc\xml \XMLDecoder.as:161]
          at mx.rpc.soap::SOAPDecoder/decodeBody()[C:\autobuild\3.3.0\frameworks\projects\rpc\src\mx\r pc\soap\SOAPDecoder.as:452]
          at mx.rpc.soap::SOAPDecoder/decodeEnvelope()[C:\autobuild\3.3.0\frameworks\projects\rpc\src\ mx\rpc\soap\SOAPDecoder.as:304]
          at mx.rpc.soap::SOAPDecoder/decodeResponse()[C:\autobuild\3.3.0\frameworks\projects\rpc\src\ mx\rpc\soap\SOAPDecoder.as:236]
          at webservice::BaseMyTrainerService/processResult()[C:\Users\Eugen\Projekte\Flex\MyTrainer\s rc\webservice\BaseMyTrainerService.as:1047]
          at mx.rpc::AsyncResponder/result()[C:\autobuild\3.3.0\frameworks\projects\rpc\src\mx\rpc\Asy ncResponder.as:84]
          at mx.rpc::AsyncRequest/acknowledge()[C:\autobuild\3.3.0\frameworks\projects\rpc\src\mx\rpc\ AsyncRequest.as:74]
          at DirectHTTPMessageResponder/completeHandler()[C:\autobuild\3.3.0\frameworks\projects\rpc\s rc\mx\messaging\channels\DirectHTTPChannel.as:409]
          at flash.events::EventDispatcher/dispatchEventFunction()
          at flash.events::EventDispatcher/dispatchEvent()
          at flash.net::URLLoader/onComplete()

       

       

       


      So far now I'm not able to access the result data in a proper way. If it helps I'll post the corresponding WSDL too.

       


      Thanks for your help!

        • 1. Re: Problem: Receive java.util.hashmap from Apache Axis2 webService
          2bEugene Level 1

          Hi again,

           

          for everyone interrested: I "solved" it by replacing Axis with BlazeDS.

           

          In the first instance I noticed a missing type declaration in the WSDL - but that wast not the root of the issue. In fact, I still don't know what exaclty the crux is.

          Normal Strings and Ints did work - even the wrapper classes - but I did not do well with set types. Maybe as an alternative: I think normal POJOs would also work (Object with a set of members; in that way also the FlexSDK interprets the HashMaps) ... well, whatever

           

          But after switching to BlazeDS the server handling got a bit easier (bought with platform dependency).

           

          A final note: If you want to stick to HashMaps pay attention that you use Strings for the Keys in HashMaps an not Ints. Flex tries to translate the Maps into Objects an has difficulties to use an Int as a Name for a member variable (whit a cipher in a String it works well).

           

          OK, i think, that's it.

           

          Bye then...