I need to call a method inside web service and passing to it it's parameters from action script 3.0 can anyone help me plz? i searched all over the internet and found solutions with flex and i am not working with flex i am working with action script 3.0
I use something like this:
var request:URLRequest = new URLRequest();
request.url = 'http://example.org';
// If you're POSTing data:
request.method = URLRequestMethod.POST;
request.data = new URLVariables({ /* Your object */ });
var loader:URLLoader = new URLLoader();
loader.dataFormat = URLLoaderDataFormat.VARIABLES; // If you're using POST
try{
loader.load(request);
}catch(error:Error){
// Handle error
}
trace(loader.data); // Result
Documentation:
Here is the code that I used in one of my Flex projects...
import mx.rpc.soap.WebService;
public var service:WebService = new WebService();
override protected function initializationComplete():void
{
service.wsdl = "http://localhost:1133/YourService.asmx?wsdl"
// GetPayload is the method name you're calling on your web service
service.GetPayload.resultFormat = "e4x";
service.GetPayload.addEventListener("result", yourResultHandler);
service.GetPayload.addEventListener("fault", yourFaultHandler);
// Method to call once the WSDL is loaded
service.addventListener(LoadEvent.LOAD, loadHandler);
service.loadWSDL();
}
Then here is what happens once the WSDL is loaded
protected function loadHandler(event:LoadEvent):void
{
// send() takes the service parameters
service.GetPayload.send("Product");
}
You just need to write the two methods to handle the XML returned by your services (the data is returned in e4x format:
protected function yourResultHandler(event:ResultEvent):void
{
_messageXml = XML(event.result);
}
proteted function yourFaultHandler(event:FaultEvent):void
{
Alert.show(event.toString());
}
i have used above tchnique but i facing errors in these lines // ImthePm is a webservice public var service:imthePM= new imthePM();
- service.GetAllProjects.resultFormat = "e4x"; 2.service.GetAllProjects.addEventListener("result", yourResultHandler);
- service.addventListener(LoadEvent.LOAD, loadHandler);
- service.GetAllProjects.send();
Error: Call to possibly undifined property GetAllProjects through a reference with a static type ImthePm .
Can you help me to solve this problem
hi. you can use the web services by one of the tricky method first you make swf by compiled in flex environment which includes the import statements of webservice like import mx.rpc.webservices. now compile it you will get a swf. now you go to as3.0 and make a empty movieclip on stage and in linkage property put it import for runtime sharing and put the a.swf(ex)on textbox in sharing.now you can import the statement in your action script file import mx.rpc.webservices.and use the method same as flex. definately u will be able to access web services....