Naverisk GetDeviceList

Get a list of Devices for a ClientID

C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using System.ServiceModel;

namespace DemoNaveriskGetDeviceList
{
    class Program
    {
        /*
        * Instructions
        * 
        * 1. Disable Authentication and SSL.
        * 2. Add a Service Reference to the Naverisk Service, name the reference NaveriskService.
        *    The uri will generally be http://localhost:11111/Naverisk.
        * 3. With new release you may have to update the Service Reference.
        */
        static void Main(string[] args)
        {
            NaveriskService.NaveriskClient client = new NaveriskService.NaveriskClient();
            (client.ChannelFactory.Endpoint.Binding as BasicHttpBinding).MaxReceivedMessageSize = int.MaxValue;
            (client.ChannelFactory.Endpoint.Binding as BasicHttpBinding).MaxBufferSize = int.MaxValue;
            (client.ChannelFactory.Endpoint.Binding as BasicHttpBinding).ReceiveTimeout = new TimeSpan(0, 10, 0);

            // Replace ClientID = 0 with a ClientID on your Naverisk Instance
            NaveriskService.GetDeviceListResponse response = client.GetDeviceList(
                new NaveriskService.GetDeviceListRequest { ClientID = 0 });

            for (int i = 0; i < response.Keys.Count; i++)
                Console.WriteLine($"Key: {response.Keys[i]}, Value: {response.Values[i]}");

            Console.WriteLine("Press enter to continue.");
            Console.ReadLine();
        }
    }
}
PowerShell
# Instructions
#
# 1. Disable Authentication and SSL

$Uri = 'http://localhost:11111/Naverisk'

$Xml = @'
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope
    soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
    xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <soap:Body>
    {0}
  </soap:Body>
</soap:Envelope>
'@

$Body = @'
    <GetDeviceList>
      <Request xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
        <ClientID>{0}</ClientID>
      </Request>
    </GetDeviceList>
'@ -f 0 # Replace 0 with a ClientID on your Naverisk Instance 

$result = (Invoke-WebRequest -UseBasicParsing -Body ($Xml -f $Body) `
	-method POST –contentType "text/xml" -Uri $Uri -Headers @{"SOAPAction"="urn:INaverisk/GetDeviceList"})

# Pretty output
$StringWriter = New-Object System.IO.StringWriter 
$XmlWriter = New-Object System.XMl.XmlTextWriter $StringWriter 
$xmlWriter.Formatting = "indented"
$xmlWriter.Indentation = 4
([xml]($result.content)).WriteContentTo($XmlWriter)
$XmlWriter.Flush()
$StringWriter.Flush()
Write-Output $StringWriter.ToString()