UCMDB and UD Practitioners Forum (Previously CMS)

Sample code to export a TQL to XML


Sample code to export a TQL to XML

Hopefully somebody can help me here.

I am looking for a simple jython script (or does it have to be Java?) to export a TQL to disk from uCMDB 9.01


Background is a 8.03 environment that is upgraded to 9.01 with a custom discovery adapter. The adapter cannot be transferred to 9.01. It is a very simple connector however, so rebuilding it should be no problem imho. But I lack the experience/knowledge at this time.


I can create a schedule to mail the report, but I need the file on disk. As far as I know from what I found, this means I will have to use a custom discovery adapter?


Could somebody show me a sample script to include in this custom adapter please?

If I have a working example I am pretty sure I can rebuild the old adapter.


Thank you in advance for your time.



P.S. This thread has been moevd from Application Perf Mgmt (BAC / BSM) Support and News Forum to CMS and Discovery Support and News . - Hp forum Moderator


Amit Erental
Acclaimed Contributor.

Re: Sample code to export a TQL to XML

Hi Koret


Are you reffering to TQL result ? you can use one of the UCMDB APIs to exectute TQL and get the results (WebService or Java API). full info and example are here : http://support.openview.hp.com/selfsolve/document/KM939200/binary/UCMDB9.01_Admin.pdf?searchIdentifier=-5b5525ae%3a12c2dc0c8e6%3a-3da4&resultType=document






Re: Sample code to export a TQL to XML

Hi Amit,


Thank you for your answer.

Yes, I want to export the results of a TQL to a XML file.

I have already downloaded the developer reference guide, found the pages of example/demo code and am trying to work my way through it. My experience with Java / Jython is rather limited at this time however, so I guess that's what's stopping me.

(I have experience with vb, powershell, and rusty C, and now working to understand Java because of this)


I think I need to address the web service API, and use the executeTopologyQueryByName function.

This calls the TQL I made and returns a topologyMap as a result.


I found the demo code and want to include the demo and querydemo classes into the package.

From here it gets fuzzy for me.


I suppose I can then include the demo classes into the jython script so I can call the functions.

Once I manage to trigger the TQL, how do I write the TopologyMap to XML?


I supposed it would be an open&close case for seasoned developers? But if I am hopelessly underestimating the complexity please feel free to point it out too...


Amit Erental
Acclaimed Contributor.

Re: Sample code to export a TQL to XML



Welcome to Java, its a great language to work with

I think the UCMDB Java API is better, you do not want to handle the SOAP for the Web Serive

You can use executeNamedQuery method of TopologyQueryService to invoke named query

you have the whole SDK docs in the installation 

For the Java to XML: once you have the TopologyCI collection (see Topology Query Example), you can to write the results to any file you like, using any Java code you like. for XML , you have several methods, start with this web site from more info : http://articles.techrepublic.com.com/5100-10878_11-1044810.html


Hope this helps,





Christian Doll
Honored Contributor.

Re: Sample code to export a TQL to XML



do you really need it in XML? If not you can also use the jboss console to retrieve the results or definition of a tql.


On version 8 it should be service=CMDB Tql Services





Re: Sample code to export a TQL to XML

Thanks to everybody for your time and help, but I fear the challenge is a bit too hard for me, so I advised to hire a consultant to build this connector. I seem to have thoroughly underestimated the complexity to build this adapter,

I just can't seem to get a good handle on the problem, and have wasted enough time trying to figure it out.


So, thanks for all the help, but I fear it time to throw in the towel and let the expert step in.


Valued Contributor.

Sample code to import TQL into UCMDB, from xml

hi friends.


i want to import the TQL into UCMDB, which was exported as XML.

using the JAVA api or Webservice.