Announcement

Collapse
No announcement yet.

UCMDB 7.5 and a Java Web Services client?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • UCMDB 7.5 and a Java Web Services client?

    I took the UCMDB 7.5 advanced training from HP a few months ago and it seems that HP does not bundle a java web service client jar with their solution. Seems to me that they made it awfully hard to call uCDMB webservices from an external program (eq. from a Java Client) by not providing the java client and making their customers bang their heads trying to get something working.

    The instructor's "Web Service Client" example was beyond broken (seems like HP changed the schema's between 7 and 7.5 hence his binding did not match - he said he got it from another HP Employee) so I decided to create a java client package based off Apache's CXF (instead of Apache AXIS 2).

    I'd gladly share it and I've tested it with 7.5 - I haven't tried it with 8.0. Might be useful for people trying to call the ucmdb web services from a java program (eq. to export data cmdb result data to a text file) or maybe even calling it from a J2EE web-app.
    Last edited by funks; 2009-04-23, 06:02.

  • #2
    CMDB WS Client JiBix/Axis2

    Hi funks -

    I had major issues as well with running the sample client code that was passed down to me from HP. i had issues iwth binding as well. The issue was to do with JiBx.
    The Error message is: "No JiBX <mapping> defined for class data.params.classmodel.GetAllClassesHierarchy".

    Probably JiBX is mapping class to XML or something, so that class can be serialized somehow. The question is where should the configuration of that module (JiBX) be?
    It is quite clear, that one XML file is in jar file, but I think that JiBX is not even searching there. So I dropped that code and have no solution to extract data out of my 8.01 uCMDB.

    Kindly can you share your "java client package based off Apache's CXF"?

    Cheers -
    Alex

    Comment


    • #3
      We upgraded to UCMDB 8 and it works with that version just fine.

      You can download it from the following link

      It's an eclipse project but you can easily rebuild it using ant (just unzip the zip file then run 'ant' inside the UCMDBWebServiceClient folder.. If you don't want to rebuild the binary in the dist/UCMDBWebServiceClient.jar - you can use it as is, just read the /docs/README.txt to figure out the jar file dependecies for CXF 2.1.4 (alot less than AXIS 2).

      here's an example

      Code:
      package com.theintegrationzone.ucmdb.client.sample;
      
      import javax.xml.ws.BindingProvider;
      
      import com.hp.schemas.ucmdb.client.params.update.AddCIsAndRelations;
      import com.hp.schemas.ucmdb.client.services.UcmdbFault;
      import com.hp.schemas.ucmdb.client.services.UcmdbService;
      import com.hp.schemas.ucmdb.client.services.UcmdbServicePortType;
      import com.hp.schemas.ucmdb.client.types.CmdbContext;
      import com.hp.schemas.ucmdb.client.types.update.CIsAndRelationsUpdates;
      
      public class TestWS implements Runnable {
      
          private final static String endpointAddress = "http://your.ucmdb.server:8080/axis2/services/UcmdbService";
          
          private final String username;
          private final String password;
      
          private TestWS(String username, String password) {
              super();
      
              this.username = username;
              this.password = password;
      
          }
      
          public void run() {
              UcmdbServicePortType actualService = getService();
      
              AddCIsAndRelations cisToAdd = new AddCIsAndRelations();
      
              CmdbContext cmdbContext = new CmdbContext();
              cmdbContext.setCallerApplication("TestWS");
              cisToAdd.setCmdbContext(cmdbContext);
      
              try {
      
                  CIsAndRelationsUpdates relUpdates = new CIsAndRelationsUpdates();
      
                  /* Yes, this does nothing - NO-OP, just a sample */
      
                  cisToAdd.setCIsAndRelationsUpdates(relUpdates);
                  actualService.addCIsAndRelations(cisToAdd);
      
              } catch (UcmdbFault fault) {
                  throw new RuntimeException(fault);
              }
      
              System.out.println("NO-OP, all done.");
      
          }
      
          private UcmdbServicePortType getService() {
      
              UcmdbServicePortType actualService = new UcmdbService()
                      .getUcmdbServiceSOAP12PortHttp();
      
              // setup BASIC authentication requirements..
              BindingProvider bp = (BindingProvider) actualService;
      
              bp.getRequestContext().put(BindingProvider.USERNAME_PROPERTY, username);
              bp.getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, password);
      
              // set the address of the WSDL end point
              bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
                      endpointAddress);
      
              return actualService;
      
          }
      
          public static void main(String[] args) {
              new TestWS("someuser", "somepassword").run();
          }
      
      }
      Last edited by funks; 2009-06-09, 23:32.

      Comment


      • #4
        Thank you very much funks. I will try the code tomorrow. I can not wait to get started there. I will post the JiBX solution as well as I am in the middle of working it out.
        I am also running on 8.01.

        Comment


        • #5
          I ran the testWS as a java application and I am getting the following error:
          Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/ws/WebServiceFeature
          at org.apache.cxf.jaxws.ServiceImpl.getPort(ServiceIm pl.java:299)
          at javax.xml.ws.Service.getPort(Service.java:37)
          at com.hp.schemas.ucmdb.client.services.UcmdbService. getUcmdbServiceSOAP12PortHttp(UcmdbService.java:10 6)
          at com.theintegrationzone.ucmdb.client.sample.TestWS. getService(TestWS.java:57)
          at com.theintegrationzone.ucmdb.client.sample.TestWS. run(TestWS.java:29)
          at com.theintegrationzone.ucmdb.client.sample.TestWS. main(TestWS.java:74)

          I had to import axis2-1.2.jar since
          import javax.xml.ws.BindingProvider was not being resolved. Once I imported axis2-1.2.jar, all errors went away ,except when I run TestWS as a Java app it go the error above. I will keep trying to debug meanwhile.

          Comment


          • #6
            Fix

            Finally had the chance to tinker with the Jar files in order to remove all the errors that i outlined in an earlier email. And the only way I could resolve them is my downloading new Jars files for axis2 as well a couple other jar files. All works great now. Now on with the daunting task to calling a TQL query and iterating to get it's CIs , all CI's neighbors, and All relationships, and All attributes and values. I am working on that as we speak, and will share my code when finished; it will be a while though.

            Thank You.

            Comment


            • #7
              Alex, I've updated the zip file (eclipse project). That javax.xml.ws.WebServiceFeature is included in the JAX-WS (Java API for XML Web Services). No need for the AXIS2 libraries

              Code:
              - README.txt -
              
              Description:
              
              This bundle is a web services client for HP's uCMDB v 8.0 packaged as an eclipse project.
              
              Required Libs:
              
              For JDK 1.6 UPDATE 4 and above, the following files are what you'll need in the runtime classpath.
              
              "lib/commons-logging-1.1.1.jar"
              "lib/jaxb-api-2.1.jar"
              "lib/jaxb-impl-2.1.9.jar"
              "lib/jaxws-api-2.1.jar"
              "lib/jaxws-rt-2.1.7.jar"
              "lib/cxf-2.1.4.jar"
              "lib/neethi.jar"
              "lib/XmlSchema.jar"
              "lib/wsdl4j.jar"
              "lib/xml-resolver.jar"
              "lib/streambuffer.jar"
              "lib/stax-ex.jar"
              "dist/UCMDBWebServiceClient.jar"
              
              For older version, you'll need additional libraries listed below.
              
              "lib/activation-1.1.jar"
              "lib/javamail-1.4.jar"
              "lib/stax-api-1.0.1.jar"
              "lib/jsr250-api-1.0.jar"
              "lib/jaxb-api-2.1.jar"
              "lib/wstx-asl-3.2.6.jar"
              
              Sample:
              
              1) Peruse "com.theintegrationzone.ucmdb.client.sample.TestWS.java"
              2) Modify username, password, endPointAddress to suite
              3) Build using ant
              4) Run: java -cp lib/commons-logging-1.1.1.jar;lib/jaxb-api-2.1.jar;lib/jaxb-impl-2.1.9.jar;lib/jaxws-api-2.1.jar;lib/jaxws-rt-2.1.7.jar;lib/cxf-2.1.4.jar;lib/neethi.jar;lib/XmlSchema.jar;lib/wsdl4j.jar;lib/xml-resolver.jar;lib/streambuffer.jar;lib/stax-ex.jar;dist/UCMDBWebServiceClient.jar;dist/UCMDBSample.jar com.theintegrationzone.ucmdb.client.sample.TestWS
              5) Output should be "NO-OP, all done".
              Last edited by funks; 2009-07-22, 20:02.

              Comment


              • #8
                BTW, what are you using the web services for? reporting and integration purposes? We were thinking about exporting certain application topologies via Web Services -> csv files for daily import onto BAC (Business Availability Center).

                Comment


                • #9
                  why dont you point your BAC to your external uCMDB as its a standard integration from HP then you dont have to import any topologies.

                  Comment


                  • #10
                    Originally posted by funks View Post
                    Sample:

                    1) Peruse "com.theintegrationzone.ucmdb.client.sample.TestWS .java"
                    2) Modify username, password, endPointAddress to suite
                    3) Build using ant
                    4) Run: java -cp lib/commons-logging-1.1.1.jar;lib/jaxb-api-2.1.jar;lib/jaxb-impl-2.1.9.jar;lib/jaxws-api-2.1.jar;lib/jaxws-rt-2.1.7.jar;lib/cxf-2.1.4.jar;lib/neethi.jar;lib/XmlSchema.jar;lib/wsdl4j.jar;lib/xml-resolver.jar;lib/streambuffer.jar;lib/stax-ex.jar;dist/UCMDBWebServiceClient.jar;dist/UCMDBSample.jar com.theintegrationzone.ucmdb.client.sample.TestWS
                    5) Output should be "NO-OP, all done".
                    Hi,

                    Terribly sorry but I'm a complete Java dev n00b.
                    I do know uCMDB though and was overjoyed to find your package for dealing with the DDM webservices.
                    I tried to run the code described above, but fail miserably.
                    What the compiler tells me:

                    Code:
                    Exception in thread "main" java.lang.NoClassDefFoundError: com/theintegrationzone/ucmdb/client/sample/TestWS
                    Caused by: java.lang.ClassNotFoundException: com.theintegrationzone.ucmdb.client.sample.TestWS
                            at java.net.URLClassLoader$1.run(Unknown Source)
                            at java.security.AccessController.doPrivileged(Native Method)
                            at java.net.URLClassLoader.findClass(Unknown Source)
                            at java.lang.ClassLoader.loadClass(Unknown Source)
                            at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
                            at java.lang.ClassLoader.loadClass(Unknown Source)
                            at java.lang.ClassLoader.loadClassInternal(Unknown Source)
                    Could not find the main class: com.theintegrationzone.ucmdb.client.sample.TestWS.  Program will exit.
                    I did set the classpath to my jdk1.6 installation folder as well as the uCMDB/WS client folder. Can you please tell me what I am doing wrong here?

                    Comment


                    • #11
                      Did you run it as such?

                      Code:
                      java -cp lib/commons-logging-1.1.1.jar;lib/jaxb-api-2.1.jar;lib/jaxb-impl-2.1.9.jar;lib/jaxws-api-2.1.jar;lib/jaxws-rt-2.1.7.jar;lib/cxf-2.1.4.jar;lib/neethi.jar;lib/XmlSchema.jar;lib/wsdl4j.jar;lib/xml-resolver.jar;lib/streambuffer.jar;lib/stax-ex.jar;dist/UCMDBWebServiceClient.jar;dist/UCMDBSample.jar com.theintegrationzone.ucmdb.client.sample.TestWS
                      Seems like you are missing the dist/UCMDBSample.jar from the -cp switch..

                      Comment


                      • #12
                        I re-uploaded the zip file, please download it again. The ant build script should now be creating the UCMDBSample.jar file also.

                        Comment


                        • #13
                          Originally posted by funks View Post
                          I re-uploaded the zip file, please download it again. The ant build script should now be creating the UCMDBSample.jar file also.
                          Compiles ok now and I can run the sample from the command line.
                          Thanks!

                          Now I go try hang this thing in Eclipse.
                          Could I impose on you for pointers?
                          Sorry for being a complete n00b.

                          Thanks again.

                          Comment


                          • #14
                            I thought your archive is an Eclipse project, so I tried opening it, importing classes and other amateur trickery.
                            Can't seem to make it go in properly.
                            You're sure this project is directly openable in Helios?
                            Should I use some other Eclipse version?
                            Last edited by Rutger; 2010-08-18, 15:29. Reason: retract request

                            Comment

                            Working...
                            X