WebService 应用(5) - Web Services 平台元素 UDDI(Universal Description, Discovery, and Integration)

什么是UDDI?
UDDI 是一种目录服务,通过它,企业可注册并搜索 Web services。如行业发布了一个用于航班比率检测和预订的 UDDI 标准,航空公司就可以把它们的服务注册到一个 UDDI 目录中。然后旅行社就能够搜索这个 UDDI 目录以找到航空公司预订界面。当此界面被找到后,旅行社就能够立即与此服务进行通信。

  - UDDI 指通用的描述、发现以及整合(Universal Description, Discovery and Integration)

  - UDDI 是一种用于存储有关 web services 的信息的目录

  - UDDI 是一种由 WSDL 描述的网络服务接口目录

  - UDDI 经由 SOAP 进行通迅

  - UDDI 被构建于 Microsoft .NET 平台之中

 

UDDI 数据类型

  UDDI 提供一种发布和查找服务描述的方法。UDDI 数据实体提供对定义业务和服务信息的支持。WSDL 中定义的服务描述信息是 UDDI 注册中心信息的补充。UDDI 提供对许多不同类型的服务描述的支持。因此,UDDI 没有对 WSDL 的直接支持, 也没有对任何其它服务描述机制的直接支持。 在 UDDI 注册中心有 4 种主要的数据类型: businessEntity、 businessService、 bindingTemplatetModel

  

  businessEntity 提供关于商家的信息,可以包含一个或多个 businessService。这个商家是服务提供者。Web 服务的技术和业务描述在 businessService 和其 bindingTemplate 中被定义。每个 bindingTemplate 包含一个对一个或多个 tModel 的引用。tModel 被用于定义服务的技术规范。

 

发布和查找 WSDL 描述 

   一个完整的 WSDL 服务描述是由一个服务接口和一个服务实现文档组成的。由于服务接口表示服务的可重用定义,它在 UDDI 注册中心被作为 tModel 发布。 服务实现描述服务的实例。每个实例都是使用一个 WSDL service 元素定义的。服务实现文档中的每个 service 元素都被用于发布 UDDI businessService。当发布一个 WSDL 服务描述时,在服务实现被作为 businessService 发布之前,必须将一个服务接口作为一个 tModel 发布。

  下图包含从 WSDL 到 UDDI 的映射概览 。

  

   

发布服务接口

  在 UDDI 注册中心,服务接口被作为 tModel 发布。tModel 由服务接口提供者发布。tModel 中的一些元素是使用来自 WSDL 服务接口描述中的信息构建的。下表是定义创建 tModel 的步骤。一个有效的对 WSDL 服务接口定义的 tModel 引用应该是使用 targetNamespace 命名,并且必须包含 overviewURL 和 categoryBag 设置。  

步骤

UDDI tModel

WSDL 服务接口

描述

必需

1

Name

definitions 元素targetNamespace 属性

tModel 名称使用服务接口文档的目标名称空间设置。名称需要一致以确保只使用服务实现文档中的信息就可以定位 tModel

2

description

definitions 元素中的documentation 元素

tModel description 元素被限制为只能使用 256 个字符。这个元素的英文值可根据 definitions 元素的前 256 个字符设置(documentation 元素与服务接口文档中的 definitions 元素相关联)。如果 documentation 元素不存在,那么应该使用 definitions 元素中的 name 属性。

3

overviewURL

[服务接口文档 URL 和绑定规范]

服务接口文档的位置必须在 overviewURL 元素中设置。如果服务接口文档中有多个绑定,那么必须在 URL 中对绑定进行编码。

4

categoryBag

[不可用]

tModel categoryBag 必须至少包含一个键控的引用。这个键控的引用必须包含一个对 uddi-org:types tModel 的引用,而且键名必须是 wsdlSpec 。这个条目把 tModel 当作一个 WSDL 服务接口定义。

  下面的清单包含一个示例 WSDL 服务接口文档。  

WSDL 服务接口
<?xml version="1.0"?>
<definitions name="StockQuoteService-interface"
  targetNamespace
="http://www.getquote.com/StockQuoteService-interface"
  xmlns:tns
="http://www.getquote.com/StockQuoteService-interface"
  xmlns:xsd
=" http://www.w3.org/2001/XMLSchema "
  xmlns:soap
="http://schemas.xmlsoap.org/wsdl/soap/"
  xmlns
="http://schemas.xmlsoap.org/wsdl/">
  
<documentation>
    Standard WSDL service interface definition for a stock quote service.
  
</documentation>
  
<message name="SingleSymbolRequest">
    
<part name="symbol" type="xsd:string"/>
  
</message>
  
<message name="SingleSymbolQuoteResponse">
    
<part name="quote" type="xsd:string"/>
  
</message>
 
  
<portType name="SingleSymbolStockQuoteService">
    
<operation name="getQuote">
      
<input message="tns:SingleSymbolRequest"/>
      
<output message="tns:SingleSymbolQuoteResponse"/>
    
</operation>
  
</portType>
  
<binding name="SingleSymbolBinding"
           type
="tns:SingleSymbolStockQuoteService">
    
<soap:binding style="rpc"
                  transport
="http://schemas.xmlsoap.org/soap/http"/>
    
<operation name="getQuote">
      
<soap:operation soapAction="http://www.getquote.com/GetQuote"/>
      
<input>
        
<soap:body use="encoded"
            namespace
="urn:single-symbol-stock-quotes"
            encodingStyle
="http://schemas.xmlsoap.org/soap/encoding/"/>
      
</input>
      
<output>
        
<soap:body use="encoded"
            namespace
="urn:single-symbol-stock-quotes"
            encodingStyle
="http://schemas.xmlsoap.org/soap/encoding/"/>
      
</output>
    
</operation>
  
</binding>  
</definitions>

  关键字:

  Definitions - targetNamespace 将被用作 tModel 的名称。documentation 元素的内容将被用于描述 tModel。

  Binding - 绑定名将被用于限定 overviewURL。

  下面包含在发布 WSDL 服务接口定义时创建的 UDDI tModel。

UDDI tModel
<?xml version="1.0"?>
<tModel tModelKey="">
  
<name>http://www.getquote.com/StockQuoteService-interface</name>
  
<description xml:lang="en">
    Standard service interface definition for a stock quote service.
  
</description>
  
<overviewDoc>
    
<description xml:lang="en">
      WSDL Service Interface Document
    
</description>
    
<overviewURL>
      http://www.getquote.com/services/
SQS-interface.wsdl#SingleSymbolBinding
    
</overviewURL>
  
</overviewDoc>
  
<categoryBag>
    
<keyedReference tModelKey="UUID:C1ACF26D-9672-4404-9D70-39B756E62AB4"
                    keyName
="uddi-org:types" keyValue="wsdlSpec"/>
    
<keyedReference tModelKey="UUID:DB77450D-9FA8-45D4-A7BC-04411D14E384" 
                    keyName
="Stock market trading services" 
                    keyValue
="84121801"/>
  
</categoryBag>
</tModel>

  关键字:

  tModel - tModel 的名称根据 targetNamespace 设置。描述是根据与 definitions 元素相关联的 documentation 元素设置的。overviewURL 被设置为 WSDL 服务接口文档可通过网络访问到的位置, 即 http://www.getquote.com/services/SQS-interface.wsdl。它还包含对服务接口文档中名为的 SingleSymbolBinding 的绑定的直接引用。既然这是服务接口文档中唯一的绑定,对绑定的这个引用就不是必需的。categoryBag 包含 wsdlSpec 条目以及其它的所有 keyedReference,keyedReference 指出这个服务接口描述的意向中的商业用途。

 

发布服务实现

  服务实现在 UDDI 注册中心是作为带有一个或多个 bindingTemplate 的 businessService 发布的。 businessService 由服务提供者发布。

  UDDI businessService 将为服务实现文档中定义的每个 service 元素创建一个新的 businessService。 下面的表中包含 businessService 元素列表,这些 businessService 元素可根据 WSDL 服务实现文档的内容创建。  

 

UDDI businessService

描述

必需

1

name

businessService name 元素根据服务实现文档中的 service 元素的 name 属性设置。

2

description

description 元素根据 service 元素中的 documentation 元素的内容设置。 description 元素的英文值根据与 service 元素关联的 documentation 元素中的前 256 个字符设置。如果 documentation 元素不存在,那么 businessService description 元素就没有被设置。

  UDDI bindingTemplate:新的 bindingTemplate 元素是在 businessService 中为 service 元素中定义的每个 port 元素而定义的。

 

UDDI bindingTemplate

描述

必需

1

description

如果 port 元素包含一个 documentation 元素,那么就有一个 description 元素是根据 documentation 元素的前 256 个字符设置的。

2

accessPoint

对于一个 SOAP HTTP 绑定,accessPoint 是根据与 port 元素关联的扩展元素的 location 属性设置的。 这个元素将包含 URL,且 URLType 属性是根据此 URL 中的协议设置的。对于不使用 URL 规范的协议绑定,应该使用 URLType 属性指出协议绑定的类型, 并且 accessPoint 元素应该包含一个可用于定位使用指定协议的 Web 服务的值。

3

tModelInstanceInfo

bindingTemplate 将包含自己引用的每个 tModel 的一个 tModelInstanceInfo 元素。至少将有一个 tModelInstanceInfo 元素包含对表示服务接口文档的 tModel 的直接引用。

4

overviewURL

overviewURL 元素可能包含对服务实现文档的一个直接引用。对这个文档的引用仅用于提供对人类可读的文档的访问。这个文档中的其它所有信息都应该能够通过 UDDI 数据实体访问。通过维持对原始 WSDL 文档的直接引用,您可以确保被发布的文档就是查找操作返回的那个。如果这个文档包含多个端口,那么这个元素应该包含对端口名的直接引用。 由于可能会有多个端口引用同一个绑定,只使用 tModel 中的直接引用是不够的。 端口名被指定为 overviewURL 上的片段标识符。片段标识符是 URL 的一个扩展,使用“#”字符作为一个分隔符。



  服务实现到 businessService 的映射示例

  下面是 WSDL 服务实现文档的一个示例:

WSDL 服务实现
<?xml version="1.0"?>
<definitions name="StockQuoteService"
  targetNamespace
="http://www.getquote.com/StockQuoteService"
  xmlns:interface
="http://www.getquote.com/StockQuoteService-interface"
  xmlns:xsd
="http://www.w3.org/2001/XMLSchema"
  xmlns:soap
="http://schemas.xmlsoap.org/wsdl/soap/"
  xmlns
="http://schemas.xmlsoap.org/wsdl/">
  
<documentation>
    This service provides an implementation of a standard stock quote service.
    ......
  
</documentation>
  
<import namespace="http://www.getquote.com/StockQuoteService-interface"
     location
="http://www.getquote.com/wsdl/SQS-interface.wsdl"/>
  
<service name="StockQuoteService">
    
<documentation>Stock Quote Service</documentation>
    
    
<port name="SingleSymbolServicePort"
        binding
="interface:SingleSymbolBinding">
      
<documentation>Single Symbol Stock Quote Service</documentation>
      
<soap:address location="http://www.getquote.com/stockquoteservice"/>
    
</port>
  
</service>
</definitions>

  关键字:

  Service - service 元素的 name 属性被用作 businessService 的名称。service 元素中的 documentation 元素被用于描述 businessService。
  Import - 端口名被附加到 overviewURL,此 overviewURL 包含对服务实现文档的引用。服务的位置被用于设置 bindingTemplate 中的 accessPoint。

  接下来是根据服务实现文档创建的 UDDI businessService 定义。categoryBag 应该包含一个或多个 keyedReference,它们被用于对服务意向中的商业用途进行分类。

根据 WSDL 服务实现创建的 UDDI 服务
<businessService businessKey="..." serviceKey="...">
  
<name>StockQuoteService</name>
  
<description xml:lang="en">
   Stock Quote Service
  
</description>
  
<bindingTemplates>
    
<bindingTemplate bindingKey="..." serviceKey="...">
      
<description>
        Single Symbol Stock Quote Service
      
</description>
      
<accesssPoint URLType="http">
       http://www.getquote.com/singlestockquote
      
</accessPoint>
      
<tModelInstanceDetails>
        
<tModelInstanceInfo tModelKey="[tModel Key for Service Interface]">
          
<instanceDetails>
            
<overviewURL>
              http://www.getquote.com/services/SQS.wsdl
            
</overviewURL>
          
</instanceDetails>
        
</tModelInstanceInfo>
      
</tModelInstanceDetails>
    
</bindingTemplate>
  
</bindingTemplates>
  
<categoryBag>
    
<keyedReference tModelKey="UUID:DB77450D-9FA8-45D4-A7BC-04411D14E384" 
                    keyName
="Stock market trading services" 
                    keyValue
="84121801"/>
  
</categoryBag>
</businessService>

  关键字:

  BusinessService - businessService 的 name 根据 WSDL 服务实现文档中的 service 的 name设置。 description 根据 service 元素中的 documentation 元素设置。

  BindingTemplate - 它的 description 是根据 port 元素中的documentation 元素设置。accessPoint 根据 soap:address 扩展元素设置。tModelKey 被设置到与服务接口文档关联的 tModel 的 UUID。可使用 import 元素的 namespace 属性对 tModel 进行定位。overviewURL 是服务实现文档的位置。 由于它是这个文档中唯一的引用,它不包含对 SingleServiceQuote 端口的引用。

 

查找 WSDL 服务接口描述

  所有的 WSDL 服务接口在 UDDI 注册中心都是作为 tModel 发布。对这些 tModel 中的每一个都要进行归类,以便将它们标识为 WSDL 服务描述。UDDI find_tModel 消息可用于查找已经分过类的 tModel。

  find_tModel 消息将返回一列 tModel 关键字。使用 get_tModelDetail 消息可检索特定的服务接口描述。get_tModelDetail 消息将返回一个 tModel。在检索了一个 tModel 后,可使用 overviewURL 检索 WSDL 服务接口文档的内容。可将另外的 keyedReference 添加到 categoryBag 以限制这个查找请求的响应中返回的 tModel 集。 下面清单中的 find_tModel 消息可用于定位使用 WSDL 定义的所有股票报价服务。

查找 WSDL 服务接口描述
<?xml version="1.0"?>
<find_tModel generic="1.0" xmlns="urn:uddi-org:api">
  
<categoryBag>
    
<keyedReference tModelKey="UUID:C1ACF26D-9672-4404-9D70-39B756E62AB4"
                    keyName
="uddi-org:types" keyValue="wsdlSpec"/>
    
<keyedReference tModelKey="UUID:DB77450D-9FA8-45D4-A7BC-04411D14E384" 
                    keyName
="Stock market trading services" 
                    keyValue
="84121801"/>
  
</categoryBag>
</find_tModel>

 

查找 WSDL 服务实现描述

  WSDL 服务实现在 UDDI 注册中心是作为 businessService 发布的。businessService 将包含一个或多个 bindingTemplate。对 businessService 进行归类,以便将它看作基于 WSDL 的服务描述。使用 UDDI V1.0 API 时,必须找到一个 businessEntity 或一个 businessEntity 集才能使用 businessService 的查找 API。同样地,也必须找到一个 businessService 或一个 businessService 集才能使用查找 API 定位 bindingTemplate。

  查找 UDDI businessService

  有两种基本方法可用于查找服务描述。使用特定的分类法,UDDI find_service 消息可用于查找服务描述,或者说它可用于查找实现某个特定的服务接口的服务描述

查找 WSDL 服务实现描述
<?xml version="1.0"?>
<find_service businessKey="..." generic="x.0" xmlns="urn:uddi-org:api">
  
<categoryBag>
   
<keyedReference tModelKey="UUID:DB77450D-9FA8-45D4-A7BC-04411D14E384" 
                    keyName
="Stock market trading services" 
                    keyValue
="84121801"/>
  
</categoryBag>
</find_service>

  find_service 消息也可用于定位 businessService ― 该 businessService 是某个特定服务接口的实现。 下面清单中的消息包含 find_service 消息的一个示例,它将查找 businessEntity 中的所有 businessService,这个 businessEntity 实现了股票报价服务的服务接口。由于服务接口是用 tModel 来表示, tModelBag 就被用于指定 WSDL 服务接口与股票报价服务相关联的 tModel 关键字。

用 tModelBag 查找 WSDL 服务实现描述
<?xml version="1.0"?>
<find_service businessKey="..." generic="x.0" xmlns="urn:uddi-org:api">
  
<tModelBag>
    
<tModelKey>[tModel key for WSDL service interface]</tModelKey> 
  
</tModelBag>
</find_service>

  find_service 消息将返回一列服务关键字。可用 get_serviceDetail 消息检索 businessService 描述。get_serviceDetail 消息将返回一个businessService。

检索了一个 businessService 后,可选择某个特定的 bindingTemplate 调用 Web 服务。bindingTemplate 中的 accessPoint 是服务的端点。overviewURL 可用于检索 WSDL 服务实现文档的内容,该文档可能包含关于已实现服务的额外详细信息。

 

  查找 UDDI bindingTemplate

  如果 businessService 包含多个 bindingTemplate,可能会很难确定要使用哪个 bindingTemplate。 find_binding 消息可用于定位应该使用的 bindingTemplate。下面是一条 find_binding 消息,可用它来检索引用特定的 tModel 的 bindingTemplate。可将这个 tModel 与 WSDL 服务接口描述中的特定绑定关联起来。

 

查找 UDDI bindingTemplate
<?xml version="1.0"?>
<find_binding serviceKey="..." generic="x.0" xmlns="urn:uddi-org:api">
  
<tModelBag>
    
<tModelKey>[tModelKey for WSDL service interface]<tModelKey/>
  
</tModelBag>
</find_service>

  这条消息将返回一个或多个 bindingTemplate,比如比如下面列出中的那个。访问过 bindingTemplate 之后,accessPoint 中列出了 Web 服务的端点。 如果 bindingTemplate 是根据现有的 WSDL 服务实现文档创建的,那么 overviewURL 可能包含一个对这个文档的引用。可访问这个文档获取额外的、可读的关于 Web 服务的信息, 这些信息在 UDDI 注册中心找不到。  

UDDI bindingTemplate
<?xml version="1.0"?>
<bindingTemplate bindingKey="" serviceKey="">
  
<accesssPoint URLType="http">
    http://www.getquote.com/singlestockquote
  
</accessPoint>
  
<tModelInstanceDetails>
    
<tModelInstanceInfo tModelKey="[tModel Key for Service Interface]">
      
<instanceDetails>
        
<overviewURL>
          http://www.getquote.com/services/SQS.wsdl
        
</overviewURL>
      
</instanceDetails>
    
</tModelInstanceInfo>
  
</tModelInstanceDetails>
</bindingTemplate>

 

posted on 2010-06-05 14:45  lantionzy  阅读(957)  评论(0编辑  收藏  举报