jUDDI 简单安装使用

jUDDI,发音(Judy),是服务于WebServices 的UDDI的java实现开源包。

1 安装

1.1 下载

下载地址:http://ws.apache.org/juddi/releases.html

目前的jUDDI的最新版本是0.9rc3(Release Candidate #3 for Version 0.9),不过在这个版本中有一些的bug。

juddi0.9版本发布应该是不会久,可以参考下面这段话,是Viens Stephen(juddi主要开发者之一)在mail list中说的:we've closed 40+ issues since January 1, 2005. We'll be releasing a 0.9rc4 as soon as Axis 1.2 final is released and then releasing a 0.9 final a few weeks after that. (March 22, 2005)

1.2 数据库安装

UDDI需要有一个地方来存储注册的数据,因此首先要选择一个关系数据库安装。JUDDI可以使用任何支持ANSI standard SQL关系数据库( 例如MySQL, DB2, Sybase, JdataStore等)。本实例使用MySQL。

数据库安装完成后,在MySQL数据库中运行juddi-0.9rc3/sql/mysql/create_database.sql, juddi-0.9rc3/sql/mysql/insert_publishers.sql。数据库准备完成。

1.3 安装juddi及配置

首先将juddi-0.9rc3/webapp下的juddi文件夹复制到Tomcat下的webapps中,并将 mysql-connector-java-3.1.7/mysql-connector-java-3.1.7-bin.jar复制到Tomcat 5.0/webapps/juddi/WEB-INF/lib下。

下面就是连接数据库的配置,在Tomcat/conf/server.xml的Host element中加入:
<Context path="/juddi" docBase="juddi" debug="5" reloadable="true" crossContext="true">

<Logger className="org.apache.catalina.logger.FileLogger" prefix="localhost_juddiDB_log"

suffix=".txt" timestamp="true"/>

<Resource name="jdbc/juddiDB" auth="Container" type="javax.sql.DataSource"/>

<ResourceParams name="jdbc/juddiDB">

<parameter>

<name>factory</name>

<value>org.apache.commons.dbcp.BasicDataSourceFactory</value>

</parameter>

<!-- Maximum number of dB connections in pool. Make sure you

configure your mysqld max_connections large enough to handle

all of your db connections. Set to 0 for no limit. -->

<parameter><name>maxActive</name><value>100</value></parameter>

<!-- Maximum number of idle dB connections to retain in pool.

Set to 0 for no limit. -->

<parameter><name>maxIdle</name><value>30</value></parameter>

<parameter><name>maxWait</name><value>10000</value></parameter>

<!-- MySQL dB username and password for dB connections 帐号密码根据数据库安装配置修改 -->

<parameter><name>username</name><value>root</value></parameter>

<parameter><name>password</name><value>****</value></parameter>

<!-- Class name for mysql JDBC driver -->

<parameter>

<name>driverClassName</name>

<value>com.mysql.jdbc.Driver</value>

</parameter>

<!-- The JDBC connection url for connecting to your MySQL dB.

The autoReconnect=true argument to the url makes sure that the

mm.mysql JDBC Driver will automatically reconnect if mysqld closed the

connection. mysqld by default closes idle connections after 8 hours.

数据库url连接配置

-->

<parameter>

<name>url</name>

<value>jdbc:mysql://host.domain.com:3306/juddi?autoReconnect=true</value>

</parameter>

<parameter>

<name>validationQuery</name>

<value>select count(*) from PUBLISHER</value>

</parameter>

</ResourceParams>

</Context>

 

1.4 本地安装检查

访问http://127.0.0.1:8080/juddi/happyjuddi.jsp页面,此页面检查了jUDDI所必须的包和配置的正确性,并测试数据库连接是否成功。 如果没有红色文字,即本地安装成功,即可进行webservices的发布发现等服务。

2 测试实例



以上安装成功的是UDDI的服务器端,而进行发布、查找服务的客户端的应用则要用jUDDI、UDDI4J等包来进行开发。我们可以直接使用jUDDI自 带的测试代码来进行客户端使用的学习。

2.1 使用uddi4j测试

使用uddi4j作为客户端进行测试。

代码位置:juddi-0.9rc3/src/uddi4j/org/apache/juddi/uddi4j

新建立好一个工程并引入此代码,然后对代码进行必要的修改,主要是包名和配置。引入必要的包,比如:junit.jar、 uddi4j.jar、juddi.jar、soap.jar等(因为欧的代码库中有很多种代码,对应很多包,不知道其他哪些是必须的了:)。

接着是数据库的初始化,需要插入一个可以添加其他Publisher的Publisher,sql 语句: INSERT INTO PUBLISHER (PUBLISHER_ID,PUBLISHER_NAME,ENABLIED,ADMIN) VALUES ('juddi','juddi user','true','true');

调试代码后,运行TestAll测试,您可能会发现测试FAILURE很多,这些当中有些是测试代码的错误,也有可能是juddi-0.9rc3的缺陷( juddi-0.9rc3不是正式发布版)。

以下列举一些本测试案例测试失败的可能出现的修改方法:

2.1.1 加载配置文件时访问不到samples.prop

我的解决办法是将建立一个新配置文件位置,在工程目录下的:conf/samples.prop。

在Configurator.load()方法中代码可以这样修改:
    Properties config = new Properties();

try {

config.load(new java.io.FileInputStream("./conf/samples.prop"));

}

catch (Exception e) {

System.out.println("Error loading samples property file/n" + e);

}

 

解决方法很多,您可以自己思索。

2.1.2 TransportClassName配置错误

如果错误提示中有这样的报告,即可能是此错误:
org.xml.sax.SAXParseException: Element or attribute do not match QName production: QName::=(NCName':')?NCName.

在当前测试实例代码中的默认配置(samples.prop)中,TransportClassName定义成org.uddi4j.transport.ApacheSOAPTransport, 而我们使用的包是axis.jar,因此需要修改成相应的类,代码修改如下:
# -----------------------------------------------------------------------

# Transport classname. Typically defined on commandline as

# -Dorg.uddi4j.TransportClassName=xxx.

# -----------------------------------------------------------------------

#TransportClassName=org.uddi4j.transport.ApacheSOAPTransport

TransportClassName=org.uddi4j.transport.ApacheAxisTransport

# TransportClassName=org.uddi4j.transport.HPSOAPTransport

 

2.1.3 TestFindBusiness案例不通过

TestFindBusiness中有大小写匹配测试,但是在juddi-0.9rc3中的大小写匹配(caseSensitiveMatch)有bug,因此可以将大小写匹配的测 试案例注释掉。

2.1.4 PublisherManager的代码错误

在测试Test_save_tModel的时候_testAuthTokenExpired()中,我们测试过期验证时,在错误匹配的时候,会出现测试失败,如果捕捉这个 匹配的结果,你会发现,出错的类型是E_authTokenRequired而不是期待的E_authTokenExpired。

这是因为在我们所获得的AuthToken是空的,在根源就是在PublisherManager. getExpiredAuthToken(String, String)方法中,代码:
RegistryProxy proxy = new RegistryProxy();

 

proxy的实例的配置是空的。因此,我们修改这个方法变成:
  /**

* changed by xio

* @param publisher String

* @param password String

* @param testprops Properties:增加的参数,传入基本配置

* @return String

*/

public static String getExpiredAuthToken(String publisher, String password,

Properties testprops) {

Properties props = new Properties();

props.setProperty(RegistryProxy.ADMIN_ENDPOINT_PROPERTY_NAME,

testprops.getProperty("adminURL"));

props.setProperty(RegistryProxy.INQUIRY_ENDPOINT_PROPERTY_NAME,

testprops.getProperty("inquiryURL"));

props.setProperty(RegistryProxy.PUBLISH_ENDPOINT_PROPERTY_NAME,

testprops.getProperty("publishURL"));

RegistryProxy proxy = new RegistryProxy(props);

AuthToken token = null;

AuthInfo authInfo = null;

String ret = null;

try {

token = proxy.getAuthToken(publisher, password);

authInfo = token.getAuthInfo();

ret = authInfo.getValue();

System.out.println("getExpiredAuthToken:" + authInfo);

proxy.discardAuthToken(authInfo);

}

catch (Exception ex) {

ex.printStackTrace();

}

return ret;

}

 

2.2 使用jUDDI测试

在juddi-0.9rc3版本中自带的代码中没有客户端的使用实例,虽然附带了整个项目代码的测试代码,但是估计没什么人喜欢从这里抽取学 习客户端使用的学习。

当然,学习的实例还是有的,在cvs当前的工程代码中,有个samples的文件夹,这部分代码便是一个十分齐全的实例(有几个类没完成, 但不影响:)。

Cvs服务器数据:http://ws.apache.org/juddi/cvs.html

Wincvs的使用请网上下载阅读。

其他:在进行代码学习的同时,建议阅读webservices相关资料文档。强烈建议阅读:理解 UDDI 注册中心的 WSDL 系列 (http://www-900.ibm.com/developerWorks/cn/webservices/ws-uwsdl/part1/)

参考资料:
http://wiki.apache.org/ws/jUDDI_HOW-TOs
http://ws.apache.org/juddi/lists.html

原作者:xio@qq.com
来 源:http://xio.mblogger.cn

<script type="text/javascript">

&lt;!--

google_ad_client = "pub-9232855773311077";

google_ad_width = 300;

google_ad_height = 250;

google_ad_format = "300x250_as";

google_ad_channel ="";

google_color_border = "FFFFFF";

google_color_bg = "FFFFFF";

google_color_link = "0000FF";

google_color_url = "008000";

google_color_text = "000000";

//--&gt;

</script> <script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"> <p style="text-indent:2em"> <p style="text-indent:2em"></script>  

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
好的,我理解了你的问题。首先,我需要明确一下,你是要求我用 wsdl 语言创建一个集中式目录服务器,然后在该服务器中存储服务描述文件,对吗? 如果是的话,那么我可以告诉你,wsdl(Web Services Description Language)是一种用于描述 Web 服务的语言,它可以定义 Web 服务的接口、消息、数据类型等。而创建一个集中式目录服务器,则需要使用一些特定的技术和工具,比如 SOAP、UDDI 等。下面是一个简单的示例,演示如何使用 wsdl 创建一个集中式目录服务器: 1. 首先,你需要创建一个 wsdl 文件,用于描述 Web 服务的接口、方法和数据类型。以下是一个简单的示例: ``` <definitions name="MyWebService" targetNamespace="http://www.example.com/MyWebService" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <types> <xsd:schema targetNamespace="http://www.example.com/MyWebService"> <xsd:element name="Request"> <xsd:complexType> <xsd:sequence> <xsd:element name="Name" type="xsd:string"/> </xsd:sequence> </xsd:complexType> </xsd:element> <xsd:element name="Response"> <xsd:complexType> <xsd:sequence> <xsd:element name="Message" type="xsd:string"/> </xsd:sequence> </xsd:complexType> </xsd:element> </xsd:schema> </types> <message name="MyWebServiceRequest"> <part name="Request" element="tns:Request"/> </message> <message name="MyWebServiceResponse"> <part name="Response" element="tns:Response"/> </message> <portType name="MyWebServicePortType"> <operation name="SayHello"> <input message="tns:MyWebServiceRequest"/> <output message="tns:MyWebServiceResponse"/> </operation> </portType> <binding name="MyWebServiceBinding" type="tns:MyWebServicePortType"> <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/> <operation name="SayHello"> <soap:operation soapAction="http://www.example.com/MyWebService/SayHello"/> <input> <soap:body use="literal"/> </input> <output> <soap:body use="literal"/> </output> </operation> </binding> <service name="MyWebService"> <port name="MyWebServicePort" binding="tns:MyWebServiceBinding"> <soap:address location="http://www.example.com/MyWebService"/> </port> </service> </definitions> ``` 2. 接下来,你需要将该 wsdl 文件发布到你的集中式目录服务器上。你可以使用一些工具,比如 Apache CXF、Axis2 等,来实现 Web 服务的发布和管理。 3. 最后,你需要将服务描述文件存储到你的集中式目录服务器中。你可以使用一些开源的 UDDI 服务器,比如 JUDDI、WSO2 Registry 等,来实现服务描述文件的存储和查询。 希望这个简单的示例能够帮助你理解如何使用 wsdl 创建一个集中式目录服务器,并在其中存储服务描述文件。如果你有任何问题,可以随时问我。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值