斯潘8
span4
为了支持实时数据应用程序,您可能需要将数据发布到FME服务器,并触发一个将此数据作为源数据集读取的工作区。For example,您可以为可以发布传感器数据的传感器创建触发器,也可以创建自己的应用程序,将数据发布到FME服务器。
以下服务可以接受使用HTTP POST发送到FME服务器的原始数据:
1。创建一个简单的文本文件,该文件的结构表示将要发送的数据样本。在本教程附带的“示例”文件夹中,有一个非常简单的数据文件测试样品that may be used.当使用数据流服务发布到FME服务器时,稍后将调用此文本文件。
2。制作一个FME工作区,它将读取您发布给它的数据。在大多数情况下,using the Text File Reader is best.即使数据是XML或JSON,您仍然可以使用文本文件阅读器,但是您应该将reader参数read whole file一次性设置为yes。You can then parse the data further along in the workspace using the appropriate XML or JSON transformers.
三。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,可以使用“示例”文件夹,而不是创建自己的工作区。
4。将工作区发布到名为“培训”的存储库中。
5.In the last screen of the Publish to FME Server wizard,单击数据下载服务旁边的编辑按钮。
First,确保将send http message body to reader参数设置为读卡器。You will see another parameter called Include Writers in Download.确保已将此设置为文本文件编写器。
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.单击subscribe to topics参数的省略号(…)并选择receivePost主题。单击确定。Ensure the Parameter to Get Topic Message is set to Source Text File(s).
单击“确定”关闭“编辑通知服务属性”对话框。确保数据下载,Data Streaming,工作提交人,and Notification Service are selected and click Publish.
请记住,您可以使用数据上载服务将文件数据发送到您的工作区,但我们希望应用程序或服务能够直接向FME服务器发布数据。
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.您可以将此HTML文件复制到您自己的Web目录或FME服务器Tomcat根Web目录中。
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.在文本框中键入一些数据,例如:“渥太华,加拿大“,and then click Post to FME Server.您将在下面的文本框中看到FME服务器响应。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.接下来尝试使用作业提交者服务。确保将目标URL更改为源“fmejobsubmitter”而不是“fmedatastreaming”,您可以添加几个服务参数;一个指定返回格式为JSON(也可以指定XML),另一个指定异步模式:
/fmejobsubmitter/training/ReceivePost.fmw?opt_servicemode=async&opt_responseformat=json
异步模式意味着客户机不会等待作业完成,而FME服务器只返回作业ID,如下所示:
“serviceResponse”:“statusInfo”:“mode”:“异步”,"status": "success" },“工单编号”:100878
单击“发布到FME服务器”以尝试“作业提交者”服务。
11。接下来,让我们试试数据下载服务。将目标URL从“fmejobsubmitter”更改为“fmedatadownload”。如果使用异步模式,数据下载服务将返回一个网页,其中包含指向数据下载zip文件或jobid的链接。The URL to enter looks like this:
/fmedatadownload/training/ReceivePost.fmw
单击Post to FME Server测试数据下载服务。
12。You can also post data to a notification topic using the Notification service.Earlier in Step 7,发布工作区时,您在主题ReceivePost下为它创建了订阅。这意味着当我们发布到该主题时,订阅该主题的任何内容都将被触发。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?令牌=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!
嗨,肯,
In the fmerest/v2/apidoc:
我了解在FME服务器API上使用一个日志需要在请求URL和正文中的文件中使用一些查询字符串参数。
According to many documentation on the net,post应该接受主体中的参数,而不是作为查询字符串。http://www.w3schools.com/tags/ref httpmethods.asp
Does FME server accept setting these parameters in the body?
If I want to post data to a Datastreaming service,我是否可以在正文中指定已发布的参数以及要发布到我的服务的文件(我从未尝试过这样做)?
or do I have to use query strings for published parameters and the body for the file (developpers don't like to)?如果是这样,why fme server's REST API differs from REST standards?or does it?
Thanks.
JP
© 2019 亚搏在线Safe Software Inc |合法的