LabVIEW Web Development Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Calling a LabVIEW web service from C#

I don't know if this group is the best place for this, but I suppose it might be relevant if someone builds web UIs in C#.

I should probably also preface this by saying I'm far from an expert on web services. While I know the general background on them, I had no reason to actually use one before yesterday.

Anyway, that reason was a client who wanted to pass some commands from a C# program on one PC to a LV program on another. I figured this was a perfect use case for WS, built a test WS, saw that it worked and sent the details to the .NET guy, who promptly tore the whole thing down. He wants to be able to import the WS as a class in C# and that requires the service to publish a WSDL file. That makes sense, as it's the metadata of the service, but the LV WS doesn't seem to publish it.

A bit of searching and an answer comes up - The C# wizard generally works with SOAP. LV uses REST and for historical reasons there was no official way to build a WSDL file for it (apparently now there is). For the purposes of the test, I fired up Eclipse, which has a plugin to graphically edit WSDL content, but that was too late for checking with the C# guy and the LV import wizard said it would only consume SOAP files.

So, the basic question is whether there is a way to generate the WSDL file in LV, so that it can be imported as a class in C#?

I couldn't find any data when searching for it, but it seems that something is published, because if I publish the WS and then go the web server page, it does show the published WS with its methods and their details.

As a backup option, we did consider the option of them simply constructing the URLs in code, but they're not happy with the idea.


___________________
Try to take over the world!
0 Kudos
Message 1 of 3
(5,306 Views)

As you determined, WSDL is primarily associated with SOAP, while LabVIEW web services use REST. WSDL 1.0 isn't capable of describing RESTful web services, but 2.0 technically can.

The real issue here is that as I understand it, the C# tools (I'm assuming svcutil) can only import a 1.0 WSDL. So I don't believe it's possible to import a RESTful web service whether it has a WSDL or WADL (a non-standard format made specifically for REST).

I think it's appropriate to construct the URLs in code. That seems to be the expectation for consuming ASP.NET Web APIs (Microsoft's RESTful web services) as well, which also don't provide any metadata. Ideally with REST, the response contains the URLs that the client can use to, for example, retrieve an individual resource from a collection.

The web interface that shows published web services uses an internal API to list all of the available methods for a web service, but it isn't the amount of information that a WSDL provides. For example, it doesn't know anything about the output format or how POST data needs to be entered.

Message 2 of 3
(4,333 Views)

Thanks. In that case, I guess this turns into a feature request to have LV generate and publish WSDL 2.0 files, but since I don't use web services enough, I probably won't be the one to add it to the idea exchange.

I tend to agree that building the string seems easy enough (I expect that whatever string manipulation tools C# has, they should be roughly as easy to use as Format Into String), but I'm not the one who needs to be convinced of that, as I'm not the one writing that code. I'll pass along the information and a link to this thread and let them figure it out.

I don't know exactly what tool he used to import the WS, but as far as I could tell, it was integrated directly into the project environment (something along the lines of New>>Class>>Web Service, which pops up a wizard). I guess they'll try the import and if it fails (as it did when I tried it in the LV import tool, which only supports SOAP imports), I guess they'll move to creating copies of the methods and building the strings in code.


___________________
Try to take over the world!
0 Kudos
Message 3 of 3
(4,333 Views)