You are here: FME Server Developer's Guide > Developing with the Web Services > FME Server Transformation Services > Example: Running a Transformation

Example: Running a Transformation

The following examples use the austinDownload sample workspace:

http://<host>/fmeserver/repositories/Samples/austinDownload.fmw/fmedatadownload/configure

HTML

Aim: To create an HTML form on your web page that allows users to set published parameters and then run a workspace. After the user clicks "Run", they are re-directed to the FME Server "success" or "failure" page.

Directions

  1. Navigate to: http://<host>/fmeserver/repositories/Samples/austinDownload.fmw/fmedatadownload/configure
  2. At the bottom of the page, expand the Developer Resources panel and copy the form:
  3. Create an empty HTML document and paste the form in. You should now have something that looks like this:
  4. Open the HTML file to see the form. Fill in the published parameters as required and click Run. The workspace runs and you are re-directed to the FME Server results page.

What is happening?

The Run button has a type=”submit”, so it posts all of the values you have defined in the input boxes back to FME Server. In this case, the HTTP request is type POST, and the data is posted to the following URL: http://localhost/fmedatadownload/Samples/austinDownload.fmw. You can see this by looking on line 11 of the code.

JavaScript

Note:  For an extensive list of interactive samples, see the FME Server Playground: http://fmeserver.com/userweb/sharper/playground/index.html

Aim: Often when writing a web application, you require more flexibility than an HTML form can provide. For example, you may want to control what happens based on the success or failure of the application, rather than simply re-directing the user to FME Server success/failure page. JavaScript, specifically AJAX, gives you that flexibility.

In this example, a workspace is run using JavaScript, and rather than re-direct the user to a web page to display the results of the translation, the HTML is returned and displayed in a simple alert dialog.

Directions

  1. Navigate to: http://<host>/fmeserver/repositories/Samples/austinDownload.fmw/fmedatadownload/configure
  2. At the bottom of the page, expand the Developer Resources panel and copy the URL.
  3. Copy the code below into a text editor and save the file as index.html.
  4. Update the pHostName = "fmeserver.com" variable to point to your FME Server host name. It should match the URL you copied in step 2.
  5. Open the HTML file and click the Run Workspace button. This runs the workspace on FME Server, returns the results of the translation, and presents the results in an alert dialog.

What is Happening?

To see what is happening line by line, step through the JavaScript code using a tool such as Chrome Developer Tools or Firebug. The JavaScript does not trigger when the page loads, but when the user clicks the Run Workspace button, which calls function runWorkspaceJavascript(). This function triggers an AJAX request to FME Server to run the job. The results of the request are handled by function onResponse().

Safe Software Inc. www.safe.com