flash cs4 and web service


I'm a novice coder, and am trying to get flash to connect
to a webservice. I think I've got the connection :-) but
am unable to view the info, and after viewing various
tutorials and forums and completely stuck.

I have attached the fla which I hope will help.

And below the actionscript alone.

Who is Participating?
blue-genieConnect With a Mentor Commented:
if you have access to the developers, just find out what if any parameters are expected.
try calling the  method without any parameters.. if you connect successfully just trace the result to see what format it is in.
sybrand01Author Commented:

just to confirm, I am trying to show "UKJackpotEstimate"
from the webservice "http://www.virtualworlddirect.com/elotterywebservice/lotteryservices.asmx?wsdl"
in flash, fla and code above.


hi your flash file is not attached.
are you using AS3 or AS2? are you using any existing component or classes?
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

I havent done anything where Flash connects straigh to a SOAP service but I figure if it gets too tricky you could write a server side proxy script to handle the SOAP communication and then use a more AS3-supported data format between your server and Flash. Most server side languages have native (or add-on) support for SOAP, and it should be a pretty straightforward process to send and recieve envelopes. As a bonus, you may also control (server-side) who is authorized to use the data, if ever needed.

You probably already read it, but a quick googling resulted in this:

It looks like AS3 and SOAP works quite well, even though it seems (only scanned through results briefly) it is more of a workaround than a real solution since AS3 XML doesnt really like namespaces.

Good luck!
xml in AS3 uses the ECMAScript Specs - hence  E4X so you can handle namespaces.

I use SOAP services on a daily basis with flash, but in order to point the asker to the right direction, need to know what he's currently doing.
sybrand01Author Commented:
hi  experts :-)

sorry the actionscript and fla seem to have gone?
Here they are again.
import mx.services.WebService;
import mx.services.PendingCall;
function WebServiceCall(input:String) {

var outputField:TextField
var returnedValue:String;
var wsURL:String = "http://www.virtualworlddirect.com/elotterywebservice/lotteryservices.asmx?wsdl";
var ws:WebService = new WebService(wsURL);
var re:PendingCall = ws.LotteryGetAllDetails(UKJackpotEstimate);
re.onResult = function(result):Void {

returnedValue = result;
outputField.text = result;
trace("Jackpot is "+returnedValue);
callback = ws.LotteryGetAllDetails(UKJackpotEstimate);
callback.onResult = function(result){
      trace("result obtained");
      trace("result: " + result);
      TextField_txt.text = result;

re.onFault = function(fault) {

returnedValue = fault.faultCode+","+fault.faultstring;
   trace("fault.faultcode= " + fault.faultcode);
   trace("fault.faultstring= " + fault.faultstring);
   trace("fault.detail= " + fault.detail);
   trace("fault.element= " + fault.element);
   trace("fault.faultactor= " + fault.faultactor);
   trace( "-------------------" );
   trace( response );


// show UKJackpotEstimate”

Open in new window

hello. where is UKJackpotEstimate declared?
I swapped out to one of my webservices and it works fine so i'm thinking

1. UKJackpotEstimate value ... check that - tried hard code an expected value - see what happens.
sybrand01Author Commented:
thanks blue-genie, I'm glad to know it connects. :-)
I don't understand what/ you mean 'where is UKJackpotEstimate declared'
or where to hard code an expected value?
you have this




what is UKJackpotEstimate??? I don't see it in your code snippet.
sybrand01Author Commented:
That is in the http://www.virtualworlddirect.com/elotterywebservice/lotteryservices.asmx?wsdl file.
LotteryGetAllDetails is the section and UKJackpotEstimate the figure I'm trying to view.?
as far as I know, that's not how it works. unless there's a short cut no one told me about.

you call the function you want

in this case LotteryGetAllDetails .. i can't access it remotely to check if that expects any parameters.

you then get the data back, depending on how the webservice was done. we usually use xml, then in flash i take the xml and parse it to get the value i want.
sybrand01Author Commented:
I don't have access to change the webservice.
Is there a different way I can show the UKJackpotEstimate
from http://www.virtualworlddirect.com/elotterywebservice/lotteryservices.asmx?wsdl 
you mentioned as3 ECMAScript earlier, is this a different way?
or will I need to contact the developers and get them to
change the service to xml?
sybrand01Author Commented:
Thats it sorted, extra parameters, runs perfect now :-)
thanks blue genie
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.