8 Replies Latest reply on Nov 29, 2007 10:48 PM by fdrt3

    Webservice gode generation and Mashalling errors

    fdrt3
      Hi. I got multiple problems using the webservice stub generator. I'm using a very simple webservice to do a login.
      The return value is a complex type (UserDTO).

      Try to use a simple call like:

      private function requestPhotos():void {
      var loginService:LoginEndpointService = new LoginEndpointService();
      var loginUserParameter:LoginUser = new LoginUser();
      loginUserParameter.String_1 = "user";
      loginUserParameter.String_2 = "password";
      loginUserParameter.String_3 = "mandator";
      loginUserParameter.String_4 = "en_US";
      loginService.loginUser( loginUserParameter );
      }

      Then you'll see that:

      1. Wrong code is produced (it even does not compile).
      I'm using a complex return type and the code that is generated is wrong.

      Try to use the WSDL at the bottom to check the compile problems:
      BaseLoginEndpointService.as :
      line 229: var arrayTypedClass:Class = SchemaTypeRegistry.getClass(currentOperation.outputMessage.parts[0].type);
      "1061: Aufruf für eine möglicherweise nicht definierte Methode getClass über einen Verweis mit statischem Typ Class."

      line 125: BaseLoginEndpointServiceService.getPort("BaseLoginEndpointServicePort").binding.portType. addOperation(logoutUser);SchemaTypeRegistry.registerClass(new QName(" http://dtos.pub.endpoints.maxtrading.com/jaws","UserDTO"),generated.webservices.UserDTO);
      "1061: Aufruf für eine möglicherweise nicht definierte Methode registerClass über einen Verweis mit statischem Typ"

      line 126: SchemaTypeRegistry.registerClass(new QName(" http://pub.endpoints.maxtrading.com/jaws","logoutUser"),generated.webservices.LogoutUser);
      "1061: Aufruf für eine möglicherweise nicht definierte Methode registerClass über einen Verweis mit statischem Typ"

      private function _loginUser_populate_results(event:ResultEvent):void
      {
      var e:LoginUserResultEvent = new LoginUserResultEvent();
      e.result = event.result as UserDTO;
      loginUser_lastResult = e.result;
      dispatchEvent(e);

      }

      should be something like:

      private function _loginUser_populate_results(event:ResultEvent):void
      {
      var e:LoginUserResultEvent = new LoginUserResultEvent();
      e.result = event.result as LoginUserResponse;
      loginUser_lastResult = e.result as UserDTO;
      dispatchEvent(e);

      }


      2. After fixing the bugs, I get a marshalling errors when using the stubs:

      TypeError: Cannot marshall type ' http://www.w3.org/2001/XMLSchema::LoginUser' to simple content.
      at mx.rpc.xml::SchemaMarshaller/marshall()[E:\dev\flex_3_beta2\sdk\frameworks\projects\rpc\s rc\mx\rpc\xml\SchemaMarshaller.as:76]
      at mx.rpc.xml::SchemaManager/marshall()[E:\dev\flex_3_beta2\sdk\frameworks\projects\rpc\src\ mx\rpc\xml\SchemaManager.as:339]
      at mx.rpc.xml::XMLEncoder/marshallBuiltInType()[E:\dev\flex_3_beta2\sdk\frameworks\projects\ rpc\src\mx\rpc\xml\XMLEncoder.as:126]
      at mx.rpc.soap::SOAPEncoder/marshallBuiltInType()[E:\dev\flex_3_beta2\sdk\frameworks\project s\rpc\src\mx\rpc\soap\SOAPEncoder.as:786]
      at mx.rpc.xml::XMLEncoder/encodeType()[E:\dev\flex_3_beta2\sdk\frameworks\projects\rpc\src\m x\rpc\xml\XMLEncoder.as:1420]
      at mx.rpc.soap::SOAPEncoder/encodeType()[E:\dev\flex_3_beta2\sdk\frameworks\projects\rpc\src \mx\rpc\soap\SOAPEncoder.as:733]
      at mx.rpc.xml::XMLEncoder/encode()[E:\dev\flex_3_beta2\sdk\frameworks\projects\rpc\src\mx\rp c\xml\XMLEncoder.as:74]
      at mx.rpc.soap::SOAPEncoder/encode()[E:\dev\flex_3_beta2\sdk\frameworks\projects\rpc\src\mx\ rpc\soap\SOAPEncoder.as:676]
      at mx.rpc.soap::SOAPEncoder/encodePartValue()[E:\dev\flex_3_beta2\sdk\frameworks\projects\rp c\src\mx\rpc\soap\SOAPEncoder.as:583]
      at mx.rpc.soap::SOAPEncoder/encodeMessage()[E:\dev\flex_3_beta2\sdk\frameworks\projects\rpc\ src\mx\rpc\soap\SOAPEncoder.as:534]
      at mx.rpc.soap::SOAPEncoder/encodeOperationAsDocumentLiteral()[E:\dev\flex_3_beta2\sdk\frame works\projects\rpc\src\mx\rpc\soap\SOAPEncoder.as:373]
      at mx.rpc.soap::SOAPEncoder/encodeBody()[E:\dev\flex_3_beta2\sdk\frameworks\projects\rpc\src \mx\rpc\soap\SOAPEncoder.as:316]
      at mx.rpc.soap::SOAPEncoder/encodeEnvelope()[E:\dev\flex_3_beta2\sdk\frameworks\projects\rpc \src\mx\rpc\soap\SOAPEncoder.as:178]
      at mx.rpc.soap::SOAPEncoder/encodeRequest()[E:\dev\flex_3_beta2\sdk\frameworks\projects\rpc\ src\mx\rpc\soap\SOAPEncoder.as:154]
      at generated.webservices::BaseLoginEndpointService/call()[E:\Projekte\flex\F3GSE Part I - Simple RIA\generated\webservices\BaseLoginEndpointService.as:176]
      at generated.webservices::BaseLoginEndpointService/loginUser()[E:\Projekte\flex\F3GSE Part I - Simple RIA\generated\webservices\BaseLoginEndpointService.as:144]
      at generated.webservices::LoginEndpointService/loginUser()[E:\Projekte\flex\F3GSE Part I - Simple RIA\generated\webservices\LoginEndpointService.as:80]
      at FlickrRIA/requestPhotos()[E:\Projekte\flex\F3GSE Part I - Simple RIA\FlickrRIA.mxml:41]
      at FlickrRIA/___FlickrRIA_Button1_click()[E:\Projekte\flex\F3GSE Part I - Simple RIA\FlickrRIA.mxml:56]
      ----------------------------------------

      So... Many things that actually do not work with webservices!
      I used Flex 3 SDK Beta 2 and the lasted nighty build (188187, 19th November) to check if things getting better. (The lastest build produces even more code generation errors!)

      Please create a bug-entry if possible. The jira was down when I wrote this stuff.

      ----------------------------------------
      The used WSDL is attached to this post.
      ----------------------------------------
        • 1. Re: Webservice gode generation and Mashalling errors
          Ivascu Cristian Level 1
          Hi,

          These errors are caused by some changes in the SDK - the SchemaTypeRegistry class type changed from a static class to a dynamic one. And since the SDK is released nightly, you could update it without updating the builder.
          The problems have been fixed and will be available with the next release. In the meantime you can simply replace SchemaTypeRegistry with SchemaTypeRegistry.getInstance().

          Hope this helps,
          Cristian
          • 2. Re: Webservice gode generation and Mashalling errors
            fdrt3 Level 1
            Hi Cristian.

            Thank's for the answer, but it does not help and does not completly resolve the mentioned issues.

            1. The code-generator is still wrong for complex return types. Please see my example of the operation private function _loginUser_populate_results(event:ResultEvent):void above.

            I always have to manually change the lines so that it will compile.

            2. Yor hint with SchemaTypeRegistry is ok, but it does not make the service call working. I get this excpetion when using the generated code:

            TypeError: Cannot marshall type ' http://www.w3.org/2001/XMLSchema::LoginUser' to simple content.
            at mx.rpc.xml::SchemaMarshaller/marshall()[E:\dev\flex\sdk\frameworks\projects\rpc\src\mx\rp c\xml\SchemaMarshaller.as:76]
            at mx.rpc.xml::SchemaManager/marshall()[E:\dev\flex\sdk\frameworks\projects\rpc\src\mx\rpc\x ml\SchemaManager.as:374]
            at mx.rpc.xml::XMLEncoder/encodeType()[E:\dev\flex\sdk\frameworks\projects\rpc\src\mx\rpc\xm l\XMLEncoder.as:1421]
            at mx.rpc.soap::SOAPEncoder/encodeType()[E:\dev\flex\sdk\frameworks\projects\rpc\src\mx\rpc\ soap\SOAPEncoder.as:754]
            at mx.rpc.xml::XMLEncoder/encode()[E:\dev\flex\sdk\frameworks\projects\rpc\src\mx\rpc\xml\XM LEncoder.as:87]
            at mx.rpc.soap::SOAPEncoder/encode()[E:\dev\flex\sdk\frameworks\projects\rpc\src\mx\rpc\soap \SOAPEncoder.as:697]
            at mx.rpc.soap::SOAPEncoder/encodePartValue()[E:\dev\flex\sdk\frameworks\projects\rpc\src\mx \rpc\soap\SOAPEncoder.as:604]
            at mx.rpc.soap::SOAPEncoder/encodeMessage()[E:\dev\flex\sdk\frameworks\projects\rpc\src\mx\r pc\soap\SOAPEncoder.as:555]
            at mx.rpc.soap::SOAPEncoder/encodeOperationAsDocumentLiteral()[E:\dev\flex\sdk\frameworks\pr ojects\rpc\src\mx\rpc\soap\SOAPEncoder.as:394]
            at mx.rpc.soap::SOAPEncoder/encodeBody()[E:\dev\flex\sdk\frameworks\projects\rpc\src\mx\rpc\ soap\SOAPEncoder.as:329]
            at mx.rpc.soap::SOAPEncoder/encodeEnvelope()[E:\dev\flex\sdk\frameworks\projects\rpc\src\mx\ rpc\soap\SOAPEncoder.as:195]
            at mx.rpc.soap::SOAPEncoder/encodeRequest()[E:\dev\flex\sdk\frameworks\projects\rpc\src\mx\r pc\soap\SOAPEncoder.as:165


            ----

            So it does not work at all. Is it possible to get an update of the webservice-code-generator? And why does the marshalling does not work?

            I used the lasted build 188576 for the test.
            • 3. Re: Webservice gode generation and Mashalling errors
              Ivascu Cristian Level 1
              Hi,

              The lastResult property is correct - e.g. it should not be casted to UserDTO. If you look both in the generated code and in the wsdl definition, the return type of the loginUser operation is a complex type - loginUserResponse, which is a wrapper over the UserDTO type. We respect the definition provided in the wsdl and as such we use the same structure. The lastResult property for an operation has the same type as the event.result property.
              As for the marshalling problem, it shouldn't happen, if the SchemaTypeRegistry mappings are correct. Unfortunately I cannot duplicate this issue because I am lacking a valid endpoint - if you can expose your webservice publicly I can look into it.

              Thanks,
              Cristian
              • 4. Re: Webservice gode generation and Mashalling errors
                fdrt3 Level 1
                Hi Mr. Ivascu,

                I had a look at the generated code and could not follow your argumentation.

                I just take the code snippet for the generated operation

                private function _loginUser_populate_results(event:ResultEvent):void
                {
                var e:LoginUserResultEvent = new LoginUserResultEvent();
                e.result = event.result as UserDTO;
                loginUser_lastResult = e.result;
                dispatchEvent(e);

                }

                Within Flex 3 Beta 2, two casting errors are marked by the compiler.

                1. e.result = event.result as UserDTO;

                e is LoginUserResultEvent and e.result is generated to LoginUserResponse.

                So the cast of "event.result as UserDTO" to "LoginUserResponse" cannot be done.

                2. loginUser_lastResult = e.result;

                loginUser_lastResult is of type UserDTO but e.result is of type LoginUserResponse.

                Therefore two errors are reported. Something is wrong with the code-generation at this point.

                Can you check how the code must corrected so that it should work?
                • 5. Re: Webservice gode generation and Mashalling errors
                  Ivascu Cristian Level 1
                  Hi,

                  Sorry, it seems I checked against a newer build, where both the lastResutl and the LoginUserResultEvent.result property both were of the LoginUserResponse type, so no casting errors occured for me.
                  I will try to reproduce it on the Beta 2 release and get back at you with a fix - theoretically, from what the wsdl shows, you should have both e.result and loginUser_lastResult of the LoginUserResponse type.

                  Cristian
                  • 6. Re: Webservice gode generation and Mashalling errors
                    fdrt3 Level 1
                    Cristian,

                    look in your private messages for a link to the online-wsdl.
                    • 7. Re: Webservice gode generation and Mashalling errors
                      fdrt3 Level 1
                      Christian,

                      did you found any solution for my problem?

                      Carsten
                      • 8. Re: Webservice gode generation and Mashalling errors
                        fdrt3 Level 1
                        Hi Christian!

                        Do you still have a look at my problem? I'm blocked with this issue and cannot get any further.

                        Please tell me how I can get a working solution for Flex 3B2 or a newer build.

                        Thank you.