Reputation: 19822
Is there a way to use the soap web service classes that FLEX provides from Flash CS5?
Upvotes: 1
Views: 1314
Reputation: 39408
Here are some instructions from someone who did the same thing.
To quote some relevant passages:
First of all you need to link to the flex webservices library from flash cs5 where you can find it in the below link :
C:\Program Files (x86)\Adobe\Adobe Flash Builder 4\sdks\4.1.0\frameworks\libs
in your flash document you need first to import web services namespaces :
import mx.rpc.soap.*;
import mx.rpc.events.*;
import mx.rpc.AbstractOperation;
then when you need to call the web service you need to initialize the object then load the WSDL call, after the event Load is trigger then you can call any method from this web service :
var uNameWebService:WebService;
var serviceOperation:AbstractOperation;
CallService_btn.addEventListener(MouseEvent.CLICK, InitWebService);
function InitWebService(event:MouseEvent):void
{
Result_txt.text = "INIT"
uNameWebService = new WebService();
uNameWebService.loadWSDL("http://localhost:55166/Service1.asmx?WSDL");
uNameWebService.addEventListener(LoadEvent.LOAD, BuildServiceRequest);
}
function BuildServiceRequest(evt:LoadEvent)
{
Result_txt.text = "START"
serviceOperation = uNameWebService.getOperation("GetName");
serviceOperation.addEventListener(FaultEvent.FAULT, DisplayError);
serviceOperation.addEventListener(ResultEvent.RESULT, DisplayResult);
serviceOperation.send();
}
function DisplayError(evt:FaultEvent)
{
trace("error");
}
function DisplayResult(evt:ResultEvent)
{
var UserName:String = evt.result as String;
Result_txt.text = UserName;
}
Upvotes: 1