Opentext Cordys REST Gateway用户引导
Opentext Cordys REST Gateway用户向导
REST(表征状态转移),是现代架构风格,消耗和暴露网络资源,REST定义使用HTTP和URI网络标准最好的实践。这个用户向导是介绍性的向导,解释在Cordys系统上如何使用REST网关。本向导帮助你配置、打包和部署REST解决方案。
在Cordys系统上配置REST Gateway组件
- 定位到 REST Gateway 组件 并下载REST Gateway CAP;
- 安装 CAP;
- 添加
RESTGateway.jar
到bcp.classpath
located at$Cordys_Installation_Directory/config 文件夹。
- 创建一个 WS-AppServe服务组和服务容器,由于这里不需要连接任何数据库,你可以不选中配置数据库的选择框。
- 附加方法(Attach the method )设置Metadata.RESTMappingDefinitionSet.RESTMappingWebServiceInterface和Services.GenerateServiceMappings.WebServiceInterfaceGenerateServiceMappings 到WS-AppServe服务租。
- 分配REST开发者权限给开发人员账户;
- 配置Web服务器,做如下操作:
- 转换用户友好URIs为实际冗长的URIs,按一定规则定义,使REST URIs友好;
-
IIS:(略)
- Add the following entry to the web.config file of the Cordys web site under the configuration/system.webServer XPath.
<rewrite>
<rules>
<rule enabled=
"true"
name=
"RESTRule"
stopProcessing=
"true"
>
<match url=
"^.*/restful/[^?]*"
/>
<action type=
"Rewrite"
url=
"{R:0}/com.cordys.web.rest.RESTGateway.wcp"
/>
<conditions logicalGrouping=
"MatchAll"
>
<add input=
"{R:0}"
negate=
"true"
pattern=
".*\.wcp$"
/>
</conditions>
</rule>
</rules>
</rewrite>
- Add the following entry to the web.config file of the Cordys web site under the configuration/system.webServer XPath.
-
Apache:
- 添加下列行内容到cordys_apache.conf文件中,位置在
$Cordys_Installation_Directory/components/webgateway/Apache;
RewriteEngine on
RewriteRule (^.*/restful/[^?]*$)(?<!\.wcp) $
1
/com.cordys.web.rest.RESTGateway.wcp [L,R]
- 添加下列行内容到cordys_apache.conf文件中,位置在
开发REST
开发REST,做如下操作:
- 在CUSP,点击生成REST(Generate REST)服务界面创建REST服务;
- 生产之后,点击测试REST(Test REST)服务,并测试。
参考 REST Provider - Developer Guide 获取更多细节。
打包REST解决方案
打包REST解决方案,按如下提及步骤操作:
- 在TestREST服务下,点击下载,REST映射做为一个XML文件被下载;
- 在CWS项目内部,使用所下载的REST映射创建XML存储定义对象。 这样使打包REST映射能部署到另外一个生产系统上。
部署REST解决方案
- 如上所描述片段,在Cordys系统上配置REST;
- 安装包含REST映射地市 CAP;
- 在 CUSP上,点击 TEST REST 测试服务;
- 点击Activate激活REST映射;
- 点击 Show查看REST映射。
监控JMX设置
在JMX设置,通过你能监控REST网关(REST Gateway)性能,有三个计数器,你能观察花费处理请求的总时间。
- Request Processing Counter::显示处理REST请求的时间花费,也包括持续请求转换时间;
- Response Creation Counter:显示创建REST响应的时间花费(包括响应转换)。
除了这些,Cordys Connector是一个托管组件,这个组件被用于发送请求到XML存储,这个被用于监控发生XML存储读的性能。
限制
- 从REST资源开通链接到相关连资源是不可能的;
- 从产生REST服务界面( Generate REST Services UI)删除REST映射是不可能的。
删除REST映射要做如下操作:
- 打开XML Store浏览器( XMLStore Explorer)。
- 定位到 /Cordys/servicemapping/resttosoap 并删除不需要的资源;
- 删除 /Cordys/servicemapping/soaptorest文件夹。
- 打开 Test REST Services.
- 点击 Activate重新产生 /Cordys/servicemapping/soaptorest 和子目录;
- 在Test Rest Service界面上,点击 Show观看映射。
问题解答
- 使用http请求失败状态吗是405Method Not Allowed,那么,你必须配置web服务允许此方法使用,大多数web服务默认允许http方法是get和post。