I have a C# webservice that returns a 2D array data. Since we cannot have webservices return multi dimensional data, i made it to return a jagged array.
[OperationContract]
object[][] WSGetData();
I have a COM Visible C# class library. This is a thin layer which consumes this service and provides it as it is to Excel VBA clients. (For certain reasons, we chose not go via VSTO, or Web Services References Toolkit routes.)
class Wrapper
{
public object[][] GetData()
{
return WSproxy.WSGetData(); //Calling the webservice method
}
}
I call the method in VBA as below.
Dim data as Variant
data = wrapperObj.GetData();
I get a Type Mismatch error.
When I changed the Wrapper class to convert the webservice's 'jagged array' output to a multi dimensional output (ie. object[,]) before returning to VBA, it works fine. But I do not want to do this, because it would affect performance as we will be passing around huge data.
What is the best way to achieve this, please. Thanks for any directions..
Jagged Arrays are possible. I don't think VBA likes the way you've declared your variant. You probably need to declare it as a Variant array. See the below example: