AS3 WSDLURIProxy Class

Many times when you are developing Flex 2.0 Applications utilizing Flex 2 Data Services you will most likely be consuming a web service in various components through out your application.

For instance: Imagine an application in which there are three different view states in the application and you have implemented a ViewStack to handle the different states. Within the ViewStack there are 3 seperate custom components. Each custom component contains a datagrid which displays data retrieved from a Web Service via a mx:WebService tag. In the Web Service tag you set the wsdl property to a specific Endpoint URI.

The only problem is that if you are working in a development enviroment and your application moves to production you will most likely need to change the wsdl destination in all of your components. This approach is fine and is also very common in simple Flex Applications which consume a webservice as a data source. A more efficient way of setting the Endpoint URI is by adding channels and destinations to the services-config.xml file located in WEB-INF\flex that the Web Service tags can point to. The WSDLProxy class adds the same functionality but in ActionScript, therefore there is no need to modify the services-config.xml.

How the WSDLURIProxy works is very simple. You set a static constant of type String to the URI of the Web Service endpoint. Next all you need to do is import the WSDLURIProxy in all of your components and set the ‘wsdl’ property in all tags to: wsdl=”{WSDLURIProxy.getEndpointURI()}”. and that’s it.

Now once your application is pushed form development to production if the Endpoint URI needs to change you can simply change the URI in the WSDLURIProxy and all of your Web Service tags will reflect the changes. Very Simple. If your working on a simple application and not using Cairngorm then this is a very useful utility.
Below I have provided links to the source code as well as complete WSDLURIProxy ASDocs.

WSDLURIProxy.as

ASDOC

{Sorry, Comments are currently Closed! }