LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to create a 404 page with LabVIEW web services?

Solved!
Go to solution
Its really because that none of you really understand webservices. Its very easy to process something called with invalid params as you call the thing you process the param and figure that the param is invalid. The problem is when the user calls something which is really not there.
0 Kudos
Message 11 of 25
(1,619 Views)

If it returns an error, it can be dealt with.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 12 of 25
(1,613 Views)
As I said its webservices. Reacts completely different than any typical labview code. Maybe it creates an error code somwhere but because you dont call any labview code with an invalid url you can not handle it with labview. Its most likely should be server setup as it is if you want to configure a 404 call with xampp or wamp.
0 Kudos
Message 13 of 25
(1,604 Views)

I think I see your point.  What you want is how to trap the invalid page request after it becomes a request, because Web Services won't generate an error.  I haven't found a solution yet.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 14 of 25
(1,593 Views)
Solution
Accepted by 1984

Hey there! It looks like this is still unanswered, so I thought I would contribute my 2 cents.

 

LVWS uses something called Appweb, and the different configuration commands can be found here.

 

The config file for the LabVIEW web server is located at Program Files(x86)\National Instruments\LabVIEW 2013\resource\webserver\niwsdebugserver.conf

If you add the following line of code, you can redirect any 404s to a custom page:

 

ErrorDocument 404 /mywebservice/404.html

 

Where you would replace mywebservice with the name of your web service.

 

I don't believe the location matters, but just in case, I added that line in the spot shown below. Hope this helps!

 

AddOutputFilter chunkFilter
ErrorDocument 404 /mywebservice/404.html
LimitRequestForm 50000000

 

 

 

Tanner B.
Systems R&D Engineer - Aerospace, Defense, and Government
National Instruments
Message 15 of 25
(1,577 Views)

THIS IS IT! Thanks a lot, works right out of the box! Worth to mention that it seems once I add the lines to the file labview had to be restarted.

 

Your first post worth a kudos! Keep it up! 🙂

 

Message 16 of 25
(1,572 Views)

No problem! It's worth mentioning that this hijacks ALL 404 pages, so if you ever have another web service you'll need to delete that line. I believe you can use some of the routing functions to make the 404's service-specific, but I haven't messed with it.

Tanner B.
Systems R&D Engineer - Aerospace, Defense, and Government
National Instruments
0 Kudos
Message 17 of 25
(1,557 Views)

A custom 404.html page is great and solves one of my requirements.

 

But, in for a penny, in for a pound....

 

Anyone know how to redirect the 404 to a VI?  In other words, I'd like the 404 error to be served by a custom VI, rather than by a static (custom) html file.  Perhaps as a catch-all or wildcard in the URL mappings.

 

I've just started digging in the AppWeb documentation myself, but it seems the functionality I'm looking for, if it exists at all, will be in the NI-specific modules, for which I have not yet found documentation.

 

thanks,

  Martin

 

 

 

0 Kudos
Message 18 of 25
(1,519 Views)

Do as Tanner-B suggested and change the debugserver settings. Create the 404 page like <mywebservice>/404

 

Then in your webservice create a web resource called "404" and there you go. 

0 Kudos
Message 19 of 25
(1,503 Views)

@1984 wrote:

Do as Tanner-B suggested and change the debugserver settings. Create the 404 page like <mywebservice>/404

 

Then in your webservice create a web resource called "404" and there you go. 


That's even easier than the solution I was building, ie have the 404.html file contain an html redirect to <mywebservice>/404vi.vi.

 

The part I'm still working on is how to recover the original Request URI.  It appears that the ErrorDocument redirect replaces the Request URI request  variable with the new URI and the original URI is not stored in the request variables.

0 Kudos
Message 20 of 25
(1,495 Views)