Uddi注册中心教程

                                                      文/54dabang

                                                      Email:[email protected]

一 前言

     工欲善其事,必先利其器。在学习uddi注册中心的过程中,我深刻认识到有好的资料是非常重要的。由于在学习的前期,看到的都是非常零碎的资料,走了非常多的弯路。在学习的后期,偶然看到IBM网上UDDI注册中心教程,看完之后才恍然大悟。

在学习uddi注册中心之前,首先贴出IBM的教程,相信所有人在看完这些资料之后都可以理解wsdl文档的结构以及内容,了解uddi注册中心的原理,清晰的明白如何解析wsdl文档,并将其注册到uddi注册中心中,通过服务的查找,查找出自己所需要的服务。

1.理解uddi

1.1理解uddi注册中心里面的wsdl的第一部分

http://www.ibm.com/developerworks/cn/webservices/ws-uwsdl/part1/index.html

 

此教程中,详细解释了从 wsdl文档元素结构 到uddi注册中心数据类型 的映射关系,wsdl文档的结构。

1.2理解uddi注册中心里面的wsdl的第二部分

      http://www.ibm.com/developerworks/cn/webservices/ws-uwsdl/part2/index.html

 

此教程包含在“UDDI 注册中心”发布和查找完整的 WSDL 服务描述的用法个案研究,包含:(1)没有服务实现的服务接口(2)带有一个服务接口文档的服务实现(3)带有多个服务接口文档的服务实现(4)单个 WSDL 文档(5)引用另一个服务接口的服务接口

1.3理解uddi注册中心里面的wsdl第三部分

   http://www.ibm.com/developerworks/cn/webservices/ws-uwsdl/part3/index.html

此教程将会教会您您将学会如何开发两个在 UDDI 注册中心中发布 WSDL 服务描述的 Java 应用程序。

特别需要注意的是,IBM已经提供了wsdl 文档 解析服务接口和服务实现,并且注册到uddi中心的源代码:

   如果需要,可以将其下载下来,放到java工程中使用:

   发布wsdl服务接口:

http://www.ibm.com/developerworks/cn/webservices/ws-uwsdl/part3/PublishServiceInterface.java

发布wsdl服务实现:

http://www.ibm.com/developerworks/cn/webservices/ws-uwsdl/part3/PublishServiceImplementation.java

2.发布uddi

 2.1 关于教程

  http://www.ibm.com/developerworks/cn/education/webservices/ws-psuddi/index.html

2.2 UDDI 概述

http://www.ibm.com/developerworks/cn/education/webservices/ws-psuddi/index.html

   此教程提供了 UDDI 的高级概述,然后研究了如何用几种方法发布到 UDDI 注册中心。(两种方式:一种是通过 UDDI4J 发布,解析wsdl,然后注册到uddi中心,另外一种是通过GUI界面,自己填写,注册到uddi中心)。

2.3.使用 WSDK UDDI GUI

http://www.ibm.com/developerworks/cn/education/webservices/ws-psuddi/section3.html

2.4深入研究深入研究 UDDI

http://www.ibm.com/developerworks/cn/education/webservices/ws-psuddi/section4.html

2.5从命令行发布服务

http://www.ibm.com/developerworks/cn/education/webservices/ws-psuddi/section6.html

2.6 用uddi4j发布

http://www.ibm.com/developerworks/cn/education/webservices/ws-psuddi/section7.html

3. 发现Web 服务:UDDI

3.1关于本教程

 http://www.ibm.com/developerworks/cn/education/webservices/ws-dwsuddi/index.html

3.2 UDDI 回顾

http://www.ibm.com/developerworks/cn/education/webservices/ws-dwsuddi/section2.html

3.3WSDK UDDI GUI

http://www.ibm.com/developerworks/cn/education/webservices/ws-dwsuddi/section3.html

3.4 开始使用 UDDI4J

http://www.ibm.com/developerworks/cn/education/webservices/ws-dwsuddi/section4.html

3.5查找技术模型

 http://www.ibm.com/developerworks/cn/education/webservices/ws-dwsuddi/section5.html

3.6 查找 BusinessService

http://www.ibm.com/developerworks/cn/education/webservices/ws-dwsuddi/section6.html

3.7查找 BusinessEntity

http://www.ibm.com/developerworks/cn/education/webservices/ws-dwsuddi/section6.html

3.8使用 UDDI4J 获取详细信息

http://www.ibm.com/developerworks/cn/education/webservices/ws-dwsuddi/section8.html

3.9实验:UDDI4J 的完整编程示例

http://www.ibm.com/developerworks/cn/education/webservices/ws-dwsuddi/section9.html

二 搭建uddi注册中心时遇到的问题


1.安装
网上说安装的帖子很多,基本流程还是对的,我这里主要参考了http://www.cnblogs.com/kevin-wu/archive/2007/05/21/754157.html这篇帖子
但是一定要注意JDK版本不能是1.6,因为如果是JDK1.6,在测试安装是否成功的页面http://localhost:8080/juddi/happyjuddi.jsp时, 就会有SOAPMessage和SAXParserFactory两个类Found in an unknown location,其中SOAPMessage还是很重要的,应该是和SOAP通信有关,如果找不到就会导致后面findBusiness等不能执行,出 现fault string and possibly faultcode is not set的错误。

如果运行环境是JRE1.5的版本那么这个包就能找到
Looking for: javax.xml.soap.SOAPMessage
+Found in: D:\Program Files\Tomcat\webapps\juddi\WEB-INF\lib\saaj.jar

2.使用
观察到 Tomcat\webapps\juddi\console目录下的jsp文件,每个api都用一个jsp文件实现,最终都提交表单到controller.jsp文件。对这个controller.jsp,它内部实现了SOAP的一些通信机制,这里我们没有深究,只是简单地把它拿来 用。


下一步要解决的是
改动这个目录下的API,查找服务时既能查出原有的服务的属性,又能查出我们新加入的非功能属性。
简单分析了一下(这里可能会有不确切的地方),要注册一个服务,首先要得到一个authToken,然后根据它注册bussinessEntity信息,然后注册tModel信息,最后注册service信息。

打开:http://localhost:8080/juddi/console/可以看到相应的链接页面

2.1 get_authToken
打开 http://localhost:8080/juddi/console/get_authToken.jsp,可以看到默认提交的表单是一个SOAP 请求,代码表示它将soap_request传递给controller.jsp,然后将返回的消息responseMessage显示在下面的文本区 中。***表示可能需要填写的部分,在这里*号部分是我们要提交的内容userID和cred,如果用户名userID不正确则会返回一个SOAP应答, 但是cred随便填一个数也能得到authToken,不知道是为什么了。填写juddi和juddi,然后submit,得到一个authToken, 即authToken:8FE01220-DD7D-11DD-ADFB-B7B7EF162770。

<?xml version="1.0"encoding="UTF-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"xmlns:xsd="http://www.w3.org/2001/XMLSchema"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
 <soapenv:Body>
  <authToken generic="2.0" operator="jUDDI.org"xmlns="urn:uddi-org:api_v2">
   <authInfo>authToken:8FE01220-DD7D-11DD-ADFB-B7B7EF162770</authInfo>
  </authToken>
 </soapenv:Body>
</soapenv:Envelope>

2.2 save_business
get_authToken中的authToken:8FE01220-DD7D-11DD-ADFB-B7B7EF162770这一行覆盖<authInfo>后面的*,记得<name>属性是必填的,其他好像都是可选的

输入
<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelopexmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
  <soapenv:Body>
    <save_business generic="2.0"xmlns="urn:uddi-org:api_v2">
     <authInfo>authToken:8FE01220-DD7D-11DD-ADFB-B7B7EF162770</authInfo>
      <businessEntity businessKey="">
        <name>ruc</name>
        <description>Renmin Universityof China</description>
        <contacts>
          <contactuseType="technical contact">
           <personName>Kang</personName>
           <phone>010-62510000</phone>
           <email>[email protected]</email>
          </contact>
        </contacts>
      </businessEntity>
    </save_business>
  </soapenv:Body>
</soapenv:Envelope>

得到
<?xml version="1.0"encoding="UTF-8"?><soapenv:Envelopexmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"xmlns:xsd="http://www.w3.org/2001/XMLSchema"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
 <soapenv:Body>
  <businessDetail generic="2.0"operator="jUDDI.org" xmlns="urn:uddi-org:api_v2">
   <businessEntity authorizedName="juddi"businessKey="EE976890-DD82-11DD-ADFB-8828584945B5"operator="jUDDI.org">
    <discoveryURLs>
     <discoveryURL useType="businessEntity">http://localhost:8080/juddi/uddiget.jsp?businesskey=EE976890-DD82-11DD-ADFB-8828584945B5</discoveryURL>
    </discoveryURLs>
    <name>ruc</name>
    <description>Renmin University ofChina</description>
    <contacts>
     <contact useType="technical contact">
      <personName>Kang</personName>
      <phone>010-62510000</phone>
      <email>[email protected]</email>
     </contact>
    </contacts>
   </businessEntity>
  </businessDetail>
 </soapenv:Body>
</soapenv:Envelope>


2.3 save_tModel
tModel是一个技术指纹,一个service可以对应多个tModel

输入
<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelopexmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
  <soapenv:Body>
    <save_tModel generic="2.0"xmlns="urn:uddi-org:api_v2">
      <authInfo>authToken:3348A9F0-DD82-11DD-ADFB-9513937BB2B2</authInfo>
      <tModel tModelKey="">
        <name>HelloWorld</name>
        <description>HelloWorld</description>
        <overviewDoc>
         <description></description>
         <overviewURL>http://localhost:8080/WebProjectDemo/services/HelloWorld#HelloWorldSoapBinding</overviewURL>
        </overviewDoc>
        <identifierBag>
          <keyedReferencetModelKey="" keyName="" keyValue="" />
        </identifierBag>
        <categoryBag>
          <keyedReferencetModelKey="" keyName="" keyValue="" />
        </categoryBag>
      </tModel>
    </save_tModel>
  </soapenv:Body>
</soapenv:Envelope>

其中
overviewURL 是服务实现文档的位置
<overviewURL>
http://localhost:8080/WebProjectDemo/services/HelloWorld#HelloWorldSoapBinding
</overviewURL>
其中http://localhost:8080/WebProjectDemo/services/HelloWorld是HelloWorld.wsdl文件中的address location,HelloWorldSoapBinding是HelloWorld.wsdl文件中的binding name

得到
<?xml version="1.0"encoding="UTF-8"?><soapenv:Envelopexmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"xmlns:xsd="http://www.w3.org/2001/XMLSchema"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
 <soapenv:Body>
  <tModelDetail generic="2.0" operator="jUDDI.org"xmlns="urn:uddi-org:api_v2">
   <tModel authorizedName="juddi" operator="jUDDI.org"tModelKey="uuid:59EFA030-DD88-11DD-ADFB-A2381C34199F">
    <name>HelloWorld</name>
    <description>Hello World</description>
    <overviewDoc>
    <overviewURL>http://localhost:8080/WebProjectDemo/services/HelloWorld#HelloWorldSoapBinding</overviewURL>
    </overviewDoc>
    <identifierBag>
     <keyedReference keyName=""keyValue="" tModelKey=""/>
    </identifierBag>
    <categoryBag>
     <keyedReference keyName=""keyValue=""tModelKey="UUID:A035A07C-F362-44dd-8F95-E2B134BF43B4"/>
    </categoryBag>
   </tModel>
  </tModelDetail>
 </soapenv:Body>
</soapenv:Envelope>

2.4 save_service
输入
<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelopexmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
  <soapenv:Body>
    <save_service generic="2.0"xmlns="urn:uddie-org:api_v2">
     <authInfo>authToken:3348A9F0-DD82-11DD-ADFB-9513937BB2B2</authInfo>
      <businessServicebusinessKey="EE976890-DD82-11DD-ADFB-8828584945B5"serviceKey="">
        <name>HelloWorld</name>
        <description>HelloWorld</description>
        <bindingTemplates>
          <bindingTemplatebindingKey="">
           <accessPoint URLType="http">http://localhost:8080/</accessPoint>
           <tModelInstanceDetails>
             <tModelInstanceInfo tModelKey="uuid:0978C270-DD89-11DD-ADFB-E44D6510EEF7">
               <instanceDetails>
                 <overviewDoc>
                   <overviewURL>http://localhost:8080/WebProjectDemo/services/HelloWorld#HelloWorldSoapBinding</overviewURL>
                 </overviewDoc>
               </instanceDetails>
             </tModelInstanceInfo>
           </tModelInstanceDetails>
          </bindingTemplate>
        </bindingTemplates>
      </businessService>
    </save_service>
  </soapenv:Body>
</soapenv:Envelope>

得到
<?xml version="1.0"encoding="UTF-8"?><soapenv:Envelopexmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"xmlns:xsd="http://www.w3.org/2001/XMLSchema"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
 <soapenv:Body>
  <serviceDetail generic="2.0" operator="jUDDI.org"xmlns="urn:uddi-org:api_v2">
   <businessServicebusinessKey="EE976890-DD82-11DD-ADFB-8828584945B5"serviceKey="B052F6D0-DD8C-11DD-ADFB-DB56A1983284">
    <name>HelloWorld</name>
    <description>HelloWorld</description>
    <bindingTemplates>
     <bindingTemplatebindingKey="B05567D0-DD8C-11DD-ADFB-C11B5D72DD9F"serviceKey="B052F6D0-DD8C-11DD-ADFB-DB56A1983284">
      <accessPointURLType="http">http://localhost:8080/</accessPoint>
      <tModelInstanceDetails>
       <tModelInstanceInfotModelKey="uuid:0978C270-DD89-11DD-ADFB-E44D6510EEF7">
        <instanceDetails>
         <overviewDoc>
         <overviewURL>http://localhost:8080/WebProjectDemo/services/HelloWorld#HelloWorldSoapBinding</overviewURL>
         </overviewDoc>
        </instanceDetails>
       </tModelInstanceInfo>
      </tModelInstanceDetails>
     </bindingTemplate>
    </bindingTemplates>
   </businessService>
  </serviceDetail>
 </soapenv:Body>
</soapenv:Envelope>


2.5 find_tmodel
输入
<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelopexmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
  <soapenv:Body>
    <find_tModel generic="2.0"xmlns="urn:uddi-org:api_v2">
      <findQualifiers>
       <findQualifier>exactNameMatch</findQualifier>
     </findQualifiers>     
      <name>HelloWorld</name>
      <identifierBag>
        <keyedReferencetModelKey="***" keyName="***" keyValue="***"/>
      </identifierBag>
      <categoryBag>
        <keyedReferencetModelKey="***" keyName="***" keyValue="***"/>
      </categoryBag>
    </find_tModel>
  </soapenv:Body>
</soapenv:Envelope>

<findQualifier>的属性值大概有
exactNameMatch, orAllKeys ,andAllKeys等
http://www.uddi.org/pubs/ProgrammersAPI_v2.htm#_Toc25137773的APPENDIX E里面说得挺多的了。

返回
<?xml version="1.0"encoding="UTF-8"?><soapenv:Envelopexmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"xmlns:xsd="http://www.w3.org/2001/XMLSchema"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
 <soapenv:Body>
  <tModelList generic="2.0" operator="jUDDI.org"xmlns="urn:uddi-org:api_v2">
   <tModelInfos>
    <tModelInfotModelKey="uuid:57DEA0A0-DBBE-11DD-A95C-D13DE83070A5">
     <name>HelloWorld</name>
    </tModelInfo>
   </tModelInfos>
  </tModelList>
 </soapenv:Body>
</soapenv:Envelope>


2.6 find_service
这也是我们组做这个作业遇到的最大的一个问题,就是怎么也查不出服务
返回的消息总是

<?xml version="1.0"encoding="UTF-8"?><soapenv:Envelopexmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"xmlns:xsd="http://www.w3.org/2001/XMLSchema"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
 <soapenv:Body>
  <serviceList generic="2.0" operator="jUDDI.org"xmlns="urn:uddi-org:api_v2">
   <serviceInfos/>
  </serviceList>
 </soapenv:Body>
</soapenv:Envelope>

网上有类似提问的,就是没回答。今天早上灵光一现,发现只要把那些不查的属性去掉就可以了,搞了很么就居然这么简单,晕死晕死晕死...

按tModelKey查
<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelopexmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
  <soapenv:Body>
    <find_service generic="2.0"xmlns="urn:uddi-org:api_v2">
    <tModelBag>
       <tModelKey>uuid:0978C270-DD89-11DD-ADFB-E44D6510EEF7</tModelKey>
    </tModelBag>
</find_service>
  </soapenv:Body>
</soapenv:Envelope>
得到
<?xml version="1.0"encoding="UTF-8"?><soapenv:Envelopexmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"xmlns:xsd="http://www.w3.org/2001/XMLSchema"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
 <soapenv:Body>
  <serviceList generic="2.0" operator="jUDDI.org"xmlns="urn:uddi-org:api_v2">
   <serviceInfos>
    <serviceInfo businessKey="EE976890-DD82-11DD-ADFB-8828584945B5"serviceKey="B052F6D0-DD8C-11DD-ADFB-DB56A1983284">
     <name>HelloWorld</name>
    </serviceInfo>
   </serviceInfos>
  </serviceList>
 </soapenv:Body>
</soapenv:Envelope>

按服务名name查
输入
<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelopexmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
  <soapenv:Body>
    <find_service businessKey=""generic="2.0" xmlns="urn:uddi-org:api_v2">
      <findQualifiers>
       <findQualifier>orAllKeys</findQualifier>
     </findQualifiers>     
      <name>Hello</name>
    </find_service>
  </soapenv:Body>
</soapenv:Envelope>
得到
<?xml version="1.0"encoding="UTF-8"?><soapenv:Envelopexmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"xmlns:xsd="http://www.w3.org/2001/XMLSchema"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
 <soapenv:Body>
  <serviceList generic="2.0" operator="jUDDI.org"xmlns="urn:uddi-org:api_v2">
   <serviceInfos>
    <serviceInfobusinessKey="EE976890-DD82-11DD-ADFB-8828584945B5"serviceKey="B052F6D0-DD8C-11DD-ADFB-DB56A1983284">
     <name>HelloWorld</name>
    </serviceInfo>
    <serviceInfobusinessKey="BB3604C0-DB02-11DD-AA81-B82AA209A326"serviceKey="CADE5640-DC86-11DD-9640-8799713EAEDE">
     <name>HelloWorld</name>
    </serviceInfo>
   </serviceInfos>
  </serviceList>
 </soapenv:Body>
</soapenv:Envelope>

 

 

 

 

 

 

 

 

 

 

你可能感兴趣的:(Uddi注册中心教程)