PDA

View Full Version : Trouble with WebService directly using Actionscript


mudabbas
09-23-2009, 12:39 AM
Hi,

I have decided to connect to my web service directly using action script instead of writing it in mxml. I dont see any error. I am sure my web service response fine. but it is not getting into the bytesRecieved function. Can anyone please tell me if there is a problem in my code?


public function PWImage(imgId:int)
{
super();
var webServ:WebService = new WebService();
webServ.wsdl = "http://localhost/PWTestWebService/Service.asmx?WSDL";
var operation:Operation = new Operation(webServ, "ReadBinaryFile");
operation.addEventListener(FaultEvent.FAULT, faultEvent);
operation.addEventListener(ResultEvent.RESULT, bytesRecieved);
operation.send(imgId);
}

private function bytesRecieved(in_event:ResultEvent):void
{

////............
}

angerbee
12-01-2009, 09:00 PM
Did you figure this out? I'm in the same boat.

Did you try trace(webServ.ready);? It returns a bool that "Specifies whether the WebService is ready to make requests." I cannot get mine to say true.

mudabbas
12-01-2009, 09:10 PM
Yes, I figured that out. It didn't work when I used it directly in actionscript. But it did work when I moved it back to mxml tag. You would have to figure out the way, if you want to make sure the class is converted to a component.

<mx:WebService id="webService1"
wsdl="http://localhost/PWTestWebService/Service.asmx?WSDL" showBusyCursor="true" fault="Alert(event.fault.faultString)">
<mx:operation name="ReadBinaryFile"
result="bytesRecieved(event);"
fault="faultEvent(event);" />
</mx:WebService>

JustinJDW
12-04-2009, 01:56 AM
Have you tried initializing the WebService instance?var webServ:WebService = new WebService();
webServ.wsdl = "http://localhost/PWTestWebService/Service.asmx?WSDL";
webServ.initialized(this, "myWebService");
and then use the Operation class from the mx.rpc.soap.mxml package not the mx.rpc.remoting package.

It should work. I do this all the time with the RemoteObject which is essentially the AMF implementation.