Naverisk GetTicketList

Get a list of tickets.

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

using System.ServiceModel;

namespace DemoNaveriskGetTicketList
{
    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);

            NaveriskService.GetTicketListResponse response = client.GetTicketList(
                new NaveriskService.GetTicketListRequest
                {
                    ItemCount = 10,
                    Start = 0,
                    Sort = 2,
                    SortColumn = 201
                });

            for (int i = 0; i < response.List.Length; i++)
            {
                Console.WriteLine($"IncidentCombinedID: {response.List[i].IncidentCombinedID}");
                Console.WriteLine($"ClientName: {response.List[i].ClientName}");
                Console.WriteLine($"IncidentSubject: {response.List[i].IncidentSubject}");
                Console.WriteLine($"IncidentDescription: {response.List[i].IncidentDescription}");
                Console.WriteLine($"IncidentIdentifier: {response.List[i].IncidentIdentifier}");
                Console.WriteLine();
            }

            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 = @'
    <GetTicketList>
      <Request xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
        <ItemCount>10</ItemCount>
        <Start>0</Start>
        <Sort>2</Sort>
        <SortColumn>201</SortColumn>
        <UserSpecific>false</UserSpecific>
        <MonitorList>false</MonitorList>
        <ClientIDFilter>0</ClientIDFilter>
        <UserIDFilter>0</UserIDFilter>
        <SubSourceIDFilter>0</SubSourceIDFilter>
        <IsBiliableFilter>false</IsBiliableFilter>
        <TicketNumber>0</TicketNumber>
        <ConsoleType>0</ConsoleType>
        <ClearPreviousMonitors>false</ClearPreviousMonitors>
      </Request>
    </GetTicketList>
'@

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

$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()