Web Service Cache

7 11 2007

I was working on my as3 web service package today and I decided to implement a class for caching service results. This feature is optional and it’s turned off as a default.

This feature can come in handy if you’re calling a method from a service with the same parameter(s) more than once. If it’s enabled, the cache object will store the results in an array for faster access later on, no need to send the same SOAP request again to the service.

I think using this feature is better than relying on the browser’s cache because what I’ve learned in the past is that the browser’s cache is in some cases turned off by the user.

This neat little feature will be part of my next release (soon i hope) of the web service package for actionscript 3. In the meantime, you can download my latest release from the link under “Downloads” on the right panel.

Advertisements




Web Service in AS3, Release 1.0

27 10 2007

I completed what seems like a stable version of my web service class. It’s been tested on 3 different services and has been successful in calling methods in each of those 3 services. Some features in this class are:

  • Queued service calls: Methods will be executed in the order they are called in.
  • Assign callbacks: You can assign a function to execute for every service call you make when the response has loaded.
  • Automatic SOAP requests: The class will build and send the SOAP requests for you, no need to create chunks of XML manually.

Here’s come example code using a sample webservice taken from “Advanced ActionScript 3 with Design Patterns” book:

import alducente.services.WebService;
import flash.events.*;

var ws:WebService = new WebService();
ws.addEventListener(Event.CONNECT, connected);
ws.connect("http://ws.cdyne.com/ip2geo/ip2geo.asmx?WSDL");

function connected(evt:Event):void{
 ws.ResolveIP(done, "192.168.0.125", 0);
}

function done(serviceRespone:XML):void{
 trace("Web Service Result: ");
 trace(serviceRespone);
}

Being able to call web service methods easily was the first thing on my mind while building this object. As you can see above, all you need to do is call a method in the object which would have the same name as the method you are trying to call in the web service. The first parameter would be the function you want called when the response is loaded and everything else are the parameters that method is expecting.

Click here to download the package!





Web Service in AS3, part 2

26 10 2007

***UPDATE: CLICK HERE to read the latest about this subject and to download the completed web service class***

As I mentioned in yesterday’s post, I was able to grab service information from a web service including available methods and the parameters needed for each one. Today I was able to use that data and create a SOAP request at runtime. I hope to test out the request by sending it to the service and waiting to see what I get back, but that will have to wait until tomorrow.





Web Service in AS3

25 10 2007

***UPDATE: CLICK HERE to read the latest about this subject and to download the completed web service class***

I haven’t been doing much with AS3 so I thought I would do a little experiment. Considering that I’ve been reading up on ASP.NET, I thought it would be good to figure out if AS3 has done anything new with the web service component. After searching the help files and doing a couple searches, I found out that Adobe did do something new…they got rid of it.

After reading some blogs and tutorials, accessing web services takes a little bit more than I’m used to. Now you must create a SOAP request manually, which is a little too much work if you’re working on a big project that’s heavy on web services.

That being said, I’ve been working on my very own web service class which will be able to call web service methods by specifying the method name and the required parameters. SOAP requests will be created at runtime which should minimize the amount of work needed.

As of this post, I’ve been able to successfully grab the available methods in a web service, along with every method’s required parameters. I’ll be using this data to create SOAP requests at runtime whenever a service method is called.

I’ll be posting more about this class as I build it out.