级别: 中级 Naveen Sachdeva (sachdeva@us.ibm.com), IT 咨询专家, IBM Indrajit Poddar (ipoddar@us.ibm.com), 顾问软件工程师, IBM Ying Chun Guo (guoyingc@cn.ibm.com), 软件工程师, IBM
2008 年 1 月 14 日 本系列的上一篇文章概要性介绍了 IBM® WebSphere® Service Registry and Repository 和 IBM WebSphere Process Server 如何用于服务消费治理。本文将描述一些实现细节,向您介绍如何自定义 WebSphere Service Registry and Repository 来支持服务消费治理,如何使用 WebSphere Process Server 实现订阅者授权流程,以及如何使用 SOAP 接口将其与 WebSphere Service Registry and Repository 集成。
概述
WebSphere Service Registry and Repository 是一个服务元数据注册中心和存储库。它建立了一个中心点,以查找和管理从不同源中获得的服务元数据。服务元数据的一个示例是服务提供者 (SP) 和服务订阅者 (SS) 之间事先协商的成本和响应时间。WebSphere Service Registry and Repository 具有大量可针对服务提供者自定义的方面。例如,您可以使用 XML 模式定义 WebSphere Service Registry and Repository 模板来表示特定于服务提供者的契约信息。另外,还可以使用 Web Ontology Language (OWL) 定义分类级别将不同的 WebSphere Service Registry and Repository 实体关联起来。WebSphere Service Registry and Repository 还为其 UI 提供了广泛的自定义功能。与用户的组织角色对应的透视图可以在 Web UI 中定义,以提供服务元数据的自定义视图。WebSphere Service Registry and Repository 提供了添加确认和通知插件的能力,以实现自定义行为来响应存储库的内容更改。
 | |
WebSphere Process Server 是 Business Process Execution Language (BPEL) 工作流的一个容器。在 BPEL 中编写的业务流程可以作为 Web 服务导出并由其他应用程序访问;其中一个示例是使用 SOAP 接口的 WebSphere Service Registry and Repository。您可以将 WebSphere Process Server 与 WebSphere Service Registry and Repository 集成来执行工作流,以响应存储在 WebSphere Service Registry and Repository 中的元数据的状态更改。如图 1 中所示,WebSphere Process Server 中的 BPEL 流程可以由 WebSphere Service Registry and Repository 通过 WebSphere Service Registry and Repository 中用户定义的通知插件来调用。BPEL 流程进而可以使用 WebSphere Service Registry and Repository SOAP API 创建或更新 WebSphere Service Registry and Repository 中的信息。
图 1. WebSphere Process Server 和 WebSphere Service Registry and Repository 集成点
本文将介绍如何设置 WebSphere Service Registry and Repository 并将其与 WebSphere Process Server 集成,以实现上一篇文章中介绍的订阅者授权流程。
设置 WebSphere Service Registry and Repository
您可以通过向 WebSphere Service Registry and Repository 添加模板、分类、角色或透视图实现以下 WebSphere Service Registry and Repository 自定义。以下部分介绍了自定义详细信息。
模板自定义
首先,您需要为本系列文章的上一篇文章中介绍的场景定义三种 XML 模式定义 (XSD) 复杂类型(如清单 1 所示):
-
Service 表示一个服务(例如,BatchACHService:Batch Automatic check Clearing House)。
-
Batch ACH Service Subscribe Endpoint 表示与 Batch ACH Service 的不同端点相关的属性集(例如,highVolumeBatchACHServiceEP 和 lowVolumeBatchACHServiceEP)。
-
Batch ACH Service Subscribe Contract 表示服务提供者和服务订阅者之间的契约(例如,JamesHuBatchACHServiceContract)。
清单 1. 针对订阅者授权流程的 XSD 复杂类型
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema
targetNamespace="http://f49.j2b.ibm.com/1/0/template"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:sdo="commonj.sdo"
xmlns:sdoxml="commonj.sdo/xml"
xmlns:tns="http://www.ibm.com/xmlns/prod/serviceregistry/6/0/governance/SampleTaxonomy"
|-------10--------20--------30--------40--------50--------60--------70--------80--------9|
|-------- XML error: The previous line is longer than the max of 90 characters ---------|
xmlns:srsdo="http://www.ibm.com/xmlns/prod/serviceregistry/6/0/sdo">
<xsd:complexType name="Service">
<xsd:attribute name="businessOwner" type="xsd:string" />
<xsd:attribute name="availableEndpoints" type="xsd:IDREFS" />
<xsd:attribute name="providedInterface" type="xsd:IDREFS" />
<xsd:attribute name="contractTemplate" type="xsd:IDREFS"/>
<xsd:attribute name="serviceDependencies" type="xsd:IDREFS" />
</xsd:complexType>
<xsd:complexType name="Batch ACH Service Subscribe Endpoint">
<xsd:attribute name="executionCost" type="xsd:string" />
<xsd:attribute name="responseTime" type="xsd:string" />
<xsd:attribute name="maxChecksPerBatch" type="xsd:string" />
<xsd:attribute name="minChecksPerBatch" type="xsd:string" />
<xsd:attribute name="definingWSDLPort" type="xsd:IDREFS" />
</xsd:complexType>
<xsd:complexType name="Batch ACH Service Subscribe Contract">
<xsd:attribute name="responsetime" type="xsd:string" />
<xsd:attribute name="cost" type="xsd:string" />
<xsd:attribute name="email" type="xsd:string" />
<xsd:attribute name="servicename" type="xsd:string" />
<xsd:attribute name="maxChecksPerRequest" type="xsd:string" />
<xsd:attribute name="maxRequestPerHour" type="xsd:string" />
<xsd:attribute name="isTestNeeded" type="xsd:string" />
<xsd:attribute name="service" type="xsd:IDREFS" />
</xsd:complexType>
</xsd:schema>
|
通过将清单 1 中所示的 XSD 文档导入到 WebSphere Service Registry and Repository,然后将复杂类型分类为模板,您可以定义与这些复杂类型对应的 WebSphere Service Registry and Repository 模板。您可以在 WebSphere Service Registry and Repository Web UI 中查看这些模板(请参见图 2)。
图 2. 从清单 1 的复杂类型中衍生的 WebSphere Service Registry and Repository 模板
该服务模板具有以下属性:
- 属性:
businessOwner 描述服务提供者(例如,Peter Partell)。
- 关系:
availableEndpoints 描述可以访问该服务的端点(例如,http://serviceprovider.com:9080/service/highVolumeBatchACH 和 http://serviceprovider.com:9080/service/lowVolumeBatchACH)。
- 关系:
providedInterface 描述针对该服务的 Web 服务描述语言 (WSDL) 接口(例如,BatchACHServiceWSDL.xml)。
- 关系:
contractTemplate 描述服务提供者和服务订阅者之间的契约模板(例如,一个 WebSphere Service Registry and Repository 概念:JamesHuBatchACHServiceContract 来自以下模板的实例化:Batch ACH Service Subscribe Contract)。
- 关系:
serviceDependencies 描述服务及其依赖服务之间的关系(例如,JamesHuAccountsPayableProcess)。
Batch ACH Service Subscribe Endpoint 模板具有以下属性:
- 属性:
executionCost 描述服务调用的成本(例如,每检查一次 5 分)。
- 属性:
responseTime 描述服务执行的响应时间(例如,每检查一次 2 毫秒)。
- 属性:
maxChecksPerBatch 描述批处理服务的最大检查数量(例如,highVolumeBatchACHServiceEP 每批最多可处理 10,000 次检查,lowVolumeBatchACHServiceEP 每批最多可处理 1,000 次检查)。
- 属性:
minChecksPerBatch 是 Batch ACH Service Subscribe Endpoint 的特定属性,它描述批处理服务的最小检查数量(例如,highVolumeBatchACHServiceEP 每批至少可处理 1,000 次检查,lowVolumeBatchACHServiceEP 每批至少可处理 1 次检查)。
- 关系:
definingWSDLPort 描述端点及其 WSDL 端口定义之间的关系(例如,BatchACHServiceSOAPPort)。
Batch ACH Service Subscribe Contract 模板具有以下属性:
-
responsetime 描述服务提供者和服务订阅者之间相互协商的服务响应时间(例如,每次检查 5 毫秒)。
-
cost 描述服务提供者和服务订阅者之间相互协商的服务调用成本(例如,如果每批检查数量 > 1,000,则每次检查 3 分,或者,如果每批检查的数量 < 1,000,则每次检查 5 分)。
-
email 描述服务订阅者的电子邮件(例如,jameshu@servicesubscriber.com)。
-
servicename 描述订阅服务的名称(例如,BatchACHService)。
-
maxChecksPerRequest 描述针对检查处理容量目的的相互协商的每个请求的最大检查数(例如,3,000)。
-
maxRequestPerHour 描述针对基础设施容量规划目的每小时的最大请求数(例如,4,000)。
-
isTestNeeded 描述是否需要测试端点。
-
service 是与为其指定此契约的服务概念的关系。
分类自定义
已在 WebSphere Service Registry and Repository 中引入了 6 种分类(分类法):
-
Test 描述用于测试的端点(例如,TestEndpoint)。
-
Production 描述用于生产的端点(例如,ProxyEndpoint)。
-
Public 描述向服务订阅者公开的端点(例如,TestEndpoint 和 ProxyEndpoint)。
-
Private 描述没有向服务订阅者公开的端点。IBM WebSphere Enterprise Service Bus 中介模块基于多个标准(如 maxChecksPerBatch)将调用从公共端点路由到适当的专用端点(例如,highVolumeBatchACHServiceEP 和 lowVolumeBatchACHServiceEP)。有关介绍 WebSphere Enterprise Service Bus 中介模块使用场景的更多详情,请参阅文章“Make composite business services adaptable with points of variability, Part 4:Using WebSphere Enterprise Service Bus mediation modules”(developerWorks,2007 年 7 月)。
-
Contract 描述契约模板的实例(例如,Batch ACH Service 订阅)。
-
ContractTemplate 描述 WebSphere Service Registry and Repository 中的契约模板实体(例如,Batch ACH Service Subscribe Contract)。
您可以在 OWL 文件中定义这些分类(参见清单 2),然后将其导入到 WebSphere Service Registry and Repository 中,以创建一个新的分类法,如图 3 中所示。
清单 2. 用于在 OWL 中指定的订阅者授权流程的 WebSphere Service Registry and Repository 分类
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE rdf:RDF [
<!ENTITY wsrrgst "http://f49.j2b.ibm.com/1/0/Taxonomy#">
]?>
<rdf:RDF xml:base="http://f49.j2b.ibm.com/1/0/Taxonomy#"
xmlns:owl="http://www.w3.org/2002/07/owl#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
xmlns:wsrrgst="http://f49.j2b.ibm.com/1/0/Taxonomy#"
xmlns:xsd="http://www.w3.org/2001/XMLSchema#"?>
<owl:Ontology rdf:about="http://f49.j2b.ibm.com/1/0/Taxonomy"?>
<rdfs:label>Jivaro2 Taxonomy</rdfs:label?>
</owl:Ontology?>
<owl:Class rdf:about="&wsrrgst;Production"?>
<rdfs:label?>Product?</rdfs:label?>
<rdfs:comment?>Services that are published as part of products?</rdfs:comment?>
</owl:Class?>
<owl:Class rdf:about="&wsrrgst;Test"?>
<rdfs:label?>Test?</rdfs:label?>
<rdfs:comment?>Services that are published for test?</rdfs:comment?>
</owl:Class?>
<owl:Class rdf:about="&wsrrgst;Public"?>
<rdfs:label?>Public?</rdfs:label?>
<rdfs:comment?>Services that are public?</rdfs:comment?>
</owl:Class?>
<owl:Class rdf:about="&wsrrgst;Private"?>
<rdfs:label>Private</rdfs:label?>
<rdfs:comment?>Services that are private?</rdfs:comment?>
</owl:Class?>
<owl:Class rdf:about="&wsrrgst;ContractTemplate"?>
<rdfs:label?>ContractTemplate?</rdfs:label?>
<rdfs:comment?>Contract Template?</rdfs:comment?>
</owl:Class?>
<owl:Class rdf:about="&wsrrgst;Contract"?>
<rdfs:label?>Contract?</rdfs:label?>
<rdfs:comment?>Contract?</rdfs:comment?>
</owl:Class?>
</rdf:RDF?>
|
图 3. 在将清单 2 中的 OWL 文件导入到 WebSphere Service Registry and Repository 之后创建的自定义分类法
角色和透视图
已将两个自定义角色“查看者”和“订阅者”添加到了 WebSphere Service Registry and Repository Web UI 中,并且还针对每个角色创建了自定义的透视图。允许订阅者查看有关订阅服务的详细信息,如公共端点和相关服务。他们还可以根据 IBM Tivoli® Access Manager 的授权策略调用订阅服务,而查看者角色中的用户则无法做到这一点。最初,所有的用户都是查看者角色;当完成订阅者授权流程后,每个用户都将从查看者角色转换到订阅者角色。WebSphere Service Registry and Repository Java™ 命令语言 (Jacl) 脚本用来配置角色和用户,加载透视图的定义和配置文件。例如,我们将查看者和订阅者角色添加到了 WebSphere Service Registry and Repository,将用户 JamesHu 添加到了查看者角色中。
另外,还为查看者角色创建了名为 Viewer 的新透视图。此透视图允许查看者角色中的用户查看可供订阅和向他们提交的所有服务。为查看者透视图创建了透视图、导航树、集合视图、详细信息视图和视图查询的定义文件。清单 3 中显示了查看者透视图定义。它指定:
- 只有查看者角色中的成员才允许查看该透视图。
-
ViewerNavigationTree 将显示在导航窗格中。
- 对象集合的集合视图和特定对象的详细视图将显示在工作区窗格中。
清单 3. 查看者角色的 WebSphere Service Registry and Repository 透视图定义元素
<perspective-definition xmlns="http://www.ibm.com/xmlns/prod/serviceregistry/6/0/
PerspectiveDefinition"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.ibm.com/xmlns/prod/serviceregistry/6/0/
PerspectiveDefinition
./../schemas/PerspectiveDefinition.xsd"
perspective-definition-name="Viewer"
weight="97">
<title-message resource-bundle-name="SampleResources" message-key=
"perspective.display.name.viewer"/>
<roles>
<role>Viewer</role>
</roles>
<navigation-tree-name>ViewerNavigationTree</navigation-tree-name>
<detail-view-mappings>
......
<view-mapping display-type="Service" view-definition-name="JivaroService" />
<view-mapping display-type="Subscriber" view-definition-name="JivaroSubscriber" />
<view-mapping display-type="contract" view-definition-name="JivaroContractDetail" />
......
</detail-view-mappings>
<collection-view-mappings>
......
<view-mapping display-type="Service" view-definition-name="JivaroServices" />
<view-mapping display-type="Subscriber" view-definition-name="JivaroSubscribers" />
......
</collection-view-mappings>
</perspective-definition>
|
查看者透视图的导航树和视图查询定义分别显示在清单 4 和 5 中。该导航树定义了节点 Services,该节点显示在导航树中。当单击 Services 节点时,将执行视图查询 showViewServices。视图查询将该视图查询 showViewServices 定义为返回其模板为 Service 的所有通用对象。
清单 4.查看者透视图的导航树定义
<NavigationTree xmlns="http://www.ibm.com/xmlns/prod/serviceregistry/6/0/
NavigationTreeDefinition"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.ibm.com/xmlns/prod/serviceregistry/6/0/
NavigationTreeDefinition ../../schemas/NavigationTree.xsd"
name="ViewerNavigationTree">
<node id="navtree_root" node-resource-key="navigationtree.service.registry">
<node id="businessmetadata" node-resource-key="navigationtree.unified.service.metadata">
<node id="bservice" node-resource-bundle="SampleResources"
node-resource-key="navigationtree.service.business.service" view-query-id=
"showViewServices"/>
</node>
</node>
</NavigationTree>
|
清单 5.查看者透视图的视图查询定义
<ViewQueryDefinitionSet xmlns="http://www.ibm.com/xmlns/prod/serviceregistry/6/0/
ViewQueryDefinitionSet" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.ibm.com/xmlns/prod/serviceregistry/6/0/
ViewQueryDefinitionSet ../../schemas/ViewQueryDefinitionSet.xsd">
<QueryDefinitions>
......
<Query id="showViewServices">
<ObjectType>GenericObject</ObjectType>
<DisplayType>Service</DisplayType>
<Relationship name="template">
<Target>
<Property name="name" value="Service" />
</Target>
</Relationship>
</Query>
......
</QueryDefinitions>
</ViewQueryDefinitionSet>
|
当单击导航树中的 Services 节点时,将显示一个集合视图。此集合视图显示有关服务名称集合的信息。该集合视图定义文件显示在清单 6 中。
清单 6. Services 对象集合的集合视图定义
<collection-view-definition xmlns="http://www.ibm.com/xmlns/prod/serviceregistry/6/0/
CollectionViewDefinition" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.ibm.com/xmlns/prod/serviceregistry/6/0/
CollectionViewDefinition ../../../schemas/CollectionViewDefinition.xsd"
view-definition-name="JivaroServices">
<messages>
<title-message resource-bundle-name="SampleResources"
message-key="sample.collection.view.business.services.title"/>
<description-message resource-bundle-name="SampleResources"
message-key="sample.collection.view.business.services.description"/>
</messages>
<column-definitions>
<column-definition filterable="true">
<heading-message message-key="collection.view.column.name"/>
<property-name>name</property-name>
<action>ViewDetail</action>
</column-definition>
<column-definition filterable="true">
<heading-message message-key="collection.view.column.description"/>
<property-name>description</property-name>
</column-definition>
<column-definition filterable="true">
<heading-message message-key="collection.view.column.version"/>
<property-name>version</property-name>
</column-definition>
</column-definitions>
<button-definitions>
</button-definitions>
</collection-view-definition>
|
当单击集合视图中的一项服务时,将显示详细信息视图。Service 对象的详细信息视图定义文件显示在清单 7 中。详细信息视图描述了一些常规属性,如名称和引用属性:contractTemplate。该引用属性显示为 HTML 链接。单击该链接用户可以导航到 contractTemplate 类型概念的自定义集合视图。
清单 7. Service 对象的详细信息视图定义
detail-view-definition xmlns="http://www.ibm.com/xmlns/prod/serviceregistry/6/0/
DetailViewDefinition" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.ibm.com/xmlns/prod/serviceregistry/6/0/
DetailViewDefinition ../../../schemas/DetailViewDefinition.xsd"
view-definition-name="JivaroService">
<messages>
<callout-message resource-bundle-name="SampleResources"
message-key="sample.detail.view.business.service.callout" />
<title-message resource-bundle-name="SampleResources" message-key=
"sample.detail.view.business.service.title" />
<description-message resource-bundle-name="SampleResources"
message-key="sample.detail.view.business.service.description" />
</messages>
<tab-definition tab-name="details" tab-content="/pages/detailContent.jsp">
<tab-title-message message-key="detail.details" />
<general-properties>
<heading-message message-key="detail.view.general.properties" />
<property>
<property-name>name</property-name>
<property-messages>
<property-message message-key="detail.view.name" />
<field-help-message message-key="detail.view.name.field.help" />
</property-messages>
</property>
......
</general-properties>
<additional-properties>
<heading-message message-key="detail.view.relationships" />
<property hide-on-new="true">
<action>ViewRelationshipDetail</action>
<property-name>contractTemplate</property-name>
<property-messages>
<property-message resource-bundle-name="SampleResources" message-key=
"sample.detail.view.contract" />
<field-help-message message-key="detail.view.version.field.help" />
</property-messages>
</property>
</additional-properties>
</tab-definition>
</detail-view-definition>
|

 |

|
将 WebSphere Service Registry and Repository 与 WebSphere Process Server 集成
要将 WebSphere Service Registry and Repository 与订阅者授权治理流程集成,需要创建一个 WebSphere Service Registry and Repository 通知插件、在 WebSphere Process Server 中运行的 BPEL 工作流、以及 WebSphere Service Registry and Repository 客户端。以下部分介绍有关集成步骤的详细信息。
WebSphere Service Registry and Repository 通知插件
创建通知插件可以在查看者创建契约模板实例时自动调用订阅者授权流程。
创建 WebSphere Service Registry and Repository 通知插件的第一步是开发实现接口 com.ibm.serviceregistry.ServiceRegistryNotifier 的 Java 类。该接口具有三个方法 ——create、update 和 delete——当创建、更新和删除 WebSphere Service Registry and Repository 对象时将分别调用这三个方法。例如,清单 8 显示了 create 方法的源代码。在此方法中,如果要创建的对象是一个契约模板实例,则该实例的属性将通过使用 WebSphere Service Registry and Repository API 来获取,并且使用 Web 服务客户端调用订阅者授权流程。要创建的对象还将通过添加分类契约和设置与订阅服务的关系来进行更新。
清单 8. 用于调用订阅者授权流程的 WebSphere Service Registry and Repository 通知插件
public void create(OriginalObject obj, boolean success.
ServiceRegistryException arg2) {
if (classificationURI==null)
initProperties();
if (!success)
return;
if ((obj==null) || (obj.getTemplate()==null) ||
(obj.getTemplate().getClassificationURIs()==null))
{
return;
}
if (!obj.getTemplate().getClassificationURIs().contains(
classificationURI)) {
return;
}
if (wsrrClient == null) {
init();
}
try {
String servicename = BSRSDOHelper.INSTANCE.getPropertyValue(obj,"servicename");
if ((servicename==null) || (servicename.trim().length()==0))
{
throw new RuntimeException("Servicename cannot be null");
}
GenericObject service = getServiceObjectFromServicename(servicename);
if (service==null) {
System.out.println("Cannot find subscribed service name");
return;
}
BSRSDOHelper.INSTANCE.setTargetObject(obj,"service",service);
((WSRR)((GenericObjectImpl)obj).getRootObject()).
getArtefacts().addAll(
((WSRR)((ComplexTypeDefinitionImpl)service.getTemplate()).getRootObject()).
getArtefacts());
obj.getClassificationURIs().add(contractClassification);
wsrrClient.update(obj);
String email="",responsetime="";
StringBuffer buffer=new StringBuffer();
List properties = obj.getUserDefinedProperties();
for (int i = 0; i < properties.size(); i++) {
UserDefinedProperty property = (UserDefinedProperty) properties.get(i);
String propertyname = property.getName();
if (propertyname.equals("email"))
{
email=property.getValue();
}
else if (propertyname.equals("responsetime"))
{
responsetime=property.getValue();
}
else if (!propertyname.equals("servicename")){
String propertyvalue = property.getValue();
if (propertyvalue!=null && propertyvalue.length()>0)
{
if (i==0)
buffer.append(property.getName()+"="+property.getValue());
else
buffer.append("&"+property.getName()+"="+property.getValue());
}
}
}
invokeEntitlementProcess(service.getName(),obj.getOwner(),
email,responsetime,buffer.toString(),obj.getBsrURI());
}
catch(Exception e)
{
System.out.println("Exception happened when add the relationship
service in contract:"+e.getMessage());
e.printStackTrace();
}
}
private String invokeEntitlementProcess(String serviceName,
String contactorUserId,
String contactorEmail,
String contractResponsetime,
String contractString,
String contractBsrURI)
{
try{
EntitlementProcessInterfaceProxy proxy = new EntitlementProcessInterfaceProxy();
proxy.setEndpoint(processendpoint);
EntitlementProcessInterface service = proxy.getEntitlementProcessInterface();
String result = service.process(serviceName,contactorUserId,contactorEmail,
contractResponsetime,contractString,contractBsrURI);
return result;
}
catch(Exception e)
{
e.printStackTrace();
}
return "";
}
|
该通知插件作为共享库部署到 WebSphere Service Registry and Repository 中。该部署需要重新启动 WebSphere Service Registry and Repository。
订阅者授权流程
上一篇文章中介绍的订阅者授权流程是使用 IBM WebSphere Integration Developer 中的 BPEL 创建的,并将其部署在 WebSphere Process Server 中。
图 4 显示了订阅者授权流程的界面,其输入内容包括:
-
ServiceName,这是订阅服务的名称。该服务的详细信息可以通过服务名称从 WebSphere Service Registry and Repository 中查询到。
-
订阅者的
UserId。
-
订阅者的
Email。
-
ResponseTime,在契约中指定的期望的 responseTime 值。
-
contractProperties,订阅者契约的属性,包括每个请求的最大检查数 和每小时的最大请求数。
-
contractBsrURI,WebSphere Service Registry and Repository 中契约实例的 bsrURI 属性。契约实例可以通过此属性查找,并且可以使用 WebSphere Service Registry and Repository API 来更新。
图 4. WebSphere Integration Developer 中显示的订阅者授权流程界面
该订阅者授权流程可与 WebSphere Service Registry and Repository 通信,以获取有关订阅服务的信息、更新契约实例的状态,以及通过 WSRRServiceHelper 创建订阅。该流程可配置 Tivoli Access Manager 来更新访问控制列表,以允许服务订阅者调用所订阅的服务。这通过以下人工任务来完成:AdminConfigureTAM。该流程还可配置 WebSphere Service Registry and Repository 以通过另一人工任务来添加订阅者角色:AdminAddSubscriberRole。在 WebSphere Integration Developer 中,人工任务和 Web 服务以装配图形式组合到订阅者授权流程,如图 5 所示。
图 5. 订阅者授权流程的装配图
WebSphere Service Registry and Repository 客户端
创建的 WSRRServiceHelper 可以通过 WebSphere Service Registry and Repository API 的 Web 服务客户端与 WebSphere Service Registry and Repository 通信,如清单 9 所示。
清单 9. 使用 WebSphere Service Registry and Repository API 创建 WebSphere Service Registry and Repository 客户端
System.setProperty(SYSTEM_TRUST_STORE, "C:\\DummyClientTrustFile.jks");
System.setProperty(SYSTEM_TRUST_STORE_PASSWORD, "WebAS");
System.setProperty(SYSTEM_KEY_STORE, "C:\\DummyClientKeyFile.jks");
System.setProperty(SYSTEM_KEY_STORE_PASSWORD, "WebAS");
WSRRCoreSDOClient wsrrClient = new WSRRCoreSDOClient("https://localhost:9443/
WSRRCoreSDO/services/WSRRCoreSDOPort","wpsbind","wpsbind");
|
图 6 和清单 10、清单 11 以及清单 12 显示了此 Web 服务的接口和方法。
图 6. WSRRServiceHelper Web 服务的接口
清单 10. WSRRServiceHelper Web 服务中的 addSubscription 方法
Subscription sub = (Subscription)DataFactory.INSTANCE.create(Subscription.class);
sub.setTargetBsrURI(serviceInstance.getBsrURI());
sub.setEmailAddress("mailto:"+email);
sub.setString("name","Subscription for service "+serviceName);
sub.setString("owner",userid);
String bsrURI = wsrrClient.create(sub);
|
清单 11. WSRRHelper Web 服务中的 updateProperty 方法
BaseObject obj = wsrrClient.retrieve(bsrURI);
BSRSDOHelper.INSTANCE.setPropertyValue(obj,property,value);
wsrrClient.update(obj);
|
清单 12. WSRRHelper Web 服务中的 getAvailableEndpoint 方法,显示如何通过名称查询服务对象以及如何通过关系获取相关的端点:availableEndpoints
GraphQuery graphQuery = SdoFactory.INSTANCE.createGraphQuery();
String FIND_WSDL = "/WebSphere Service Registry and Repository/GenericObject[@name=\""
+serviceName+"\" and template(.)/@name=\"Service\"]";
graphQuery.setQueryExpression(FIND_WSDL);
List results = wsrrClient.executeQuery(graphQuery);
GenericObject serviceObj = (GenericObject)results.get(0);
List relations = serviceObj.getUserDefinedRelationships();
for(int i=0;i<relations.size();i++)
{
UserDefinedRelationship relation = (UserDefinedRelationship)relations.get(i);
if (relation.getName().equals("availableEndpoints"))
{
List targets = relation.getTargets();
......
}
}
|
结束语
本文向您介绍了如何通过用户定义的模板、角色和权限、UI 透视图和分类系统自定义 WebSphere Service Registry and Repository。现在,您已经了解了如何使用通知插件和 WebSphere Service Registry and Repository API 将 WebSphere Service Registry and Repository 与在 WebSphere Process Server 中运行的订阅者授权流程进行集成。还学习了如何结合使用 WebSphere Service Registry and Repository 自定义技术以及与 WebSphere Process Server 的集成技术,来通过发布的服务实现订阅者授权流程治理。
致谢
作者感谢 Ashleigh Brothers 和 Patrick Flanders,他们对本文进行了专业性编辑检查。
下载 | 描述 | 名字 | 大小 | 下载方法 |
|---|
| Sample code for this article | wsrrgov.zip | 7.3MB | HTTP |
|---|
参考资料 学习
获得产品和技术
讨论
作者简介  | 
|  | Naveen Sachdeva 是业务流程管理技术全球销售团队的成员,负责 WebSphere Service Registry and Repository 产品方面的工作。在这方面,他参加了影响力较大的技术销售工作,并且负责现场支持和品牌支持。他不但是一位 IBM 认证的 IT 专家,还是一位 SOA 解决方案设计师,具有长达 14 年的 IT 经验。他在 IBM Software Group 中工作过 9 年,从事的工作包括软件开发和支持、业务合作伙伴技术支持以及技术销售。Naveen Sachdeva 为 developerWorks 撰写了一些文章,还与人合著了 IBM 红皮书。 |
 | |  |
Indrajit Poddar 是一位顾问软件工程师,现在是 IBM 软件部策略与技术团队的一名成员。他感兴趣的是采用面向服务的体系结构和 IBM Software Group 产品组合(WebSphere Application Server、Process Server, Portal Server 和 Tivoli and Rational 产品)来设计复合应用程序的体系结构。他获得了宾夕法尼亚州立大学的计算机科学与工程学士学位,以及位于印度坎普尔市的印度科技大学计算机科学与工程硕士学位。 |
对本文的评价
|