Opentext Cordys REST Gateway用户向导


        REST(表征状态转移),是现代架构风格,消耗和暴露网络资源,REST定义使用HTTP和URI网络标准最好的实践。这个用户向导是介绍性的向导,解释在Cordys系统上如何使用REST网关。本向导帮助你配置、打包和部署REST解决方案。


在Cordys系统上配置REST Gateway组件


  1. 定位到 REST Gateway 组件 并下载REST Gateway CAP;
  2. 安装 CAP;
  3. 添加 RESTGateway.jar 到 bcp.classpath located at $Cordys_Installation_Directory/config 文件夹。

    注: The RESTGateway.jar will be available at $Cordys_Installation_Directory/com/cordys/web/rest.

  4. 创建一个 WS-AppServe服务组和服务容器,由于这里不需要连接任何数据库,你可以不选中配置数据库的选择框。
    • 附加方法(Attach the method )设置Metadata.RESTMappingDefinitionSet.RESTMappingWebServiceInterface和Services.GenerateServiceMappings.WebServiceInterfaceGenerateServiceMappings 到WS-AppServe服务租。
  5. 分配REST开发者权限给开发人员账户;
  6. 配置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>
    • Apache:
      • 添加下列行内容到cordys_apache.conf文件中,位置在$Cordys_Installation_Directory/components/webgateway/Apache;
        RewriteEngine on
        RewriteRule (^.*/restful/[^?]*$)(?<!\.wcp) $1/com.cordys.web.rest.RESTGateway.wcp [L,R]

        注: 在文件加载信息下面开始处添加上述数据。


开发REST


        开发REST,做如下操作:

  1. CUSP,点击生成REST(Generate REST)服务界面创建REST服务;
  2. 生产之后,点击测试REST(Test REST)服务,并测试。
    参考 REST Provider - Developer Guide 获取更多细节。

打包REST解决方案

打包REST解决方案,按如下提及步骤操作:

  1. 在TestREST服务下,点击下载,REST映射做为一个XML文件被下载;
  2. 在CWS项目内部,使用所下载的REST映射创建XMLStore定义对象。

    注: XML存储定义 (XML Store Definition) 应该被部署到 /Cordys/servicemapping/resttosoap 文件夹。

    这样使打包REST映射能部署到另外一个生产系统上。

部署REST解决方案


  1. 如上所描述片段,在Cordys系统上配置REST;
  2. 安装包含REST映射地市 CAP;
  3. 在 CUSP上,点击 TEST REST 测试服务;
  4. 点击Activate激活REST映射;
  5. 点击 Show查看REST映射。


监控JMX设置


        在JMX设置,通过你能监控REST网关(REST Gateway)性能,有三个计数器,你能观察花费处理请求的总时间。

  • Request Processing Counter::显示处理REST请求的时间花费,也包括持续请求转换时间
  • Response Creation Counter:显示创建REST响应的时间花费(包括响应转换)

       除了这些,Cordys Connector是一个托管组件,这个组件被用于发送请求到XMLStore,这个被用于监控发生XMLStore读的性能。


限制


  1. 从REST资源开通链接到相关连资源是不可能的;
  2. 从产生REST服务界面( Generate REST Services UI)删除REST映射是不可能的。

       删除REST映射要做如下操作:

  1. 打开XML Store浏览器( XMLStore Explorer)。
    1. 定位到 /Cordys/servicemapping/resttosoap 并删除不需要的资源;
    2. 删除 /Cordys/servicemapping/soaptorest文件夹。
  2. 打开 Test REST Services.
  3. 点击 Activate重新产生 /Cordys/servicemapping/soaptorest 和子目录;
  4. 在Test Rest Service界面上,点击 Show观看映射。

问题解答


  • 使用http请求失败状态吗是405Method Not Allowed,那么,你必须配置web服务允许此方法使用,大多数web服务默认允许http方法是get和post。

相关内容