PDA

View Full Version : Webservice challenge. Getting data and returning it. Please help.


maglez
06-14-2005, 03:28 PM
Hello.

I'm stuck on this problem for several days, I need your help please.

I have a webservice with two methods. Method "GetProduct" gets some data and through method "ValidateProduct", those previous data are sent back for verification.

It seems very simple, get the data and send it back for verification.

It should be a simple code like...
//In the movie first frame
import mx.services.*

//Loading web service
webservice_Instance = new WebService("http://ipmou.dyndns.org/TestFlash/Service.asmx?wsdl");

//In a button
on(click){
//Calling method GetProducts on web service
GetProduct_WSCBO = _root.webservice_Instance.GetProduct();

//Call back from method Get if successful
GetProduct_WSCBO.onResult = function(theResult){
trace(theResult);

//Sending data back for validation
ValidateProduct_WSCBO = _root.webservice_Instance.ValidateProduct(theResul t);

//Call back for method ValidateManufacturedProduct on success
ValidateProduct_WSCBO.onResult = function(theResult){
trace("theResult: " + theResult);
}

//Call back for method ValidateManufacturedProduct on fault
ValidateProduct_WSCBO.onFault = function(fault){
trace(fault.faultCode);
}
}

//Call back from method Get if Not successful
GetProduct_WSCBO.onFault = function(fault){
trace(fault.faultCode);
}
}

Please, try this example and let me know if the result for the Validation method is true, what it should be. I have attached and fla file for testing.

Thanks a lot.

madgett
06-15-2005, 08:25 AM
There might be an issue with the webservice itself on the Validate Product method, however the first method GetProduct() works fine. Here is what I used to do the testing, just copy/paste it on the _root timeline:
import mx.services.*;
//Loading web service
webservice_Instance = new WebService("http://ipmou.dyndns.org/TestFlash/Service.asmx?wsdl");
var GetProduct_WSCBO:PendingCall = webservice_Instance.GetProduct();
GetProduct_WSCBO.onResult = function(result) {
// do something
for (var i in result) {
trace("result."+i+" = "+result[i]);
}
//Call back for method ValidateManufacturedProduct on success
trace("Sending back the object "+"{TypeName:"+result.TypeName+", Title:"+result.Title+"}");
var ValidateProduct_WSCBO:PendingCall = webservice_Instance.ValidateProduct({TypeName:resu lt.TypeName, Title:result.Title});
ValidateProduct_WSCBO.onResult = function(theResult) {
trace("theResult: "+theResult);
};
//Call back for method ValidateManufacturedProduct on fault
ValidateProduct_WSCBO.onFault = function(fault) {
trace(fault.faultstring);
};
};
GetProduct_WSCBO.onFault = function(fault) {
trace(fault.faultstring);
};

maglez
06-15-2005, 02:44 PM
From a Macromedia article

"...You may also run into problems with web services that require complex data, such as objects containing arrays, as an input parameter. If you try to pass complex data to a web service using the WebService API, you will receive an error saying that the endpoint URL could not be opened. To send complex data, use Flash Remoting. Complex data in output parameters, on the other hand, does not cause any problems...."

Full article at http://www.macromedia.com/devnet/mx/flash/articles/flmxpro_webservices.html , you'll find that note on page 3.

Thank you for your help, I really appreciate

maglez
06-15-2005, 02:50 PM
My colleagues and I was talking about this matter.

They can't understand how it can gets parameters without problem and not be able to send it back.

They insist it's deliberated, perhaps to make us get some other product like Flash Remoting.

Any way, thaks a lot to everybody.

madgett
06-20-2005, 06:45 AM
Interesting...I haven't done much research on that, I just stick to strings...I find no issues there.

What you could do is develop an mxp file with the updated classes where this bug is happening.

maglez
06-20-2005, 09:48 AM
We'll use some workaround to bypass this problem, the thing is that it's against the webservice philosophy, a technology to communicate any system no matter the operating system or the hardware. My colleagues are going to write webservices specific for Flash and that shouldn't be, webservices are suppose to be independent of the platform.

Anyway, thanks a lot for your help.