LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

WebServices in LV. Problem with getting an array of objects from .net dll

Solved!
Go to solution

Hi,

 

I'm not quite sure is the problem connected to WebServices import function. But to present full picture I explain what I did.

 

Using Import WebServices in LV2012SP1 I created a library to do the job. I saved the library for LV2011 then. It works fine (discovering and connectig to the WebService etc).

 

But,

 

When I execute the web service which should return an array of objects (definied in the service, C# class) instead of seeing expected array of clusters I see ann array of references. Why?

 

It works perfectly when the output is one, singular object, not an array. Then the cluster is returned.

0 Kudos
Message 1 of 5
(2,501 Views)

LV can't convert .NET objects to clusters directly. I think you have to do the conversion manually by reading the properties of each .NET object in the array and storing them as cluster (maybe you have to cast the .NET object to the appropriate type before you're able to read its properties). A guess why it works an non-array type: Maybe a mapping is created between the properties of the .NET objects and the fields of the cluster during import.

0 Kudos
Message 2 of 5
(2,496 Views)

I think it does, unless the object is an array.

 

In my case, there is no problem with the auto converting class to cluster.

0 Kudos
Message 3 of 5
(2,468 Views)

As said before, I think this cluster conversion is done via creating a mapping during import. But that might not even be important. AFAIK the array object lacks type information and is treated as an array of System.Object . If that's the case LV can't know how to convert these references.

0 Kudos
Message 4 of 5
(2,464 Views)
Solution
Accepted by topic author MimiKLM

Ok,

 

Despite the fact that we have different opinions about the array and not array variables your post has helped me and pointed in the right direction. Thanks.

 

Now my code does what I want.

 

Capture.PNG

0 Kudos
Message 5 of 5
(2,445 Views)