span8
span4
span8
span4
To support real time data applications you may want to POST data to FME Server and trigger a workspace which reads this data as a source dataset.For example, you can create triggers for sensors that can POST sensor data or you may be creating your own application which will POST data to FME Server.
The following services can accept raw data sent to FME Server using HTTP POST:
1.Create a simple text file that is structured to represent a sample of data you will be sending.In the “Samples” folder attached to this tutorial, there is a very simple data file calledSample.txtthat may be used.This text file will be called later on when posting to FME Server with the Data Streaming service.
2.Make an FME workspace that will read the data you POST to it.In most cases, using the Text File Reader is best.Even if the data is XML or JSON you can still use the Text File Reader but you should set the reader parameter Read Whole File at Once to Yes.You can then parse the data further along in the workspace using the appropriate XML or JSON transformers.
3.Add a writer to the workspace for output data which will be sent to the Data Download or Data Streaming Service.In the sample workspace attached (ReceivePost.fmw) we simply use a Text File Writer to return the same data.
Note: The sample workspace, ReceivePost.fmw, in the “Samples” folder may be used instead of creating your own workspace.
4.Publish the workspace to FME Server into a repository named “training”.
5.In the last screen of the Publish to FME Server wizard, click on the Edit button beside the Data Download Service.
First, ensure that the Send HTTP Message Body to Reader parameter is set to your Reader.You will see another parameter called Include Writers in Download.Ensure this is set to your Text File Writer.
6.Repeat the above step for the Data Streaming and the Job Submitter Services
7.Click Edit for Notification Service where the settings are bit different.Click the ellipsis (...) for the Subscribe to Topics parameter and select the ReceivePost topic.Click OK.Ensure the Parameter to Get Topic Message is set to Source Text File(s).
Click OK to close the Edit Notification Service Properties dialog.Ensure Data Downloading, Data Streaming, Job Submitter, and Notification Service are selected and click Publish.
记住哟u can use the Data Upload Service to send file data to your workspace, but we want an application or a service to be able to post data directly to FME Server.
8.In the “Samples” folder attached to this tutorial there is a PostFMEServer.html file that provides a simple web page which uses JavaScript to send data to a POST object.You can copy this HTML file into your own web directory or into the FME Server Tomcat ROOT web directory
9.Now try posting data to the different FME Server services and see the response.You will need to enter your own FME Server username and password to post data.
First try the Data Streaming service which is the default.Type some data into the text box, for example: “Ottawa, Canada”, and then click Post to FME Server.You will see the FME Server response in the text box below.Any data you post to the Data Streaming service is sent as source data to the workspace reader and then whatever the workspace writes is sent directly back.
10.Next try using the Job Submitter service.Make sure to change the Target URL to source “fmejobsubmitter” not “fmedatastreaming” You can add a couple of service parameters;one to specify the return format as JSON (XML is also possible) and one to specify asynchronous mode:
/fmejobsubmitter/training/ReceivePost.fmw?opt_servicemode=async&opt_responseformat=json
Asynchronous mode means the client will not wait for the job to complete and FME Server simply returns the the JobID like this:
{"serviceResponse": { "statusInfo": { "mode": "async", "status": "success" }, "jobID": 100878 }}
Click Post to FME Server to try out the Job Submitter service.
11.Next let’s try the Data Download service.Change the Target URL from “fmejobsubmitter” to “fmedatadownload”.The Data Download service will return a web page with a link to the Data Download zip file or the JobID if you used asynchronous mode.The URL to enter looks like this:
/fmedatadownload/training/ReceivePost.fmw
Click Post to FME Server to test the Data Download service.
12.You can also post data to a notification topic using the Notification service.Earlier in Step 7, when you published the workspace, you created a subscription for it under the topic ReceivePost.This means when we POST to that topic anything which subscribes to that topic will be triggered.Change the Target URL from “fmedatadownload” to “fmenotification”.You may need to use a security token unless you disable security on the REST service but you can try it with a URL like this:
/fmerest/v3/notifications/topics/ReceivePost/publish?token=b03050f246d741995a9e17e919eee5284896b11d
Click Post to FME Server to test the Notification service.
Congratulations!Now you’ve successfully posted data to FME Server and triggered a workspace which reads this data as a source dataset using several different FME services!
We haven't tested for max post size as we typically are posting fairly small messages.Any Tomcat configurations, such as maxPostSize would apply here.I'm not aware of any limitations at this point.
Hi Ken,
In the fmerest/v2/apidoc:
I understand that using a POST on the FME server API requires some query string parameters in the request url and the file in the body.
According to many documentation on the net, POST should accept parameters within the body and not as query string.http://www.w3schools.com/tags/ref_httpmethods.asp
Does FME server accept setting these parameters in the body?
如果我想post数据datastream数据服务, can I specify published parameters within the body together with the file I want to post to my service (I never managed to do so)?
or do I have to use query strings for published parameters and the body for the file (developpers don't like to)?If so, why fme server's REST API differs from REST standards?or does it?
Thanks.
.JP
Hi@bgeorges, Yes, using the token parameter will work if you want to trigger a secure workspace using a POST request like the one used in these examples.
Tutorial: Custom Data Delivery using FME Server
FME Server Developer Playground
Notify FME Server when a directories contents change (2013 and earlier only)
RSS Feed of FME Server Data Download Layers
Intro to Notification Service: Receiving, Inspecting and Processing Notification Messages
403 Forbidden Error When Making FME Server Request
Weather Updates and FME Server (Tutorial)
FME Server as a WebHook for littleBits
Receiving email, Part 1: Setting up a topic and an email address (2015)
© 2020 Safe Software Inc |Legal