Testing and Debugging a Web Service on the NI Web Server (Windows)

Parent Topic: Developing Web Services

Before you publish a Web service to a target, you might want to test that clients can invoke and communicate with HTTP method VIs and static content as expected. If you notice unexpected behavior or errors, you can correct them and then test the Web service again.

Note  For more information about concepts in this topic, refer to the�Web services introduction�and�tutorial. LabVIEW Web services are available only in the LabVIEW Full Development System and the LabVIEW Professional Development System.

Workflow for Debugging a Web Service

Testing and debugging a Web service�is typically an iterative process you complete in the LabVIEW project that contains the Web service files. Complete the following steps to test and debug a Web service on the NI Web Server:

Note  In this topic, you test and debug a Web service on the NI Web Server. You can also test your Web service on the Application Web Server, refer to Testing and Debugging a Web Service on the Application Web Server.
  1. If the Web service is part of a stand-alone application, open and run any startup VIs for the application from the project.
  2. Right-click the Web service project item� in the project tree and select�Start. LabVIEW places the Web service on the NI Web Server, where it behaves as if published to a target.
  3. If you are using the NI Web Server for the first time on your computer, complete the following steps to enable and configure the NI Web Server:
    1. Click Configure NI Web Server in the Start Web Service dialog box to launch NI Web Server Configuration.
    2. For testing and debugging, choose the Simple local access configuration preset and click Next.
    3. On the Authentication page, select Log in using an admin user for server administration and create your own password. Click Next.
    4. Click Finish to apply this configuration.
    5. Switch back to the LabVIEW project and repeat step 2.
  4. Open HTTP method VIs from the project. Use standard LabVIEW debugging techniques, such as probes, breakpoints, and execution highlighting, to observe their behavior when the client invokes them.
  5. Invoke an HTTP method VI from a client, such as a web browser, using the URL mapped to the VI. You can find and copy the appropriate URL directly from the project.

    Complete the following steps to access an HTTP Method VI:
    1. Right-click the HTTP method VI�and select�Show Method URL�to display the�HTTP Method URL�dialog box.
    2. In the�Available Servers�pull-down menu, select the item that contains NI Web Server, and then click Copy URL.
    3. Close the dialog box.
      Note  The Web service does not respond to any requests from the client if the HTTP Method URL dialog box is open.
    4. Paste the URL into a web browser and replace the�{value}�variables with numeric values, such as�http://127.0.0.1:80/TutorialService/Add?b=2&a=3.
      Note  NI Web Server uses 80/443 as the default port in accordance with HTTP/HTTPS protocol. However, the port number might change if another application occupies the port. You can customize the port number in NI Web Server Configuration. Refer to Configuring NI Web Server in the NI Web Server Manual for more information on server settings like authentication, port, and remote connections.
    5. Browse to the URL.
  6. If you notice an error or finish testing the Web service, right-click the Web service project item in the project tree and select�Stop. If startup VIs for a LabVIEW stand-alone application are running, you do�not�have to stop them.
    Note  You cannot edit HTTP method VIs until you stop the debugging session because LabVIEW reserves them for execution during debugging.
  7. Edit the VIs to correct any issues you noticed.
  8. (Optional) Repeat steps 2-7 to validate your changes to the Web service files.

Related Information

Understanding the NI Web Server