UDDI 數據結構
為了開始將公司添加到 UDDI 注冊中心,Francis 定義了要輸入注冊中心的信息。
businessEntity
第一步是將報社本身的信息輸入注冊中心。為此,Francis 創建了一個 businessEntity
對象。此對象包含有關企業的信息,既用于對企業進行標識,也用于提供與其有關的信息。例如,businessEntity 對象可以包含多個名稱(從而能夠為公司所使用的每種語言創建一個 name 元素),聯系信息(Francis 被告知將 Pat Mooney 添加為主要聯系人)、與實體相關的服務(Gene 將稍后添加)和用于對公司進行標識與分類的信息。
盡管大部分人都不會采用這種方式與 UDDI 注冊中心交互,但要注意的一個事實是,UDDI 實際上就是 SOAP 應用程序;執行的所有操作都作為往返傳遞 SOAP 消息的結果發生。這意味著,Francis 所創建的 businessEntity 最終將表示為 XML 元素。請參見清單 2。
清單 2. businessEntity 元素
<businessEntity businessKey="{uuid}"
operator="(optional)"
authorizedName="(optional)">
<discoveryURLs>
<discoveryURL></discoveryURL>
<discoveryURL></discoveryURL>
</discoveryURLs>
<name>The Daily Moon</name>
<name lang="fr-ca">La Lune Quotidienne</name>
<description></description>
<contacts>
<contact>
<description></description>
<personName>Pat Mooney</personName>
<phone></phone>
<email>patm@daily-moon.com</email>
<address useType="optional, billing, etc."
sortCode="optional"
tModelKey="optional">
<addressLine></addressLine>
<addressLine></addressLine>
<addressLine></addressLine>
</address>
</contact>
<contact>
...
</contact>
</contacts>
<businessServices>
<businessService serviceKey="required"
businessKey="optional">
...
</businessService>
</businessServices>
<identifierBag>
...
</identifierBag>
<categoryBag>
...
</categoryBag>
</businessEntity>
|
businessEntity
記錄并不一定要很復雜。事實上,按照 businessKey
的要求,單個名稱和一個唯一標識符就足夠了。不過,出于完整性考慮,我包含了完整的結構,但去掉了一些稍后將另行討論的部分。在生產環境中,應將空白元素刪除。
讓我們看一看此處的一些信息。
從代碼的起始處開始,businessKey
當然是唯一標識符。operator 和 authorizedName
屬性由注冊中心內部進行處理;您不必考慮這部分內容,它們僅僅分別表示運行注冊中心的實體和添加此記錄的人員或帳戶。
discoveryURLs
會在每次將 businessEntity 保存到注冊中心時添加到注冊中心。這些 URL 旨在用作供用戶訪問有關 businessEntity
的更多信息的地址。
請注意,Francis 添加了一個額外的名稱,用于以法語表示其名稱(報社打算在法國宣傳其業務)。這些實體中的每一個都具有 lang
屬性,用于指定相關語言的代碼。您可以提供常見縮寫的可替換名稱,如 IBM 對應于 International Business Machines。
接下來的可選描述是一個簡單的文本字符串。事實上,UDDI 中的大部分元素都具有一個可選描述。
接下來,Francis 添加了其他一些聯系人。對于每個聯系人,他可以根據需要指定任意多的信息。通常會提供 personName
,但電話號碼、電子郵件等其他信息是由個人自行提供的,因為 UDDI 注冊中心的所有信息對所有用戶均可用。聯系人還可能具有地址信息,使用 useType
來指定地址類型。例如,對于聯系人,它可以為家庭地址和公司地址等。對于公司,useType
可以為總部、發行中心等等。
businessServices
元素將列出已與 businessEntity
關聯的任何服務。由于 Gene 尚未添加任何服務,故而此元素通常為空。最后兩項 identifierBag
和 categoryBag
提供了有關公司本身的其他信息,以便進行搜索。我們稍后將對二者分別進行分析。
publisherAssertion
publisherAssertion
是 businessEntity
之間的關系聲明。例如,Francis 知道此項目的目標之一是使用 Daily Star 中提供的服務,其中,Daily Star 將為 Daily Moon 提供體育賽事比分。這使得 Daily Star 成為 Daily Moon 的內容提供者。Francis 可以按照清單 3 中所示的方式表示此關系。
清單 3. publisherAssertion
<publisherAssertion>
<fromKey>(businessKey for Daily Star)</fromKey>
<toKey>(businessKey for Daily Moon)</toKey>
<keyedReference tModelKey="904BD800-D53A-11DA-B055-850A1DA99D79"
keyName="optional" keyValue="CONTENTPROVIDER" />
</publisherAssertion>
|
fromKey
和 toKey
元素表示所涉及的兩個實體的唯一 ID。在本例中,這兩個實體指 Daily Moon 和 Daily Star。Daily Star 是 Daily Moon 的內容提供者,故而據此放置二者的鍵。keyedReference
將會多次出現。在本例中,我們可以說引用本身就是內容提供者。keyValue
是 keyedReference
的唯一必需屬性,但常常也會包含 keyName
(為了提高可讀性)和 tModelKey
(標識特定的引用類型)。在本例中,tModelKey
表示兩個報社之間關聯的命名空間(與內部關系相對)。我們稍后將對 tModels
進行進一步的討論。
businessService
接下來,Francis 需要輸入有關 Daily Moon 將要提供的任何實際服務的信息。除了所需的唯一 serviceKey
和名稱外,businessService
對象中還包含兩條重要信息。即 bindingTemplates
和服務所屬的任何類別。請參見清單 4。
清單 4. businessService
<businessService serviceKey="required"
businessKey="optional">
<name></name>
<description></description>
<bindingTemplates>
<bindingTemplate serviceKey="optional" bindingKey="required">
...
</bindingTemplate>
</bindingTemplates>
<categoryBag>
...
</categoryBag>
</businessService>
|
BindingTemplate
Tmodelinstancedetails
指示其兼容的應用程序或規范。請參見清單 5。
清單 5. bindingTemplate
<bindingTemplate
serviceKey="optional"
bindingKey="required">
<accessPoint> OR <hostingRedirector bindingKey="another
binding to be used instead">
<tModelInstanceDetails>
<tModelInstanceDetail>
<tModelInstanceInfo tModelKey=""uuid key for specification tModel">>
<description></description>
<instanceDetails>
<description></description>
<overviewDoc>
<description></description>
<overviewURL></overviewURL>
</overviewDoc>
<instanceParams>string</intstanceParms>
</instanceDetails>
</tModelInstanceInfo>
<tModelInstanceInfo>
...
</tModelInstanceInfo>
</tModelInstanceDetail>
<tModelInstanceDetails>
</bindingTemplate>
TModels (including tModel of tModels)
Serve two purposes. As specification indicators, and as namespace indicators.
<tModel tModelKey="required" operator="optional"
authorizedName="optional">
<name></name>
<description></description>
<overviewDoc>
<description></description>
<overviewURL></overviewURL>
<overviewDoc>
<identifierBag>
...
</identifierBag>
<categoryBag>
...
</categoryBag>
</tModel>
|
bindingTemplate
定義在何處能找到服務以及其執行什么工作,這聽起來并不復雜。不過,這兩項功能在 UDDI 上下文中擔任了新的重要角色。例如,為了確定可以在何處訪問服務,可以提供 accessPoint
(表示簡單的 URL)或任何其他相應的數據,如求助熱線的號碼或 hostingRedirector
。
|
分類法
對信息進行分類時,如果能就如何進行分類達成一致則很有幫助。這些一致同意的分類標準稱為分類法。
例如,北美工業分類系統 (NAICS) 通過為每種類別指定一個唯一代碼來區分“體育用品出租”、“體育用品商店”和“二手體育用品商店”。這樣,當遇到代碼 532292 時,就知道所說的是出租體育用品的商家,而不是出售這些東西的商家。
UDDI 操作員向系統添加一系列分類法作為例行規定,可供您在無需為其注冊 tModels 的情況下使用。例如,jUDDI 可以使用 tModel 鍵 A035A07C-F362-44DD-8F95-E2B134BF43B4 為 uddi-org:general_keywords 創建 tModel ,因此您可以使用它,而不必自己定義。
|
|
當服務的綁定發生更改時,將使用 hostingRedirector
。例如,如果 Daily Moon 要建立自己的分類廣告服務,并允許這兩家報社使用 createNewAdd()
調用提交廣告,則需要確保服務永遠不會更改,或者提供一個方法來告知客戶機服務已發生更改。而這就是要使用 hostingRedirector
的地方。在這種情況下,Francis(或實際由 Gene 進行)將創建一個新 bindingTemplate
,用于表示新信息,并將該 bindingTemplate
的 bindingKey
輸入 hostingRedirector
元素的 bindingKey
屬性中。
定義服務能進行的工作可能會更困難。這個原因是兩方面的。首先,由于我們討論的并不一定是 SOAP 服務,因此無法直接為其提供 WSDL 文件。其次,由于這應該是一個自動化過程,因此需要以無歧義的方式提供此信息。
這樣所得的結果是一個包括 tModelInstanceDetails
元素的 bindingTemplate
,而此元素中又包含一個或多個 tModelInstanceDetail
元素。每個 tModelInstanceDetail
元素又包含一個或多個 tModelInstanceInfo
元素,而后者各自指向一個特定的 tModel
。我們稍后將對 tModels
進行討論。不過,重要的是要理解,tModelInstanceInfo
元素可以包含一個 instanceDetails
元素,后者本身包含一個 overviewDoc
,其中包括 overviewURL
,即實際定義服務的文檔的 URL。(是的,就是在此處指定 WSDL 文件。)
TModels(包括 tModels 的 tModel)
現在讓我們討論一下 tModels
。
tModels
實際有兩個用途。第一,就是我們在關于 publisherAssertions
的討論中了解到的,作為“命名空間指示符”。也就是說,tModel
可以提供用于區分很容易混淆的信息類型的方法。經常給出的一個例子是稅碼(或其他很容易混淆的數字)。例如,包含以下內容的 keyedReference
并不會提供所有信息,因為這兩個稅務 ID 屬于不同的國家。它們在兩個國家里都稱為稅務 ID,但就編程而言,我們必須提供一個區分二者的方法,如清單 6 中所示。
清單 6. 來自不同國家的稅務 ID
<keyedReference tModelKey="" keyName="taxid"
keyValue="11111111" />
<keyedReference tModelKey="" keyName="taxid"
keyValue="22222222" />
|
這就是要使用 tModel
的地方。我們可以為“美國稅碼”創建一個鍵模型,再為“墨西哥稅碼”創建一個鍵模型,依此類推。創建了這些模型后,可以使用其 tModel
鍵來進一步限定這些 keyedReference
。請參見清單 7。
清單 7. tModels 和 keyedReferences
<tModel tModelKey="902CDE50-D53A-11DA-B055-A74C17FA61A7">
<name>United States codes</name>
</tModel>
<tModel tModelKey="062377D0-D5F5-11DA-8170-8ACF057FECAD">
<name>Mexico codes</name>
</tModel>
<keyedReference tModelKey="902CDE50-D53A-11DA-B055-A74C17FA61A7"
keyName="taxid" keyValue="11111111" />
<keyedReference tModelKey="062377D0-D5F5-11DA-8170-8ACF057FECAD"
keyName="taxid" keyValue="22222222" />
|
tModel
的另一個用途是作為規范標識符。例如,Francis 知道 Gene 將為上個月所處理的 ClassifiedService
創建相應的條目。此服務表示特定的接口,因此可以使用 tModel
對其進行標識。tModel
可能與清單 8 中所示類似。
清單 8. tModel
<tModel tModelKey="66999A50-D5F4-11DA-9A50-FA44D6AD622A"
operator="optional" authorizedName="optional">
<name>Classified Service Interface</name>
<description></description>
<overviewDoc>
<description></description>
<overviewURL>
http://www.daily-moon.com/ClassifiedService-interface.wsdl
</overviewURL>
<overviewDoc>
<identifierBag>
...
</identifierBag>
<categoryBag>
...
</categoryBag>
</tModel>
|
和我們所討論的各個其他對象一樣,tModel
具有一個唯一鍵,這是它唯一必需的信息。不過,在本例中,我們還要指定 overviewURL
,即接口的 WSDL 文件的 URL。(我們將在后面部分創建它。)
同樣,可以使用 identifierBag
對 tModels
進行標識,還可以使用 categoryBag
對其進行歸類。接下來讓我們看一看如何進行此工作。
identifierBag
由于 UDDI 設計十分靈活,因此沒有特定的方式來標識 businessEntity。UDDI 并不強制要求使用其 D-U-N-S 編號、其稅務 ID 編號或任何特定的標識方法對公司進行標識。相反,它提供了一個容器,可以根據需要在其中放置任意數量的標識符,如清單9 中所示。
清單 9. indentifierBag
<identifierBag>
<keyedReference
tModelKey="4064C064-6D14-4F35-8953-9652106476A9"
keyName="DUNS Number" keyValue="55555555" /><keyedReference tModelKey=""
keyName="US Tax ID" keyValue="111111111" />
</identifierBag>
|
在 identifierBag
中添加的每個 keyedReference
都代表用戶在搜索中找到相關對象的另一個機會。
categoryBag
categoryBag
的工作方式與 identifierBag
類似,因為其中包含一個或多個 keyedReferences
。請參見清單 10。
清單 10. categoryBag
<categoryBag>
<keyedReference
tModelKey="C0B9FE13-179F-413D-8A5B-5004DB8E5BB2"
keyName="optional" keyValue="511110" />
</categoryBag>
|
在本例中,Francis 創建了一個 categoryBag
,指示 Daily Moon 是一個報社分支機構?,F在讓我們了解如何使用所有這些對象。
將 WSDL 映射到 UDDI
在 Gene 編寫任何代碼將所有這些信息發送到 UDDI 注冊中心前,他必須在其當前服務和 UDDI 之間建立一個重要的聯系。他必須對其進行調整,以適應 UDDI 的服務、接口和綁定模板概念。
服務與接口
您可能還記得,服務在 UDDI 中包含三個部分:接口(使用 tModels
定義)、businessService
和 bindingTemplate
(用于將兩者捆綁在一起)。因此,Gene 將首先確定用于定義 SOAP 服務的 WSDL 文件如何適應此結構。
他首先對 WSDL 進行分析。幸運的是,這非常簡單。除了實現本身外,其余所有 WSDL 內容都屬于接口。請參見清單 11。
清單 11. WSDL 接口
<wsdl:definitions xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:tns="http://ws.apache.org/axis2"
xmlns:axis2="http://ws.apache.org/axis2"
xmlns:ns1="http://org.apache.axis2/xsd"
targetNamespace="http://ws.apache.org/axis2">
<wsdl:types>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://org.apache.axis2/xsd"
elementFormDefault="unqualified"
attributeFormDefault="unqualified">
<xs:element type="ns1:ClassifiedAd" name="ClassifiedAd"
/>
<xs:complexType name="ClassifiedAd">
<xs:sequence>
<xs:element type="xs:int" name="id" />
<xs:element type="xs:string" name="content" />
<xs:element type="xs:string" name="endDate" />
<xs:element type="xs:string" name="startDate" />
</xs:sequence>
</xs:complexType>
...
</xs:schema>
</wsdl:types>
<wsdl:message name="createNewAdRequestMessage">
<wsdl:part name="part1" element="ns1:createNewAdRequest" />
</wsdl:message>
<wsdl:message name="createNewAdResponseMessage">
<wsdl:part name="part1" element="ns1:createNewAdResponse" />
</wsdl:message>
...
<wsdl:portType name="ClassifiedServicePortType">
<wsdl:operation name="finalizeIssue">
<wsdl:input message="tns:finalizeIssueRequestMessage" />
</wsdl:operation>
<wsdl:operation name="createNewAd">
<wsdl:input message="tns:createNewAdRequestMessage" />
<wsdl:output message="tns:createNewAdResponseMessage" />
</wsdl:operation>
...
</wsdl:portType>
<wsdl:binding name="ClassifiedServiceBinding"
type="tns:ClassifiedServicePortType">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http"
style="document" />
<wsdl:operation name="createNewAd">
<soap:operation soapAction="createNewAd" style="document"
/>
<wsdl:input>
<soap:body use="literal"
namespace="http://ws.apache.org/axis2" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal"
namespace="http://ws.apache.org/axis2" />
</wsdl:output>
</wsdl:operation>
...
</wsdl:binding>
</wsdl:definitions>
|
這包括類型定義(XML 模式)、任何消息、portType
甚至 binding
,因為綁定并不是特定于實現的。
實現由實際的服務元素組成。請參見清單 12。
清單 12. 服務實現 WSDL
<wsdl:definitions xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:tns=
"http://www.daily-moon.com/ClassifiedService-interface"
xmlns:axis2="http://ws.apache.org/axis2"
xmlns:ns1="http://org.apache.axis2/xsd"
targetNamespace=
"http://www.daily-moon.com/ClassifiedService-interface">
<wsdl:import namespace="http://ws.apache.org/axis2"
location=
"http://www.nicholaschase.com/ClassifiedService-interface.wsdl"
/>
<wsdl:service name="ClassifiedService">
<wsdl:port name="ClassifiedServicePort"
binding="axis2:ClassifiedServiceBinding">
<soap:address
location=
"http://www.daily-moon.com:8080/axis2/services/ClassifiedService"
/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
|
請注意,實現文件導入了接口文件。也就是說,此文件是服務的完整定義。
現在讓我們來看一看這如何與我們的 UDDI 對象對應。
將接口映射到 tModel
Gene 首先必須將接口映射到相應的 tModel
。請參見清單 13。
清單 13. tModel
<tModel tModelKey="66999A50-D5F4-11DA-9A50-FA44D6AD622A">
<name>http://www.daily-moon.com/ClassifiedService-
interface</name>
<description>Interface for the Daily Moon Classified
Department web application</description>
<overviewDoc>
<description>WSDL interface document</description>
<overviewURL>
http://www.daily-moon.com/ClassifiedService-interface.wsdl
</overviewURL>
<overviewDoc>
<categoryBag>
<keyedReference
tModelKey="C1ACF26D-9672-4404-9D70-39B756E62AB4"
keyName="uddi-org:types" keyValue="wsdlSpec" />
<keyedReference
tModelKey="C0B9FE13-179F-413D-8A5B-5004DB8E5BB2"
keyName="ntis-gov:naics:1997" keyValue="511110" />
</categoryBag>
</tModel>
|
首先看最下面,請注意 categoryBag
。Gene 添加了兩個 keyReferences
。第一個指定我們事實上在處理 WSDL 文件。已預定義了特定的 tModelKey
來表示 uddi-org:types
命名空間。所有 WSDL 文件都必須采用這種方式指定。第二個引用綁定到 ntis-gov:naics:1997
命名空間,因此 Gene 的用戶可以方便地在表示與報紙有關的服務的所有 WSDL 文件中找到此定義。繼續往上,我們可以看到 overviewDoc
。除了可選描述外,它還指定了實際的 URL,可以在此處找到 WSDL 文件。
最后,tModel
的名稱應與 WSDL 文件的目標命名空間匹配。
將實現映射到綁定模板
Gene 接下來必須將實現本身映射到 bindingTemplate
。請參見清單 14。
清單 14. bindingTemplate
<bindingTemplate serviceKey="" bindingKey="">
<accessPoint>
http://www.daily-moon.com:8080/axis2/services/ClassifiedService
</accessPoint>
<tModelInstanceDetails>
<tModelInstanceDetail>
<tModelInstanceInfo
tModelKey="66999A50-D5F4-11DA-9A50-FA44D6AD622A">
<instanceDetails>
<description>The canonical implementation of
the Daily Moon's classified
service.</description>
<overviewDoc>
<overviewURL>
http://www.daily-moon.com/ClassifiedService-impl.wsdl
</overviewURL>
</overviewDoc>
</instanceDetails>
</tModelInstanceInfo>
</tModelInstanceDetail>
</tModelInstanceDetails>
</bindingTemplate>
|
這里我們看到,Gene 創建了一個新 bindingTemplate
,并將 accessPoint
設置為實際服務的 URL。鍵 modelInstanceDetails
將接口 tModel
(通過 tModelKey
)鏈接到實現文檔(在 overviewDoc
中指定)?,F在他只需要從服務引用它即可。
從 businessService 和 businessEntity 引用 bindingTemplate
最后一步是將所有這些組裝起來,并從 businessService
引用 bindingTemplate
、從 businessEntity
引用 businessService
。請參見清單 15。
清單 15. 完整的 businessEntity
<businessEntity businessKey="1A3DB880-D5F4-11DA-B880-F94D3591C691">
<name>The Daily Moon</name>
<name lang="fr-ca">La Lune Quotidienne</name>
<contacts>
<contact>
<personName>Pat Mooney</personName>
<email>patm@daily-moon.com</email>
</contact>
</contacts>
<businessServices>
<businessService
serviceKey="064B4170-D5F5-11DA-8170-A74C17FA61A7">
<name>ClassifiedService</name>
<bindingTemplates>
<bindingTemplate
bindingKey="904BD800-D53A-11DA-B055-850A1DA99D79">
<accessPoint>
http://www.daily-moon.com:8080/axis2/services/ClassifiedService
</accessPoint>
<tModelInstanceDetails>
<tModelInstanceDetail>
<tModelInstanceInfo
tModelKey="66999A50-D5F4-11DA-9A50-FA44D6AD622A">
<instanceDetails>
<description>The canonical
implementation of the Daily Moon's classified
service.</description>
<overviewDoc>
<overviewURL>
http://www.daily-moon.com/ClassifiedService-impl.wsdl
</overviewURL>
</overviewDoc>
</instanceDetails>
</tModelInstanceInfo>
</tModelInstanceDetail>
</tModelInstanceDetails>
</bindingTemplate>
</bindingTemplates>
<categoryBag>
<keyedReference
tModelKey="C1ACF26D-9672-4404-9D70-39B756E62AB4"
keyName="uddi-org:types" keyValue="wsdlSpec" />
<keyedReference
tModelKey="C0B9FE13-179F-413D-8A5B-5004DB8E5BB2"
keyName="ntis-gov:naics:1997" keyValue="511110" />
</categoryBag>
</businessService>
</businessServices>
<identifierBag>
<keyedReference
tModelKey="4064C064-6D14-4F35-8953-9652106476A9"
keyName="DUNS Number" keyValue="55555555" />
<keyedReference tModelKey=""
keyName="US Tax ID" keyValue="111111111" />
</identifierBag>
<categoryBag>
<keyedReference
tModelKey="C0B9FE13-179F-413D-8A5B-5004DB8E5BB2"
keyName="optional" keyValue="511110" />
</categoryBag>
</businessEntity>
|
也就是說,服務現在已經完成:Gene 現在有了一個包含服務的 businessEntity
。
posted on 2006-12-29 19:32
SIMONE 閱讀(1245)
評論(0) 編輯 收藏 所屬分類:
AXIS 、
JAVA