06-25-2014 10:08 AM
06-25-2014 10:14 AM - edited 06-25-2014 10:26 AM
If it returns an error, it can be dealt with.
06-25-2014 10:47 AM
06-25-2014 12:07 PM
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.
07-02-2014 02:20 PM
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
07-02-2014 02:32 PM - edited 07-02-2014 02:34 PM
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! 🙂
07-02-2014 03:38 PM
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.
08-20-2014 01:15 PM
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
08-20-2014 01:53 PM
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.
08-20-2014 02:29 PM
@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.