jeremydore
05-25-2006, 11:53 AM
Hi folks,
This is a kind of 'does anyone know if this can be done...?' question!
I'm using the WebServiceConnector to extract an array of products from an Asp.Net webservice and then save them back when changed.
After I've triggered the web service to load the products into flash I use this listener:
private function loadRes(ev:Object){
var res = ev.target.results;
var objRef:Object;
for(var i=0; i<res.length; i++){
var tempObject:Object = new Object();
tempObject.product = res[i].product;
tempObject.productID = res[i].productID;
tempObject.productType = res[i].productType;
myProductArray.push(tempObject);
}
}
This works fine and in one single web service call I have loaded an entire arrray of products into my array (myProductArray) in Flash.
HOWEVER... I can't do the same back - each item in myProductArray needs a separate call to the relevant Asp.Net web service, so the whole process is very lengthy (and asynchronous!)
The problem seems to be that Asp.Net web services will only accept parameters that aren't arrays of user-defined objects (structs)
ie. on the Asp.Net side I can write a web service that does this:[C#]
[WebMethod]
public Boolean AddProduct(string name, int productID, int productType){
SqlConnection conn = new SqlConnection(_connString);
...etc and call it for every single product
but it won't work if I do it like this:[C#]
public struct Product{
public string name;
public int productID;
public int productType;
}
[WebMethod]
public Boolean AddProducts(Product[] myProducts){
...
I realise that this is an actionscript forum but someone must be using Asp.Net and facing this problem! Any help or even commiseration of 'I have that problem too' would be much appreciated!
Thanks!
This is a kind of 'does anyone know if this can be done...?' question!
I'm using the WebServiceConnector to extract an array of products from an Asp.Net webservice and then save them back when changed.
After I've triggered the web service to load the products into flash I use this listener:
private function loadRes(ev:Object){
var res = ev.target.results;
var objRef:Object;
for(var i=0; i<res.length; i++){
var tempObject:Object = new Object();
tempObject.product = res[i].product;
tempObject.productID = res[i].productID;
tempObject.productType = res[i].productType;
myProductArray.push(tempObject);
}
}
This works fine and in one single web service call I have loaded an entire arrray of products into my array (myProductArray) in Flash.
HOWEVER... I can't do the same back - each item in myProductArray needs a separate call to the relevant Asp.Net web service, so the whole process is very lengthy (and asynchronous!)
The problem seems to be that Asp.Net web services will only accept parameters that aren't arrays of user-defined objects (structs)
ie. on the Asp.Net side I can write a web service that does this:[C#]
[WebMethod]
public Boolean AddProduct(string name, int productID, int productType){
SqlConnection conn = new SqlConnection(_connString);
...etc and call it for every single product
but it won't work if I do it like this:[C#]
public struct Product{
public string name;
public int productID;
public int productType;
}
[WebMethod]
public Boolean AddProducts(Product[] myProducts){
...
I realise that this is an actionscript forum but someone must be using Asp.Net and facing this problem! Any help or even commiseration of 'I have that problem too' would be much appreciated!
Thanks!