Part II will include a custom function to create your URL, an example of a feeder script to manage the process, and an explanation of why the Guest account is necessary.
In Part I of this series, I explained how to trigger a server-side script using XML. In this part, I’m going to give you a custom function to aid this process and explain why you need to enable the Guest account.
First, the Guest account. To access the XML engine on the FileMaker Server by a browser, a user will always be taken to a login page, with one exception. That exception is if the Guest account is turned on. Since there’s no browser involved in the Insert from URL script step, and not way to auto-login, there’s no way to access the Server with anything but Guest.
If you don’t have a need for Guest for anything but this, it opens a little security hole, but that can be mitigated. There’s several ways to do this, but I’ll only give one method. First, turn off all Extended Privileges except Access via XML Web Publishing (fmxml). Then give all “No Access” to everything except the scripts you’re going to call by XML and the opening script and closing scripts. All those scripts and their called sub scripts should be run with “Full Access” checked. That way you’re letting the scripts manage their permissions. Again, there are other ways of accomplishing this that may be more secure, depending on your solution’s needs.
I love custom functions. They make life so much easier. You don’t need a custom function to call a script via XML, but it ensures you’re syntax is correct and reduces development time.
Here’s the one I created for this:
/*XML.script.call ( script )
Calls the script specified in the parameter in the current database. This function should be placed in an Insert From URL script step. [Guest] account needs to be active and have permission to run the script specified, all other access should be limited. The script should run with Full Access privileges.
Wing Forward Solutions, LLC
http = "http://" ;
xml = "/fmi/xml/fmresultset.xml?-db=" ;
host.ip = Get ( HostIPAddress ) ;
file = Get( FileName ) ;
layout = Get ( LayoutName ) ;
layout = "&-lay=" & layout ;
view = "&-view" ;
script = "&-script=" & script ;
result = http & host.ip & xml & file & layout & view & script
<a href="http://wingforward.net/triggering-a-server-side-script-part-ii" rel='nofollow external'>Source</a>