6 Replies Latest reply on Dec 11, 2014 3:47 AM by livioo

    Connect version 3 of the Orion/SWIS DB from a Java application

    livioo

      Hello,

      I'm currently accessing the Orion/SWIS DB for reporting purpose on our Web application. I took the Java sample of the SDK (V1.8) and this sample uses the version 2 of the Orion DB. The one of the SDK 1.9 also uses the version 2.

      We would like now to add the netflow data that seem to be available from the version 3. But when I simply add "v3" as indicated in the documentation it doesn't work. I don't get any exception but no data is returned (even for the non-netflow tables like for instance Orion.NPM.Interfaces).

      SWISv3: https://servername:17778/SolarWinds/InformationService/v3/OrionBasic

      I can get successfully the netflow data using SWQL (table: Orion.Netflow.Flows).

       

      Could you please tell me what I have to change in my Java app in addition to the URL above or tell me where I could get a sample using the version 3?

       

      Thanks a lot for your help, kind regards

      Livio

        • Re: Connect version 3 of the Orion/SWIS DB from a Java application
          tdanner

          If you have a working SWISv2 client, the URL should be the only thing you have to change to get a working SWISv3 client. Could you give more detail about what you are seeing returned from v3?

            • Re: Connect version 3 of the Orion/SWIS DB from a Java application
              livioo

              Hi, thanks for your reply!

              Here is my code:

              String query = "select InterfaceID from orion.NPM.Interfaces WHERE NodeID = 59 ";
                
              PropertyBag parameters = new PropertyBag();
              QueryXmlResponseQueryXmlResult result = swis.queryXml(query, parameters.getAsSoapPropertyBag());
               
              MessageElement[] resultXmlArray = result.get_any();
              Element resultXml = resultXmlArray[0];
               
              XPathFactory factory = XPathFactory.newInstance();
              XPath xpath = factory.newXPath();
               
              MapNamespaceContext nsContext = new MapNamespaceContext();
              nsContext.addNamespace("is", "http://schemas.solarwinds.com/2007/08/informationservice");
              xpath.setNamespaceContext(nsContext);

              NodeList nodeList = (NodeList) xpath.evaluate("//is:Interfaces", resultXml, XPathConstants.NODESET);

              With v2 I get 43 interfaces in nodeList. With v3 nodeList is empty.

                • Re: Connect version 3 of the Orion/SWIS DB from a Java application
                  tdanner

                  Have you tried dumping "result" to see what it looks like?

                    • Re: Connect version 3 of the Orion/SWIS DB from a Java application
                      livioo

                      Please find attach the content of result with v2 and v3. There is a difference: In v2 the namespaces = null:

                      result v2.jpg
                      It is not null in v3:

                      result v3.jpg

                        • Re: Connect version 3 of the Orion/SWIS DB from a Java application
                          livioo


                          I can see the 43 interfaces in result with v3 (as with v2 of course), the data are in then. The issue is therefore when I extract the info from the XML.

                          Do you think it is linked to the namespaces?

                          v3:

                          result v3.jpg

                            • Re: Connect version 3 of the Orion/SWIS DB from a Java application
                              livioo

                              Hi tdanner,

                              In fact the sample in the SDK indeed works with version 3. After comparison with my application I saw the following difference:

                              String query = "select InterfaceID from orion.NPM.Interfaces WHERE NodeID = 59 ";

                               

                              PropertyBag parameters = new PropertyBag(); 

                              QueryXmlResponseQueryXmlResult result = swis.queryXml(query + " RETURN XML RAW", parameters.getAsSoapPropertyBag());

                               

                              MessageElement[] resultXmlArray = result.get_any();

                              Element resultXml = resultXmlArray[0];

                               

                              XPathFactory factory = XPathFactory.newInstance();

                              XPath xpath = factory.newXPath();

                               

                              MapNamespaceContext nsContext = new MapNamespaceContext();

                              nsContext.addNamespace("is", "http://schemas.solarwinds.com/2007/08/informationservice");

                              xpath.setNamespaceContext(nsContext);

                               

                              NodeList nodeList = (NodeList) xpath.evaluate("//is:c0", resultXml, XPathConstants.NODESET);

                              The explanation ofthe SDK doc:

                              Choose the format that is most convenient for your programming environment. If you do not include a

                              RETURN XML clause in your query, SWISv2 will default to RETURN XML AUTO and SWISv3 will default to RETURN XML RAW.

                              I can therefore keep my initial format by specifying RETURN XML AUTO:

                              String query = "select InterfaceID from orion.NPM.Interfaces WHERE NodeID = 59 ";

                               

                              PropertyBag parameters = new PropertyBag(); 

                              QueryXmlResponseQueryXmlResult result = swis.queryXml(query + " RETURN XML AUTO", parameters.getAsSoapPropertyBag());

                               

                              MessageElement[] resultXmlArray = result.get_any();

                              Element resultXml = resultXmlArray[0];

                               

                              XPathFactory factory = XPathFactory.newInstance();

                              XPath xpath = factory.newXPath();

                               

                              MapNamespaceContext nsContext = new MapNamespaceContext();

                              nsContext.addNamespace("is", "http://schemas.solarwinds.com/2007/08/informationservice");

                              xpath.setNamespaceContext(nsContext);

                               

                              NodeList nodeList = (NodeList) xpath.evaluate("//is:Interfaces", resultXml, XPathConstants.NODESET);

                               

                              Now it works fine. Thanks a lot for your help!

                              Kind regards
                              Livio