Conditionally returning a file name?

General discussions related to APLNext's Application and Commerce WebServices and WebTransfer product.

Moderators: Tech Support, phpbb_admin

Conditionally returning a file name?

Postby Davin Church » December 30th, 2009, 6:56 pm

Ok, I'm trying to get around one of my other problems by returning a document-filename from my web code. The problem is that sometimes I want to pass back a file name (whose contents should then be returned) and sometimes I want to ignore the filename and pass back the HTML document directly (depending on the request being made).

However, when I configure my result to include both the document and the filename, there seems to be no way to NOT pass back the filename if I decide it's not needed.

How can I conditionally pass back a file (to be determined at run-time)?
Davin Church
 
Posts: 651
Joined: February 24th, 2007, 1:46 am

Varying the result of a web service

Postby joe_blaze » February 1st, 2010, 6:37 pm

The web service concept [any web service, not just APL WebServices] employs a very simple and quite restrictive design. This means that for each virtual path there is essentially only one result type and format - the web server's response to the browser's request.

Even when a filename is returned as a server response to the web browser's request, the response is actually received by the browser as a type of html page with a special 'Run/Download/Cancel' dialog box.

So here are some options to do what you describe:
    Always return a filename but have the content of that file vary depending on the server's response function, some times the content is html and sometimes the content is a pdf or an xls or whatever.

    Always return an html web page, which can vary depending on the server's response function to include [or not include] a link to the optional file on the server which the user can then download.

    Depending on the server's response function, redirect the client's browser to other virtual paths on the same or a different web server, one of which returns a filename and one of which returns an html page.

    If the client can select html page or filename to download response type, provide two different virtual paths on a cover html page from which the user can choose to click.
[/list][/list]
joe_blaze
 
Posts: 384
Joined: February 11th, 2007, 3:09 am
Location: Box 361 Brielle, NJ 08730-0361

Re: Varying the result of a web service

Postby Davin Church » February 1st, 2010, 7:13 pm

joe_blaze wrote:Even when a filename is returned as a server response to the web browser's request, the response is actually received by the browser as a type of html page with a special 'Run/Download/Cancel' dialog box.

Are we confusing returning a file to be downloaded by the browser with using APLWS to send back the contents of a file as if it were returned HTML? I thought that a document-filename is the AWS method of returning the contents of a web page (actual result HTML) in a named file instead of an explicit result. This should never result in a "download" dialog box on the browser, since it should be plain and simple HTML coming back just as if I'd returned it explicitly.

Thanks for the other options, although most of those are exactly what I was trying to avoid by using the document-filename result.
Davin Church
 
Posts: 651
Joined: February 24th, 2007, 1:46 am

document-filename feature

Postby joe_blaze » February 13th, 2010, 7:41 am

Davin said:

Are we confusing returning a file to be downloaded by the browser with using APLWS to send back the contents of a file as if it were returned HTML? I thought that a document-filename is the AWS method of returning the contents of a web page (actual result HTML) in a named file instead of an explicit result. This should never result in a "download" dialog box on the browser, since it should be plain and simple HTML coming back just as if I'd returned it explicitly.

Joe says:

To see the client-browser-side result of using the APLWebServices 'document-filename' action, check out page 15 of the .pdf-format document attached to the following thread: http://forum.apl2000.com/viewtopic.php?t=359

You will see that using 'document-filename' causes the client-side browser to display a dialog box giving the client options on the disposition of the available content, rather than immediately filling the browser with the content of the server-side file.

Also note in this example the use of the 'document-filename-delete' action that is often associated with the 'document-filename' action. This option is used so that once the client has disposed of the content on the browser side (either by opening, saving or cancelling), the 'document-filename' file is deleted on the server side. I have found that this deletion is sometimes not immediate, but occurs 'eventually' when the server is idle. I believe that this is similar to the strategy, to avoid degrading performance, that is used for updating the APLWebServices log file, i.e. keep the log entries in memory and whenever time permits save them to the physical file.

If the APLWebServices configuration had used 'document' instead of 'document-filename' then the browser would have received the content directly without the intervening dialog box.

Personally, when designing a web application I like to use 'document-filename' which causes the dialog box, because then the result document is opened in another window. In this way the client can see the input window and the result window simultaneously and if necessary, after examining the result window, modify the input window entries, without using a back button, to generate an improved result. Having the result document in another window, also means that the client can have several results on the screen and compare them to decide on the most appropriate result.
joe_blaze
 
Posts: 384
Joined: February 11th, 2007, 3:09 am
Location: Box 361 Brielle, NJ 08730-0361


Return to APL WebServices

Who is online

Users browsing this forum: No registered users and 2 guests

cron