Trying to hack the WebService Classes
November 12, 2003

Now that the Flash 7.0.1 updater has been released, I now have 30 more days on my trial of MX 2004 Pro, and I started by trying to look deeper into the WebService classes in particular. I think these are a very important set of classes, and while the WebServiceConnector component is nice, I like the idea of having run time control over connecting to web services, so these classes come in very handy. With these classes, found under:

Window -> Other Panels -> Common Libraries -> Classes

you can bypass the component and just connect to any web service (for more details, see Vera's blog entry). Here is an example connecting to a stock quote web service using just 4 lines of code!
import mx.services.*;
var myWS:WebService = new WebService(
"http://services.xmethods.net/soap/
urn:xmethods-delayed-quotes.wsdl");
var myPCall:PendingCall = myWS.getQuote("IBM");
myPCall.onResult = function(result) {trace(result);}
This is great because pretty much all you need to know is the address to the WSDL as well as something about the web service API (in this case, a method called "getQuote") and you're set.

However, after looking into this for a while (but without having any access to the source - anyone know why MM didn't ship the source for the data components?) a couple of thoughts came to mind:

1) The WSDL is being loaded and parsed at run-time to extract the data for the web service. That's additional overhead (both in time to load and bandwidth) for the Flash player that I might not want.
2) In pretty much all cases, as a developer, you will likely have to know the API (method names, parameters, return values) for a given web service that you are calling in order to actually do something with it (I know, parsing all of the data from the WSDL excuses the developer from having to know things like namespaces, etc, that the request SOAP message will need to include).

Bearing these points in mind, I wondered if it might be beneficial to be able to bypass the WSDL, and just make direct calls to the web service. Maybe the WebService class (or some other class) could implement some methods so that the developer could directly go in and set things like namespaces, webservice uri's and http header info. Of course, it isn't possible with the existing WebService classes since we don't have access to the source code. Crappy.

I know that this kinda defeats the whole purpose of WSDL (and I must admit that the WebServiceConnector is nice as it hits the WSDL at author time and returns a list of methods), but it would be nice to have the option to bypass that and go straight to the web service.

Posted by philter at 05:17 PM | Comments Disabled