3 Replies Latest reply on Nov 13, 2007 1:04 PM by Martin-R

    Help With Error in Code Generated by WSDL Wizard

    Martin-R
      I generated code using the webservice wizard, and then wrote a simple mxml file to test the code. I get this error:

      1061: Call to a possibly undefined method getClass through a reference with static type Class.

      It occurs in the following code:

      /**
      * Internal event handler to process a successful operation call from the server
      * The result is decoded using the schema and operation settings and then the
      * events get passed on to the actual facade that the user employs in the application
      * @private
      */

      private function processResult(result:Object,wrappedData:Object):void
      {
      var token:AsyncToken = wrappedData.returnToken;
      var currentOperation:WSDLOperation = wrappedData.operation;
      var decoder:SOAPDecoder = new SOAPDecoder();


      decoder.resultFormat="object";
      decoder.ignoreWhitespace = true;
      decoder.makeObjectsBindable=true;
      decoder.wsdlOperation = currentOperation;
      decoder.schemaManager = currentOperation.schemaManager;


      var body:Object = result.message.body;
      var stringResult:String = String(body);

      if (stringResult == null || stringResult == "")
      return;


      var soapResult:SOAPResult = decoder.decodeResponse(result.message.body);
      if (soapResult.isFault)
      {
      var faults:Array = soapResult.result as Array;

      for each (var soapFault:Fault in faults)
      {
      var soapFaultEvent:FaultEvent = FaultEvent.createEvent(soapFault,token,null);
      token.dispatchEvent(soapFaultEvent);
      }
      } else {
      result = decoder.decodeResponse(result.message.body).result;


      if (result is ArrayCollection)
      {
      //shoud upcast to specific type here
      var arrayTypedClass:Class = SchemaTypeRegistry.getClass(currentOperation.outputMessage.parts[0].type);

      result = new arrayTypedClass(result.source);
      }


      var event:ResultEvent = ResultEvent.createEvent(result,token,null);
      token.dispatchEvent(event);
      }
      }

      The statement where the error occurs is in bold above. The comment above that line says I should upcast to a specific type here, but I don't know what that means. Which specific type? How do I determine what type to upcast to?

      Any help would be appreciated.

      TIA,
      Randy
        • 1. Re: Help With Error in Code Generated by WSDL Wizard
          Martin-R Level 1
          Can anybody help me with this? Please...
          • 2. Re: Help With Error in Code Generated by WSDL Wizard
            Ivascu Cristian
            Hi Martin,

            From the error you showed it seems you have upgraded your SDK version, but not the builder. The problem you are experiencing comes from the fact that the one of the SDK classes (the SchemaTypeRegistry) has been updated from a static to a dynamic class. Therefore, using the getClass() call on it will not work any more. Also, the lines that register type mappings won't work.
            We've updated the generated code, but it seems you are running on an older version. Now, to fix your code you have to:
            1. Locate all occurences where the SchemaTypeRegistry class is called as a static class.
            2. Replace the SchemaTypeRegistry part from the method calls with SchemaTypeRegistry.getInstance(), like this:
            SchemaTypeRegistry.registerClass(params) becomes SchemaTypeRegistry.getInstance().registerClass(params)

            The problem is that when you re-generate the code you will have to re-do all these changes again.

            Hope this helps,
            Cristian
            • 3. Re: Help With Error in Code Generated by WSDL Wizard
              Martin-R Level 1
              Thanks, Cristian. That solved the problem.

              BTW, I'm using the nightly build of the SDK for 10/31/2007. Is there a better one?

              Any chance we can get an updated version of the wizard that generates correct code?

              Thanks,
              Randy