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);

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

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

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!




12 responses

29 10 2007


first of all great work, but i have oen question , those it suport https request ?

29 10 2007

* does it support https ?

29 10 2007

Thanks gmalta, as for your https question I’m not totally sure, I built the class so I could use it for regular services built using ASP.NET (what I usually use), which I believe uses regular http. This class has not been fully tested with anything else which is why I posted it for others to use, so I know what it can and can’t do. I can’t imagine why it wouldn’t work over https, but it is an interesting question, I’ll have to look further into that. I’ll let you know if I find anything.

29 10 2007

After consulting Mark AuCoin (www.clevermongrel.com), a back-end developer, who explained to me how sending requests using https works, the answer to your question is no. Unfortunately, this class was designed for regular queries. But it’s something that I will keep in mind for the next version. Thanks for bringing that topic up, gmalta.

29 10 2007

HI alducente,

thanks 4 the quick reply, i´m really enjoying your class for a little demo (widget ) i´m doing , i will have to skip the autentication part.

Keep up the good work.


31 10 2007

Brilliant AS3 extension, unfortunately I also need the HTTPS feature to use this for all my projects. I will be looking forward to the next version 🙂

Keep up the good work.


31 10 2007

Thanks! thanks for your package.. works perfect with ASP.net!

8 11 2007

Your classes are really extremely useful us!!!
I’ve tried to use it with our java based server. Our WSDL documents are generated by X-Fire. While parsing this document there were no availble Web Service methods got:( I took a look throw your sources and it seems to be a bug in WSDL.as class. In method getBinding() there were no bindings found while parsing wsdl document. In your code service.wsdl::port.@name is compared with portType. Is it really right? I’ve modified this method in the next way:

private function getBinding(portType:String):String{
var wsdl:Namespace = __rawWSDL.namespace();
var service:XMLList = __rawWSDL.wsdl::service;
// var myPort:XMLList = service.wsdl::port.(@name == portType);
var binding:XMLList = __rawWSDL.wsdl::binding.(@type.substr(@type.indexOf(":")+1) == portType);
var addressNS:Namespace = service.wsdl::port.children()[0].namespace();
__servicePath = service.wsdl::port.addressNS::address.@location;

var bindingAmount:Number = binding.length();
if(bindingAmount == 1){
return (binding.@name);
} else if(bindingAmount >0 ) {
return binding[0].@name;

Now it seems to be work properly. I’ve test my changes with our X-fire generated WSDL documents,
http://ws.cdyne.com/ip2geo/ip2geo.asmx?WSDL document
and http://mail.yahooapis.com/ws/mail/v1.1/wsdl document.
In all this cases modificatitons works propertly 🙂

Probably this will be useful for you:)

Thanks one more time for your code!!!

Best regards,

8 11 2007

Great work Vladimir! Thank you so much for your contribution!

Again, I have only used this class with web services created in ASP.NET and had no idea how to test for other types of services as I don’t have access to them. I will add your code and give it a couple test runs, if all goes well I will release the next package with it.

Now that it’s been brought up, if anyone else has any issues with using this class please leave a comment, I’m more than happy to do my part on research.

8 11 2007

Thanks for your hard work implementing a Web Services class for AS3. It will come in handy for many of us.

18 03 2008
izms » Blog Archive » links for 2008-03-18

[…] Web Service in AS3, Release 1.0 « Carlo Alducente 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. (tags: actionscript as3 flash webservices) […]

1 07 2008
Flex - Currency Converter | import Slice.of.Infinity;

[…] worth noting is the WebService Release 1.0 by Carlo Alducente which makes it’s less than a min of consuming webservice in AS3. Date Posted: Today, 05:02 […]

%d bloggers like this: