0 Replies Latest reply on Nov 9, 2012 3:30 PM by robert.simpson

    AddInterfacesOnNode - java or perl

    robert.simpson

      Hi folks,

       

      We haven't been having any luck getting the AddInterfacesOnNode verb to work for us. We've tried using the perl examples provided in another thread along with the updated InformationService.pm file there, but we're not getting any response. We've successfully used this user to create nodes before but not interfaces on pollers. Bunch of code snippets below. Any assistance that can be provided is greatly appreciated.

       

      I've pasted the relevant content from our script below. We do get a response when we use DiscoverInterfacesOnNode but no response at all from AddInterfacesOnNode and not even any kind of error. However, we're not seeing the interfaces on the node display in the UI, and it doesn't look like the interfaces have wound up in any DB tables, either.

       

      my $interfaceList =  $swis->Invoke('Orion.NPM.Interfaces', 'DiscoverInterfacesOnNode', [352]);

      my $xmlParser = new XML::LibXML();

      my $interfaceXML = $xmlParser->parse_string($interfaceList);

       

      my $xpc = new XML::LibXML::XPathContext();

      $xpc->registerNs('soap', 'http://schemas.xmlsoap.org/soap/envelope/');

      $xpc->registerNs('swis', 'http://schemas.solarwinds.com/2007/08/informationservice');

      $xpc->registerNs('sic', 'http://schemas.datacontract.org/2004/07/SolarWinds.InformationService.Contract');

      $xpc->registerNs('npm', 'http://schemas.solarwinds.com/2008/NPM');

       

      my $requestStatus = $xpc->find('/soap:Envelope/soap:Body/swis:InvokeResponse/swis:InvokeResult/sic:Return/npm:Result', $interfaceXML)->shift()->textContent();

       

      my $discoveredInterfaces = $xpc->find('/soap:Envelope/soap:Body/swis:InvokeResponse/swis:InvokeResult/sic:Return/npm:DiscoveredInterfaces', $interfaceXML)->shift();

       

      if ($requestStatus eq 'Succeed') {

         my $discoveredInterfacesSoapList = SOAP::Data->type('xml' => $discoveredInterfaces->toStringC14N());

         $swis->Invoke('Orion.NPM.Interfaces', 'AddInterfacesOnNode', [352, $discoveredInterfacesSoapList, 'AddDefaultPollers']);

      }

       

      Our other integration option is Java, and I've gotten to about the same point here. We're using the classes provided in the SDK and modifying the SwisClient class to try to get it to add the interfaces, and as with perl, I've gotten to the point where we can get the list of discovered interfaces but cannot add them. The current relevant content of that class's main method is below - everything else is unmodified. However, unlike our perl script, this one does provide us with an error. All we're getting is the exception: EDIT: oops. I did change the method that creates the 'swis' object to point at the v3 endpoint so that the verbs are available.

       

      AxisFault

      faultCode: {http://xml.apache.org/axis/}HTTP

      faultSubcode:

      faultString: (400)Bad Request

      faultActor:

      faultNode:

      faultDetail:

        {}:return code:  400

       

        {http://xml.apache.org/axis/}HttpErrorCode:400

       

      (400)Bad Request

        at org.apache.axis.transport.http.HTTPSender.readFromSocket(HTTPSender.java:744)

        at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:144)

        at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)

        at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)

        at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)

        at org.apache.axis.client.AxisClient.invoke(AxisClient.java:165)

        at org.apache.axis.client.Call.invokeEngine(Call.java:2784)

        at org.apache.axis.client.Call.invoke(Call.java:2767)

        at org.apache.axis.client.Call.invoke(Call.java:2443)

        at org.apache.axis.client.Call.invoke(Call.java:2366)

        at org.apache.axis.client.Call.invoke(Call.java:1812)

        at org.tempuri.BasicHttpBinding_InformationServiceStub.invoke(BasicHttpBinding_InformationServiceStub.java:496)

        at SwisClient.main(SwisClient.java:70)

       

      Code is as follows:

       

      InvokeResponseInvokeResult result = swis.invoke("Orion.NPM.Interfaces", "DiscoverInterfacesOnNode", parameterWrapper);

      MessageElement[] resultXmlArray = result.get_any();

      Element resultXml = resultXmlArray[0];


      MapNamespaceContext nsContext = new MapNamespaceContext();

      nsContext.addNamespace("soap", "http://schemas.xmlsoap.org/soap/envelope/");

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

      nsContext.addNamespace("sic", "http://schemas.datacontract.org/2004/07/SolarWinds.InformationService.Contract");

      nsContext.addNamespace("npm", "http://schemas.solarwinds.com/2008/NPM");

      XPathFactory factory = XPathFactory.newInstance();

      XPath xpath = factory.newXPath();

      xpath.setNamespaceContext(nsContext);

      NodeList nodes = (NodeList) xpath.evaluate("//npm:DiscoveredInterfaces", resultXml, XPathConstants.NODESET);

      Node node = nodes.item(0);

       

      parameters = new ArrayOfXmlElementXmlElement();

      messageElements = new MessageElement[3];

      messageElements[0] = new RPCParam("NodeID", 352);

      messageElements[1] = (MessageElement) node;

      messageElements[2] = new RPCParam("PollerType", "AddDefaultPollers");

      parameters.set_any(messageElements);

      parameterWrapper = new ArrayOfXmlElementXmlElement[1];

      parameterWrapper[0] = parameters;

       

      result = swis.invoke("Orion.NPM.Interfaces", "AddInterfacesOnNode", parameterWrapper);