CMDBuild安装及webservice接口的获取
最近项目组之前一直使用的OneCMDB出现了问题,在增删改数据时异常的慢,于是考虑是否可以优化OneCMDB,由于本人水平有限,对OneCMDB进行代码级别的优化暂时还有点难度。于是就对现有的其他开源CMDB进行调研,首先是CMDBuild(官方网站)。 对于CMDBuild,先上结论。 优缺点优点
缺点
安装参考: 安装要求
安装步骤
至此,CMDBuild的安装就完成了。 webservice接口的获取在找CMDBuild的接口时可是费了很大劲,最后在一个角落里找到了一点痕迹, WSDL2Java利用jdk自带的工具 wsimport http://127.0.0.1/TicketMobile/services/Cococ?wsdl -keep -p com.llg.ws2 -s g:/ws
于是,就可以将 官方文档上只有这么一点代码: // 1. Create an instance in the ConfigurationContext class and indicate in it where the repository directory is. In the repository directory there are 2 directories: the modules directory which contains the rampart.mar file,and the conf directory which contains the file to define the safety policy which should be adopted.
ConfigurationContext configContext = ConfigurationContextFactory
.createConfigurationContextFromFileSystem("/path/to/repository",//
null);//
// 2. Instance the WebservicesStub class moving in it the ConfigurationContext just created
WebServicesStub stub = new WebServicesStub(configContext);
// 3.Set the authentication credentials
StAXOMBuilder builder = new StAXOMBuilder(
"/path/to/repository/conf/policy.xml");//
Options options = stub._getServiceClient().getOptions();
options.setUserName("username");
options.setPassword("password");
options.setProperty(//
RampartMessageData.KEY_RAMPART_POLICY,//
PolicyEngine.getPolicy(builder.getDocumentElement()//
));
// 4.Instance a GetCardList object and call the server
GetCardList list = new GetCardList();
list.setClassName("Computer");
GetCardListResponse response = stub.getCardList(list);
Card[] card = response.get_return();
// 5.At this point you can iterate on the array card content and extract the most interesting values. For example,if you want to recover the description of every Computer,the following method will be enough:
System.out.println(card[i].getDescription());
至此,官方代码提供完毕,可是 WebServicesStub的来头最后,网上各种找啊,凡是相关的资料都试了,终于在stub调用WebService这里找到了管用的方法。 使用Axis2提供的wsdl2java.bat命令可以根据WSDL文件产生调用WebService的代码 具体操作,下载安装Axis2不说了。 进入到 wsdl2java -uri http://localhost:8080/cmdbuild/services/soap/Webservices?wsdl -p client -s -o stub
其中 在执行完上面的命令后,读者就会发现在当前目录下多了个stub 目录,在 最后的最后,终于可以用 总结CMDBuild是由意大利的公司所开发的一款开源CMDB产品,网上相关的资料很少,中文的资料就更少,只有一些简单的安装介绍的文章,而关于其如何使用的资料几乎没有,只有官方所提供的手册。然而其只是给出了SOAP的WSDL格式的接口,并没有其他的jar文件,并且在其官方使用手册中只有简单的使用示例代码,对于其中一些类的来源也没有给出,没有一个完善的api开发文档,因此若要真正的使用起来尚有一定的困难,暂时还不能进行代码级别的测试。 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |