LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Connect to Web service through a VI

I am new to LabVIEW web service. Is there a way to connect to a web service by just programming a VI on the client side ? Is this possible ? Most of the LabVIEW examples describe connecting using only a client http browser.

 

Also, would it also be possible for 2 web services to connect and say exchange .xml files ? If yes,how can one go about doing this ?

 

Kindly advice. Thanks in advance. 

0 Kudos
Message 1 of 10
(4,870 Views)
I think you are confusing web service with something else. Can you elaborate exactly on what is it that you want to do? Also, let us know what sort of setup you have over there (with respect to licenses, development machines, client machines to run executables etc.) so we can give the most appropriate solution.
Adnan Zafar
Certified LabVIEW Architect
Coleman Technologies
0 Kudos
Message 2 of 10
(4,865 Views)

I am sorry I wasnt clear. I want to be able to transfer some data as .xml files between our server and clients. But I want to program the client side VIs in such way that there is not need to use an html browser to connect to the server. Instead the client side VIs could connect directly to the server obtain these .xml files. 

I have a LabView Professional development  machine on the server with an academic license. The client will be a stand alone application.

0 Kudos
Message 3 of 10
(4,857 Views)

Web services won't help you achieve that. Do you have a FTP server? If so, there are a few ways in which you can implement this:

1) The LabVIEW Internet Toolkit has the ability to send/retrieve files or raw data to a FTP server. Have a look at the following example which shows how you can use the FTP VIs included in the toolkit.:

Sending and Retrieving Files Programmatically through FTP

2) The DataSocket Read function has the ability to read raw text, tabbed text, and .wav files from a FTP server. I have not tried this before, so if you have any questions on this, refer to the LabVIEW help manuals. 

3) Also, you can perform windows system FTP transfers with the system exec VI. Have a look at:

Using the Windows system FTP utility from LabVIEW with the System Exec VI

 

The easiest one to use and the one which I recommend is the first option of using the FTP VIs already developed in the internet toolkit. If you have any follow up questions, be sure to post back.

 

Adnan Zafar
Certified LabVIEW Architect
Coleman Technologies
Message 4 of 10
(4,848 Views)

Thanks for the advice. I will go through the links. But I had a quick question. How safe/secure is the LabVIEW FTP feature ? Are there any ways of making the FTP safer, like the SFTP ?

 

 

0 Kudos
Message 5 of 10
(4,812 Views)

Well, I'm not sure if I get the whole story but: why should it not be possible to create a VI that is a so-called web service consumer? Just use the Import Web Service Wizard (under Tools > Import > Web Service...) for public web services or manually create a TCP connection and send an HTTP request to an endpoint that is a LabVIEW web service. There are numerous ways.

 

Unfortunately, LabVIEW does not use the standard SOAP syntax and won't create WSDL files as far as I can see, otherwise using the Import Web Service Wizard with a LV web service itself would just have been too easy...

On the other hand, a LV web service responds to very straight forward http://host/servicename/function/paramA/paramB HTTP GET requests. Creating a valid request inside a VI, without a web browser, is not too difficult and the server response = web service method result can surely be an XML document.

 

Anyway, in either case I just don't see the need for FTP to retrieve a simple XML file from a server.

 

Cheers,

Hans
0 Kudos
Message 6 of 10
(4,800 Views)

@Shriku:

 

FTP is inherently insecure. As the messages are not encrypted, anyone along the way can inspect them. If your data is at all sensitive, FTP should only be used on a secure network. SFTP is an excellent alternative, however using it in LabVIEW can currently be cumbersome. The best way right now would be to install a command line sftp utility and use the SystemExec VI to drive it.

 

I'm working towards improving LabVIEW in this area. When I have something to show for my experiments I'll put it up on NI Labs.

 

@HJPhilippi:

 

It is possible and not difficult to make a VI that would be a client for your LV 8.6 Restful web service. You could either use the TCP prims and make a client from scratch as you suggested or you could use the HTTP client in the internet toolkit. You might check if the OpenG project has an HTTP client that could be used for this purpose.

 

I agree that it is unfortunate that LabVIEW 8.6 did not support SOAP or WSDL generation. There is a significant amount of work to implement SOAP. The Restful API was a good first step and for many use cases is more natural than SOAP. We are working on improving that the web services feature and an important part of that is making LabVIEW able to easily call its own web services.

 

Thanks,

 

Nathan

Message Edited by NathanK on 02-03-2009 10:34 AM
0 Kudos
Message 7 of 10
(4,789 Views)

Thanks for the information, based on which we are planning to stick to Web Service.  I had a question regarding this.

 

 

How can one go about transfering data ( arrays or tables for instance ) between the client and the web service ?  Is there a limit on the size of the data that can be sent across ?

 

 

0 Kudos
Message 8 of 10
(4,769 Views)

You can use HTTP POST and PUT methods to transfer data from the client to the web service.

The postdata can be accessed in the web method VI using the Read Postdata.vi (on the Web Services) palette.

There is not a limit on the size of data that the web service can send back to the client, but there is a 1 MB (on the desktop) and 64 KB (on RT targets) limit on the size of the data that can be sent from the client to the web service through an HTTP PUT or POST request.

 

You can override this limit by adding the following lines to your niwebserver.conf file on the server:

LimitRequestBody  <limit on the data size>

This line allows you to specify a limit great than zero and less than 2 GB.

0 Kudos
Message 9 of 10
(4,734 Views)

...and I was just about to figure out, how much data could be transferred as URI in a GET request.

🙂

 

@Anita: Sometimes you don't see the forest for the trees and forget about the functions of the web service palette. Thanks for pointing this out!

I've just tried it out and modified the http Get Document.vi from the OpenG toolkit to upload data to a LV web service with a POST request, which simply returns the data length. Works great, although I haven't verified the size limitations yet.

 

@shriku: have a look at the OpenG toolkit HTTP section to get more info on this. And it's helpfull if not necessary to know at least some basics of the HTTP protocoll to leverage web services in general.

 

Cheers,

Hans
0 Kudos
Message 10 of 10
(4,701 Views)