PDA

View Full Version : WebServices in .as Class, doesnot send operation


nirth
05-10-2006, 06:49 PM
Hello board
I've encountered some problem with working with WebService and Operation classes in .as Classes.

i'm tring to get this work like this

//in class
private var __mxna:WebService = new WebService();
private var __byCategory:Operation;
....
//in constructor
__mxna.wsdl = "http://weblogs.macromedia.com/mxna/webservices/mxna2.cfc?wsdl";
__mxna.useProxy = false;
__byCategory = __mxna.getPostsByCategory;
__byCategory.addEventListener(ResultEvent.RESULT,o nResult);
__byCategory.addEventListener(FaultEvent.FAULT,onF ault);
__byCategory.send(20,0,4,"1");
/* i also tried like this
* __byCategory.arguments= [20,0,4,"1"];
* __byCategory.send();
*/

and nothing really happens, but if i do same thing in MXML

<mx:WebService
id="mxna"
useProxy="false" wsdl="http://weblogs.macromedia.com/mxna/webservices/mxna2.cfc?wsdl" >
<mx:operation name="getPostsByCategory">
<mx:request xmlns="">
<limit>20</limit>
<offset>0</offset>
<categoryId>4</categoryId>
<languageIds>"1"</languageIds>
</mx:request>
</mx:operation>
</mx:WebService>

every thing works just fine, but i dont get what should i do to get it done in AS?

hangalot
05-11-2006, 09:10 AM
with beta3 the source came along, go look at how they implement that tag. i would say that is your best bet at the moment

nirth
05-11-2006, 01:44 PM
heh, that's was my first action, but when i opened "C:\Program Files\Adobe\Flex Builder 2.0 Beta 3\Flex SDK 2.0\frameworks\source\mx\rpc" directory i found only one interface there ( IResponder.as )...i have strong feeling that i missing something very important in as code. I've already tried diferent variations but it just dont getting result\fault at all.

hangalot
05-11-2006, 01:56 PM
nah the source is here:

D:\Program Files\Adobe\Flex Builder 2.0 Plug-in Beta 3\Flex SDK 2.0\frameworks\source

hangalot
05-11-2006, 02:12 PM
sorry i was a tit. let me find it quickly

hangalot
05-11-2006, 02:16 PM
ok it ain't in there. post this on flexcoders, an adobe engineer will deal with it. we did it all the time in flex 1.5 so it not being possible would be a gutblow

nirth
05-11-2006, 02:19 PM
thanks alot for directions, will do

nirth
05-12-2006, 04:05 PM
heh, i forgot to load WSDL document first, i had to use loadWSDL(url:String) method before sending operation.

hangalot
05-12-2006, 04:08 PM
aah, feck i should have checked that. a word of warning about that, in flex 1.5 (as in flash) you have to listen to the wsdl load complete event before you make any calls, i doubt this would have changed in flex2.

nirth
05-12-2006, 04:15 PM
yeah this works like this now


//constructor
__mxna.wsdl = "http://weblogs.macromedia.com/mxna/webservices/mxna2.cfc?wsdl";
__mxna.useProxy = false;
__mxna.addEventListener(LoadEvent.LOAD,onLoad);
__mxna.loadWSDL("http://weblogs.macromedia.com/mxna/webservices/mxna2.cfc?wsdl")

private function onLoad(evt:LoadEvent):void {
__byCategory = __mxna.getPostsByCategory;
//TODO: remove this line
__byCategory.send(20,0,4,"1");
__byCategory.addEventListener(ResultEvent.RESULT,o nResult);
__byCategory.addEventListener(FaultEvent.FAULT,onF ault);
}

hangalot
05-12-2006, 04:21 PM
yeah thats exactly what we do in flex 1.5. have a look out for the fast framework. its a servicelocator and a set of proxy services that abstract away wether the wsdl has been loaded or not. this is as2 but would be a worthwhile adaption.

as a side note, in flash 8< and flex 1.5 wasn't very strict, now if there are any errors in the xsd or any specific type that you are passing you will get a much more accurate exception, so build error handeling from the begining is my advice

nirth
05-12-2006, 04:29 PM
yeah thats exactly what we do in flex 1.5. have a look out for the fast framework. its a servicelocator and a set of proxy services that abstract away wether the wsdl has been loaded or not. this is as2 but would be a worthwhile adaption.

ty for advice


as a side note, in flash 8< and flex 1.5 wasn't very strict, now if there are any errors in the xsd or any specific type that you are passing you will get a much more accurate exception, so build error handeling from the begining is my advice

Yeah i'm tring to get this habbit(building error handeling)