Link to home
Start Free TrialLog in
Avatar of techques
techques

asked on

AS3 Compile error to call WS

I have a AS3 need to call 2 functions in a WS to get 2 return parameters.

But, it has

Compile Error:
1046: Type was not found or was not a compile-time constant: OperationEvent.
function onResult(e:OperationEvent):void {
function onFault(e:OperationEvent):void {
function onResult1(e:OperationEvent):void {
function onFault1(e:OperationEvent):void {

function GetStreamName(opName:String) {
   var ws = new WebService("http://[publicip]/WebService/Service.asmx?wsdl");
   var op:Operation = new Operation(ws);   
   op.addEventListener(OperationEvent.COMPLETE, onResult);
   op.addEventListener(OperationEvent.FAILED, onFault);
   op.CheckStreamName(opName);
}
 
function onResult(e:OperationEvent):void {	      
   for (var prop in e.data){
		   trace (e.data[prop]);
   }
   streamName = String(e.data);
}
   
function onFault(e:OperationEvent):void {
	trace (e.data);
	prompt.text = "Fail";
}
 
function GetOpID(opName:String) {
   var ws = new WebService("http://[publicip]/WebService/Service.asmx?wsdl");
   var op:Operation = new Operation(ws);   
   op.addEventListener(OperationEvent.COMPLETE, onResult1);
   op.addEventListener(OperationEvent.FAILED, onFault1);
   op.CheckOpID(opName);
}
 
function onResult1(e:OperationEvent):void {	      
   for (var prop in e.data){
		   trace (e.data[prop]);
   }
   OpID = String(int(e.data));
}
   
function onFault1(e:OperationEvent):void {
	trace (e.data);
	prompt.text = "Fail";
}

Open in new window

Avatar of blue-genie
blue-genie
Flag of South Africa image

are you using some external class that has an Operation and OperationEvent?
you need to import it if so.
Avatar of techques
techques

ASKER

I imported those as source files.

1046: Type was not found or was not a compile-time constant: WebServiceCall.

1180: Call to a possibly undefined method WebServiceCall.
I can import the as files.

I use http://www.wellconsidered.be/as3-webservice-component/

There are 3 methods in a webservice.

I can call the first method from AS3. However, I cannot call the 2nd and 3rd methods and have the following error:

TypeError: Error #1009: Cannot access a property or method of a null object reference.
at be.wellconsidered.services.webservice::WebServiceC all/::createSoapCall()
at be.wellconsidered.services.webservice::WebServiceC all$iinit()
at be.wellconsidered.services::Operation/loadMethod()
at be.wellconsidered.services::WebService/::executeQeuedOperations()
at be.wellconsidered.services::WebService/:nDescrExtractComplete()
at flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunctio n()
at flash.events::EventDispatcher/dispatchEvent()
at be.wellconsidered.services.webservice::WebServiceM ethodCollection/extract()
at be.wellconsidered.services::WebService/:nDescrLoaded()
at flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunctio n()
at flash.events::EventDispatcher/dispatchEvent()
at flash.net::URLLoader/flash.net:URLLoader:nComplete()
ok i've used that component before, no problems.
where are you calling the methods vs. where they are defined.
what the code is saying is it can't find what you're refering to.

Since I use Flash CS3 which does not support web service panel, I open a Flash AS2 file, add the WSDL and the webservice panel can locate the webservice and display 3 web methods in a tree view.
CheckUserRole()
CheckUserName()
CheckUserCredit()

I put the as3webservice source code with the same folder of the fla.

In the first frame, the following is the as3 code.

When I run it in Flash CS3, it has the above Error #1009.

I think it cannot find the web methods:
CheckUserName()
CheckUserCredit()

It can only find the web method: CheckUserRole()

Does as3webservice only support one web method?

Or, I did not import as3webservice properly and so it cannot recognize the other 2 web methods?




import be.wellconsidered.services.WebService;
import be.wellconsidered.services.Operation;
import be.wellconsidered.services.events.OperationEvent;
 
GetUserName("12");
 
function GetUserName(UserID:String):void {
   var ws = new WebService("http://[publicip]/WebService/Service.asmx?wsdl");
   var op:Operation = new Operation(ws);   
   op.addEventListener(OperationEvent.COMPLETE, onResult);
   op.addEventListener(OperationEvent.FAILED, onFault);
   op.CheckUserName(UserID);
}
 
function onResult(e:OperationEvent):void {       
   for (var prop in e.data){
     trace (e.data[prop]);
   }
   userName:String = String(e.data);
}
   
function onFault(e:OperationEvent):void {
 trace (e.data);
 prompt.text = "Fail";
}
 
 
GetUserCredit("12");
 
function GetUserCredit(UserID:String):void {
   var ws = new WebService("http://[publicip]/WebService/Service.asmx?wsdl");
   var op:Operation = new Operation(ws);   
   op.addEventListener(OperationEvent.COMPLETE, onResult1);
   op.addEventListener(OperationEvent.FAILED, onFault1);
   op.CheckUserCredit(UserID);
}
 
function onResult1(e:OperationEvent):void {       
   for (var prop in e.data){
     trace (e.data[prop]);
   }
   userCredit:int = int(e.data);
}
   
function onFault1(e:OperationEvent):void {
 trace (e.data);
 prompt.text = "Fail";
}

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of blue-genie
blue-genie
Flag of South Africa image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Then, how do you use as3webservice in Flash CS3 which does not support web service panel?

How do you use tempArr?

Do you know how to add as3webservice and those 3 web methods of that WSDL in Flash AS3?


i take it you got it? i dont' use the panel just do the stuff in code. Use to do that in AS2 as well.