6 Replies Latest reply on Oct 7, 2010 8:38 AM by Claudiu Ursica

    Dynamic WSDL address

    bencoderedit

      I have some web services being consumed by a flex app.

      The services were interfaced with using the Service wizard in Flash Builder. For different instances of the application I want to be able to point them to different end points. The problem being if I ever remove the original services that the code was created against they fail to load. Because every time the app runs it loads the WSDL from the location it was when I ran the Service Wizard.

       

      So I guess my question is,

      Is there any way to prevent a flex app with generated service code from trying to load the original WSDL location?

      I can change the end point by changing the sub-class for the service using:

              super._serviceControl.endpointURI = newurl;

       

      However I can't seem to force it to load the WSDL from a different location.

        • 1. Re: Dynamic WSDL address
          JoGlez

          Same Problem HERE!!!! Anyhelp is greatly appreciated!!

          • 2. Re: Dynamic WSDL address
            Claudiu Ursica Level 4

            In the web service generated super class' (the one starting with

            _CustomGeneratedYourClassName) constructor there's a line which hardcodes the

            wsdl propery.

             

            _serviceControl.service = "WhateverWebServiceName";

            _serviceControl.port = "WhateverWebServiceNameSoap";

            wsdl = "http://www.whatever.com/blahblah.asmx?wsdl";

            model_internal::loadWSDLIfNecessary();

             

            Comment out or remove thw wsdl hardocded string. Every time you call the service

            you can set a new wsdl for that and it will work. Bear in mind when you

            regenerate the service you have ot remove it again.

             

            C

            • 3. Re: Dynamic WSDL address
              JoGlez Level 1

              Sory to bother again but your help ws great!!!

               

              So.... That is exactly the line I want to change but is it possible to change the wsdl address during runtime. I would like to read it from an XML file but that can only be done after the application compiles (or so I think). So my question is if modified after compile time will it work??  Thanks!

               

               

              Edit: I just took a look at this link and they appear to have done it. http://forums.adobe.com/message/2788031#2788031 but in a more complex way.  All I want is to read the string from an xml and replace the normal wsdl (wsdl=Variable) how is this done and what should the syntax of the xml be??? Really need your help guys..

               

              Message was edited by: JoGlez

              • 4. Re: Dynamic WSDL address
                Claudiu Ursica Level 4

                Not sure I understand your question. The problem is when you generate the

                webservice you get that line by default with the hardcoded wsdl location. I

                think that prevents the call to that loadWsdlIfnecesary() because it does not

                consider it necessary anymore. So you're stucked with the hardcoded url event if

                you try to set it again when you use your service:

                 

                myservice.wsdl = "new url"; will set the new wsdl value but never use it when

                making the call:

                myservice.doSomething();

                 

                by commenting the hardcoding line and running again the same code

                myservice.wsdl = "new url";

                myservice.doSomething();

                 

                you'll get myservice to use the new wsdl.

                 

                You can load your application make a call to an xml (using UrlLoader or

                HTTPService or a diffrent webservice) get the url and store it somewhere when

                you can retrieve it later when you need to make the call to the webservice. Then

                you do something like the line above set it and make the call.

                 

                The cleanest way to go about it is to use  a framework like Parsley which let's

                you configure the wsdl string inside an external property file. From there it

                gets inside your context and then injected inside commands/delegates.

                 

                Hope this make sense and helps you,

                C

                • 5. Re: Dynamic WSDL address
                  JoGlez Level 1

                  Got It!! You were of great help!!!!!! Thanks a lot!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!


                   

                  Message was edited by: JoGlez

                  • 6. Re: Dynamic WSDL address
                    Claudiu Ursica Level 4

                    You need to take out the:

                    _serviceControl.service = "Service1";

                     

                    and it will work, the easiest way is to test for yourself

                     

                    When I had an issue with this I was developing against on a remote server and

                    then deployoing to another. The wsdl was send in through flashvars from

                    javascript so i needed to set it at runtime anyway. That is how I discovered the

                    issue in the first place, when deploying the flex application was still using

                    the wsdl from the development server instead of the new one.

                     

                     

                    C