2 Replies Latest reply on Apr 5, 2013 8:16 AM by solarluke

    Read custom properties.

    solarluke

      Hi,

       

      I am relatively new to the Orion SDK.

       

      Using Visual Stuio 2010, C# and the Orion SDK I have connected to my Orion server.

      Using SWISv3: https://servername:17778/SolarWinds/InformationService/v3?wsdl for my service reference.

       

      #Code

      var binding = OrionBinding.Binding;

      var address = new EndpointAddress(string.Format("https://{0}:17778/SolarWinds/InformationService/v3/OrionBasic", hostname));

      ServicePointManager.ServerCertificateValidationCallback = (sender, certificate, chain, errors) => true;

      var client = new InformationServiceClient(binding, address);

      if (client.ClientCredentials != null)
      {
           client.ClientCredentials.UserName.UserName = username;
           client.ClientCredentials.UserName.Password = password;
      }

      client.Open();

      #Code

       

      I am able to read and update Orion node details.

       

      #Code

      //Read DNS property

      var dns = client.QueryXml(string.Format("SELECT DNS FROM Orion.Nodes WHERE NodeID= '{0}'", NodeId), null);

       

      //Update DNS property

      var dict = new dictionary { new item { value = "12345", key = "DNS", type = "System.String" } };

      var uri = string.Format("swis://{0}/Orion/Orion.Nodes/NodeID={1}", hostname, nodeId.Value);

      client.Update(uri, dict);

      #Code

       

      I am able to update Orion node Customer Properties.

       

      #Code

      //Update CustomProperty

      var uri = string.Format("swis://{0}/Orion/Orion.Nodes/NodeID={1}/CustomProperties", hostname, nodeId.Value);

      var dict = new dictionary { new item { value = "12345", key = "CustomProperty", type = "System.String" } };

      client.Update(uri,dict);

      #Code

       

      However, I cannot seem to read Orion node custom properties.

       

      The following code results in the following exception when "client.Read" is executed.

       

      #Code

      //Read

      var uri = string.Format("swis://{0}/Orion/Orion.Nodes/NodeID={1}/CustomProperties", hostname, nodeId.Value);

      client.Read(uri);

      #Code

       

      #Exception

      The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter http://schemas.solarwinds.com/2007/08/informationservice:ReadResult. The InnerException message was 'Element value from namespace http://schemas.solarwinds.com/2007/08/informationservice/propertybag cannot have child contents to be deserialized as an object. Please use XmlNode[] to deserialize this pattern of XML.'.  Please see InnerException for more details.

      #Exception

       

      #Inner Exception

      {"End element 'value' from namespace 'http://schemas.solarwinds.com/2007/08/informationservice/propertybag' expected. Found text '6146'. Line 1, position 392."}

      #Inner Exception

       

      The '6146' is my Orion NodeID.

       

      Any help on this would be much appreciated.

       

      Cheers,

       

      Luke.