注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

FME—专业化的空间数据服务实践者

——FME的新闻发布、技术交流、教程培训、应用共享平台

 
 
 
 
 

日志

 
 

基于FME SERVER 的应用开发(二)  

2014-09-12 08:57:38|  分类: FME 开发 |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |

作者:小蒋

 

    FME  SERVER 基于SOA的架构,提供了一系列供开发者调用的服务。  FME SERVER对用户调用其服务时需要验证,提供了两种验证方式:

   1.HTTP 鉴别(用户名和密码)

       默认情况下,FME SERVER默认账户 Guest可以访问,然而,HTTP基本的用户名和密码验证方式对请求的客户端依然保持验证(比如浏览器);

   2.token service提供的token

       调用服务时用token的方式需在请求服务的时候加token参数, 例如:

        http://localhost/fmejobsubmitter/Samples/austinDownload.fmw?

token=c759eaf09e4638954f63ace0ce1b53b40f62ccb7

  

然后分享一下转换服务Transformation Services中比较常用的服务之一:任务提交服务()

fmejobsubmitter service

    请求参数:

Name

Value

Description

opt_responseformat

xml | json

Default: xml

Defines the language of the response. The text must be all lowercase.

opt_geturl

The URL to a dataset

The URL of the source dataset to be used for transformation.

opt_showresult

true | false

It indicates whether the XML/JSON responses from these three services include the FME transformation result. The default value is true if this parameter is not present.

opt_servicemode

sync | async

Toggle between synchronous and asynchronous modes of the service.

opt_requesteremail

comma-separated e-mail addresses

Addresses to which the notification e-mail messages are sent.

 

  返回要素:

Element

Child Elements

Value

Description

statusInfo

message

message string

service failure message

status

success | failure

service status

mode

sync | async

service mode

fmeTransformationResult

fmeServerResponse

FME Server response properties

FME Server response

fmeEngineResponse

FME Engine response properties

FME Engine response

email

none

E-mail addresses

Requesters’ e-mail addresses

jobID

none

job ID

The current job identifier

 

1:一个发布参数和xml返回形式

请求地址:

http://localhost/fmejobsubmitter/Samples/austinDownload.fmw?THEMES=railroad&opt_responseformat=xml

 

返回形式

<?xml version="1.0" encoding="ISO-8859-1" ?>

<serviceResponse>

<!-- Service Status Info -->

<statusInfo>

<status>success</status>

<mode>sync</mode>

</statusInfo>

<!-- Service Return -->

<fmeTransformationResult>

<fmeEngineResponse>...</fmeEngineResponse>

<fmeServerResponse>...</fmeServerResponse>

</fmeTransformationResult>

<jobID>53</jobID>

</serviceResponse>

 

 

 

例二:

异步模式请求,email地址和json换回格式.

请求:

http://localhost/fmejobsubmitter/Samples/austinDownload.fmw?opt_servicemode=async&opt_requesteremail=joe@safe.com&opt_responseformat=xml

返回要素:

{"serviceResponse": {

"email": "someone@safe.com",

"jobID": 15,

"statusInfo": {

"mode": "async",

"status": "success"

}

}}

 

例三:

   当任务成功或者失败的时候,指定通知服务主题请求方式。http://localhost/fmejobsubmitter/Samples/austinDownload.fmw?&nm_jobsuccess_topic=JOBSUBMITTER_ASYNC_JOB_SUCCESS&nm_jobfailure_topic=JOBSUBMITTER_ASYNC_JOB_FAILURE

 

c#.net 调用示例:

 

1.获取token

         WebClient client = new WebClient();
         NameValueCollection parameters = new NameValueCollection();
         parameters["user"] = userId_;
         parameters["password"] = password_;
         parameters["expiration"] = "1";
         parameters["timeframe"] = "hour";
         byte[] responseBytes = client.UploadValues(fmeUrl, "POST", parameters);
         token_ = ResponseStr(responseBytes);

2.调用fmejobsubmitter服务

         string fmeUrl = "http://" + host_ + ":" + port_ +     "/fmerest/repositories/" + repositoryName + "/" + workspaceName + "/run.xml";

         byte[] responseBytes;

         string output = "";

        

         WebClient client = new WebClient();

        

         NameValueCollection parameters = new NameValueCollection();

         parameters["token"] = token_;

              

         try

         {

            responseBytes = client.UploadValues(fmeUrl, "POST", parameters);

            output = ResponseStr(responseBytes);

         }

         catch (Exception e)

         {

            throw e;

         }

         // Parses the id and status as an example

         XmlDocument doc = new XmlDocument();

         doc.LoadXml(output);

         try

         {

            XmlNode id = doc.SelectSingleNode("serviceResponse/fmeTransformationResult/fmeServerResponse/id");

            XmlNode jobStatus = doc.SelectSingleNode("serviceResponse/fmeTransformationResult/fmeServerResponse/jobStatus");         }

         catch (Exception e)

         {

            throw e;

         }

 

如对文章有疑问,可发送邮件至jiangzp@antu.com.cn提问或讨论。

  评论这张
 
阅读(291)| 评论(0)
推荐 转载

历史上的今天

在LOFTER的更多文章

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2016