LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Web services with LV client

Solved!
Go to solution

A typical approach to web services is to access the host (an embedded cRIO, for example) using a client running in a browser with some JavaScript.  Has anyone implemented a LabVIEW client that calls the web services on the host?  How might this be done?

0 Kudos
Message 1 of 11
(5,710 Views)

So, I've experimented with importing web services with the Tools | Import... wizard in LV and can access a web service on the net.  In order to do this, I had to reference a WSDL file on that server.  The tool generated some new VIs, put the service in my user.lib palette, and built a client on .NET constructs.  If I am trying to access my cRIO web services, I will have no WSDL file, and I don't know how to generate a client in LV using .NET.  Are there any other methods or is the .NET approach the only available option?  Its inclusion seems odd to me.  Why could this not be done with a simple web interface VI?

0 Kudos
Message 2 of 11
(5,689 Views)

Hello kc64,

 

As discussed in our email correspondents, the information I have found out about this issue is that there isn't a LabVIEW function that will create the WSDL file. If there are other customers who would like this functionality, I would highly recommend that you file a product suggestion here.
 
As for creating a web service for an Real-Time target using REST web service, it isn't possible at this point to create a LabVIEW client for this. This web server can be intergrated though into a custom website where it can request certain values from the target. The Build web service example demonstrates the basic functionality of accessing this information from a web browser. The reason for the web service was to give our customers a way to access LabVIEW and RT targets without having to install the run-time engine on it. For your use case, is the LabVIEW run-time engine needed and if it is, could you describe the application in more detail? This will help me understand this better and to inform R&D of what customers are using this for.
 
As for building this client in LabVIEW, one of my colleagues found that a customer created a web browser in LabVIEW using .NET in order to implement this. This was close to what the WSDL VIs do after looking at them more closely.


Again, if you wouldn't mind responding this information by email, this will allow me to keep all the information in one place. For other customers who are experiencing this problem, I will provide any solution or information here to assist you with your application. If anybody has anything to add to this or any possible, please feel free to post.


Jim St
National Instruments
RF Product Support Engineer
0 Kudos
Message 3 of 11
(5,674 Views)

Jim--

 

I understand the huge value of adding the web services to the cRIO and other embedded RT targets.  The feature is so compelling that I would like to standardize on using web services as my communications channel of choice in master/slave arrangements.  If I standardize, I will want to be able to access any web services-based target using either a browser or LabVIEW.  Having to write additional code to support another type of channel to allow LV to talk to the embedded device would be very annoying.

 

I guess I have to disagree with the statement that it is not possible to generate code to allow LV to act as a web services client since it is, as you pointed out, already supported in the Tools | Import... feature.  But you must have a WSDL file to support the import.  I could mimic that design using the .NET tools to hand-craft a web services client but don't know how to register a package with .NET as seems to have been done for me automatically when the Import wizard runs.  My ideal solution from my current perspective would be to wrap a .NET registration and the other .NET calls into VIs that I can simply call without having to worry about the details of the .NET operations.

 

If you could explain the process that the Tools | Import... | Web Service... invokes so that I could mimic it manually, that would be helpful.

 

Thanks.

0 Kudos
Message 4 of 11
(5,662 Views)

Another point about .NET:  It won't run on Mac or Linux.  I don't have a need to run on those platforms but a cross-platform solution would be much better for LV in the long run.

0 Kudos
Message 5 of 11
(5,655 Views)

Hello kc64,

 

I think I might have been unclear in my previous post. Our Real-Time target do have the ability to have web services as can be seen in the knowledgebase. The web service that LabVIEW creates is called REST which stands for Representational State Transfer. This protocol allows you to pass and receive information from your target from a webpage. At this point, there isn't functionality to import this into LabVIEW to create a client for it. You can though use this service to produce a thin client or website to access this information. This example, which I have tested myself, will show you how to do this in a windows based environment. Using this example along with the knowledgebase about web services in Real-Time executable should walk you through how to implement this.

 

LabVIEW doesn't have the capability as this point to become a web services client to your cRIO. You can though import in a third party WSDL file, like you stated in your post, that will create the .NET calls to create the web service client. LabVIEW though doesn't create or have the WSDL web services for the cRIO in order to implement this. If you are looking for this type of functionality, there are different ways around this by changing the architecture to use shared variables or TCP/IP communication. Are these not viable options? If they aren't, could you explain your application in more detail so I can understand this better?

 

For the last point about web services on Mac or Linux machine, LabVIEW doesn't currently have support for this which can be seen in the Web Services FAQ. If anyone has a particular need for this, I would suggest filing a product suggestion at the link above stating this.

 

I hope this answers your questions. Also if you wouldn't mind responding to me via email, I can keep this information all together and place the final solution on the forums. Thanks.


Jim St
National Instruments
RF Product Support Engineer
0 Kudos
Message 6 of 11
(5,645 Views)

We're not converging on a solution, so I will try again.  My current project status is this:  I have a cRIO with a working RESTful web service and I can access it using my browser.  It works great.  Now, I want to access the same service using a LabVIEW client.  It has been established that LV can act as a client to a web service by the fact that it will actually generate the interface code to access the server using Tools | Import... | Web Service.  I have generated a client for an Internet accessible web service and it works.  That process, however, required a WSDL file from the server.  I don't have a WSDL file for my cRIO web service.  I can make one if absolutely necessary in order to use the web services import wizard.  Or I can write my own client in LV if I new how to register the service with .NET, which I do not.  So, it is a fact that LV can be used to build a web service client.  I seek to better understand how that may be done.

 

 

0 Kudos
Message 7 of 11
(5,631 Views)

Hello kc64,

 

I am sorry about the confusion. I am going to parse your response in the post to hopefully be more clear and answer the questions you are asking.


My current project status is this:  I have a cRIO with a working RESTful web service and I can access it using my browser.  It works great.  Now, I want to access the same service using a LabVIEW client. It has been established that LV can act as a client to a web service by the fact that it will actually generate the interface code to access the server using Tools | Import... | Web Service.  I have generated a client for an Internet accessible web service and it works.  That process, however, required a WSDL file from the server.  I don't have a WSDL file for my cRIO web service. I can make one if absolutely necessary in order to use the web services import wizard.

I have done more research on this and right now we can say that using RESTful web service by itself will not provide you the functionality to create a LabVIEW client. What we think might be possible is to create a WSDL file to access this web service but we need to talk with R&D to see about this. We know that LabVIEW doesn't have the ability to generate the WSDL file for you so you will have to create this. When I find out more information about this, I will send it your way.


Or I can write my own client in LV if I new how to register the service with .NET, which I do not.  So, it is a fact that LV can be used to build a web service client.  I seek to better understand how that may be done.

 


Yes you can and we have seen several customers do that with .NET. I also asked R&D about this and they said that you could use TCP/IP in order to get the information into LabVIEW as well. I did some research how to do this online and I found a presentation explaining how to do this as well as some code at LAVA by John Lokanis. In the notes of this example of this code, it states that there is "a VI that demonstrates how to call a LabVIEW web service from a LabVIEW VI or Application." which is exactly what you want to do.

 

I hope this information helps you and when I have more information about this, I will send it your way. Again I am sorry for the confusion.


Jim St
National Instruments
RF Product Support Engineer
0 Kudos
Message 8 of 11
(5,578 Views)
Solution
Accepted by topic author kc64

 


I have a cRIO with a working RESTful web service and I can access it using my browser.  It works great.  Now, I want to access the same service using a LabVIEW client...Or I can write my own client in LV if I new how to register the service with .NET, which I do not.  So, it is a fact that LV can be used to build a web service client.  I seek to better understand how that may be done.


 

The Native TCP VIs can make HTTP requests and call the LabVIEW Web Service Methods (http://zone.ni.com/devzone/cda/epd/p/id/3153 or http://decibel.ni.com/content/docs/DOC-2230).  Using these VIs, you can create a LabVIEW client.

 

You could also use an ActiveX Browser Control with the Navigate2 method to call Web Services:

 

navigate2_bd.png

 

WSDL files are typically used for Web Services using the SOAP protocol (Developer Zone Tutorial:  Using LabVIEW to Call SOAP Web Services).  I know that it is possible to do the same for a RESTful Web Service (LabVIEW deploy RESTful web services), but I didn't see any information for how this is done with a simple Google search  Additionally, it seemed the most other public forums rejected the idea because you just need to build an HTTP request to call a web method.

Message 9 of 11
(5,561 Views)

Smootastic--

 

Bingo!  Thanks for the several examples.  I have chosen to use the TCP VIs to implement a simple web client.  Generating the header information was the hardest part to that approach and the one example shows that clearly.  Thanks for the explanation and clarification on when WSDL is used.

 

kc64

0 Kudos
Message 10 of 11
(5,556 Views)