LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to use Read Postdata?

Hello,

 

I try to write a web service program and I want to receive some string data from the client, but I don't know how to use the Read Postdata.vi, any one can help?

 

NathanL1989

0 Kudos
Message 1 of 4
(2,905 Views)

Hi NathanL,

 

Please describe in more detail exactly what you are trying to accomplish. Off hand I would suggest looking into ReadFormData.vi as an alternative. Also please upload the files you have thus far so I can reporduce where you are running into trouble.

Patrick H | National Instruments | Software Engineer
0 Kudos
Message 2 of 4
(2,881 Views)

Hello,

 

I try to write a web service program and I want to receive some string data from the client, but I don't know how to use the Read Postdata.vi, any one can help?

 

NathanL1989


To receive some data in "Read Postdata.vi", you should deploy the vi having "Read Postdata.vi" as POST method.

Then you cannot post data to a service by typing a URL in browser. Instead use POST.vi in LabVIEW or use HTML forms to post some data.

 

1. Create a project

2. Create a vi as below and add to the project

Read Postdata.png

Note: Connect the "httpRequestID", "httpRequestID out" to connector pane terminals.

3. Create a Web Service (RESTful) from Build specification.

4. Goto Web Service->Properties

5. Add this vi to Service vi in "Source files" tab

6. Configure the URL Mapping in "URL Mapping" tab

7. Select POST in HTTP method. (This setting is most important)

8. Build and Deploy the service.

9. Now create a vi as below.

Post data.png

10. Fill in the IP address and other data. For more details on how to get these details please visit http://www.ni.com/white-paper/7350/en 

11. You will get the posted data in the vi deployed as Web service.

(To check whether the data is being posted successfully or not, write the posted data to a file other than desktop in vi that is deployed as Web service.)

 

Anand kumar SP
Senior Project Engineer
Soliton Technologies Pvt Ltd
0 Kudos
Message 3 of 4
(2,863 Views)

Thanks to Anand for that thorough walk-through.  I have been struggling with similar issues.  I have one further question:

In step 6, Anand said "Configure the URL Mapping in "URL Mapping" tab".  For the example snippet that Anand posted, what would the URL mapping look like?

 

Do I need to create a map to the "httpRequestID" controls and indicators?  Should I use ":/" to denote the control?

 

To further clarify my question, when I have done simpler Web Services projects, I have written to the controls in the URL, as show in this tutorial: http://zone.ni.com/reference/en-XX/help/371361J-01/lvhowto/build_web_service/ 

In that case, I created a URL Map like this: /add/:a/:b, where "a" and "b" were controls.  When using the Web Services VIs, however, I can't figure out how to connect my URL Map to the "httpRequestID" control.

 

Any advice is appreciated!

 

Luke

0 Kudos
Message 4 of 4
(2,828 Views)