juddi操作界面的基本使用


文章分类:Web前端

转自链接:http://www.cnblogs.com/kangjj22/archive/2009/01/09/1372394.html 

这一段时间快被这个晕死人的软件工程大作业折腾死了,总体感觉倒也不是说有多难,但理解这个juddi做的接口要uddi基础知识,像我这样菜鸟级用户,连web service都没怎么听说过,摸到门都花了好多时间和精力。网上这方面的资料实在是太少了,中文的帖子全是讲juddi的安装配置的,而且都是转来转去的,有的安装时遇到的关键[size=medium][/size]性的问题都没有人回答,英文都说实话又看不太进去...= =诶诶诶~ 

由于参考资料少,又没有花太多心思去读,我们一开始绕到 IBM的uddi4j上去了,花了半天调试通了能够findBusiness了,总算对uddi有了一个初步的概念。但是这段路也算是个小小的弯路吧~后来才意识到uddi4j的那个测试的代码和juddi的jsp界面提供的应该都是注册和查询服务等的API,晕~真够笨的。 

现在差不多把这个作业弄了大半部分了,自己先做个初步的总结,留在这里备忘。 

0.老师给的课程作业要求 

基于JUDDI的WEB服务注册中心,增加WEB服务非功能属性描述模块。利用第1组从WORDNET获取的语义信息在JUDDI注册中心查询用户需要的服务, 查询利用JUDDI的查询API自动完成。(并可根据查询结果对服务进行进一步分类,包括严格按功能、输入/输出的个数、类型完全一致和部分一致的分类.) 

JUDDI是Apache基金会下Web Services小组的一个开源项目,也是基于java并且符合UDDI规范的实现。主要具有以下特点: 

开放源代码,底层包可以采用jdk1.3及其以后版本(后来证明juddi是不完全支持JDK1.6的,这一点上花了太多的时间,好在丁丁同学目光如炬),具有平台无关性; 

后台数据库可以采用任何支持ANSI标准的数据库,例如MySQL,DB2等; 

可以将其发布到任何支持Servlet2.3标准的java应用服务器上,例如JakartaTomcat, WebSphere,WebLogic等; 



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 fault code 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的一些通信机制,这里我们没有深究,只是简单地把它拿来用。 

我们在数据库中设计了一个service的非功能属性的table用来拓展juddi功能 
USE juddi; 

CREATE TABLE service_quality ( 
  SERVICE_KEY varchar(41), 
  PRICE varchar(10), 
  USER_VALUATION varchar(5), 
  EXECUTE_TIME varchar(10), 
  RELIABILITY varchar(5), 
  APPLICABILITY varchar(5), 
  LANGUAGE varchar(10), 
  SECURITY varchar(5), 
   PRIMARY KEY  (SERVICE_KEY) 
); 


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

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:Envelope xmlns: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 University of China</description> 
        <contacts> 
          <contact useType="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: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> 
  <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 of China</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:Envelope xmlns: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>Hello World</description> 
        <overviewDoc> 
          <description></description> 
          <overviewURL>http://localhost:8080/WebProjectDemo/services/HelloWorld#HelloWorldSoapBinding</overviewURL>
        </overviewDoc> 
        <identifierBag> 
          <keyedReference tModelKey="" keyName="" keyValue="" /> 
        </identifierBag> 
        <categoryBag> 
          <keyedReference tModelKey="" 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: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> 
  <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:Envelope xmlns: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> 
      <businessService businessKey="EE976890-DD82-11DD-ADFB-8828584945B5" serviceKey=""> 
        <name>HelloWorld</name> 
        <description>HelloWorld</description> 
        <bindingTemplates> 
          <bindingTemplate bindingKey=""> 
            <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: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> 
  <serviceDetail generic="2.0" operator="jUDDI.org" xmlns="urn:uddi-org:api_v2"> 
   <businessService businessKey="EE976890-DD82-11DD-ADFB-8828584945B5" serviceKey="B052F6D0-DD8C-11DD-ADFB-DB56A1983284"> 
    <name>HelloWorld</name> 
    <description>HelloWorld</description> 
    <bindingTemplates> 
     <bindingTemplate bindingKey="B05567D0-DD8C-11DD-ADFB-C11B5D72DD9F" serviceKey="B052F6D0-DD8C-11DD-ADFB-DB56A1983284"> 
      <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> 
  </serviceDetail> 
</soapenv:Body> 
</soapenv:Envelope> 


2.5 find_tmodel 
输入 
<?xml version="1.0" encoding="utf-8"?> 
<soapenv:Envelope xmlns: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> 
        <keyedReference tModelKey="***" keyName="***" keyValue="***" /> 
      </identifierBag> 
      <categoryBag> 
        <keyedReference tModelKey="***" 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: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> 
  <tModelList generic="2.0" operator="jUDDI.org" xmlns="urn:uddi-org:api_v2"> 
   <tModelInfos> 
    <tModelInfo tModelKey="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: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> 
  <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:Envelope xmlns: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: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> 
  <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:Envelope xmlns: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: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> 
  <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> 
    <serviceInfo businessKey="BB3604C0-DB02-11DD-AA81-B82AA209A326" serviceKey="CADE5640-DC86-11DD-9640-8799713EAEDE"> 
     <name>HelloWorld</name> 
    </serviceInfo> 
   </serviceInfos> 
  </serviceList> 
</soapenv:Body> 
</soapenv:Envelope> 

  

参考到的几个还不错的网页 
UDDI V2.03 Data Structure Specification 
businessEntity、tModel、businessService等结构的一些格式规范 
http://www.uddi.org/pubs/DataStructure_v2.htm#_Toc25130763 

Web 服务:UDDI专题 
http://www.ibm.com/developerworks/cn/webservices/ws-theme/ws-uddi.html 

Creating and publishing Web Services to jUDDI 
在eclipse里配置,研究了好一阵,虽然没太用上...留在这里备忘下 
http://www.mail-archive.com/[email protected]/msg00472.htm l 

使用 UDDI 的 Web 服务描述和发现(第一部分)+(第二部分) 
微软的帖子,帮助我澄清了一些概念 
http://bbs.w3china.org/dispbbs.asp?boardID=10&ID=571 0 

你可能感兴趣的:(DI)