When I try to make a change to a Incoming Call Handling Trunk-Group I get a "System.NullReferenceException when ever I try to set the below settings.
sType.Called_Length.SetValue("10", 3);
sType.Called_Number.SetValue("1234567890", 3);
sType.Del.SetValue("10", 3);
sType.Insert.SetValue("12345", 3);
If I remove / comment this code out there is no longer an error. I've written similar code with different types without issue. Any recommendations?
Here is the full code:
public void setLabTrunkIncomingCallHandling(string trunkGroup)
{
AvayaLabCM.SystemManagementService client = new AvayaLabCM.SystemManagementService();
client.Timeout = 120000;
try
{
client.Credentials = new NetworkCredential(Properties.Settings.Default.CMLabUser, Properties.Settings.Default.CMPass);
client.PreAuthenticate = true;
client.SoapVersion = System.Web.Services.Protocols.SoapProtocolVersion.Soap11;
client.RequestEncoding = System.Text.Encoding.UTF8;
AvayaLabCM.submitRequestType req = new AvayaLabCM.submitRequestType();
AvayaLabCM.modelChoices choices = new AvayaLabCM.modelChoices();
choices.Items = new object[1];
choices.Items.SetValue(new AvayaLabCM.IncomingCallHandlingType(), 0);
req.modelFields = choices;
req.objectname = string.Empty;
req.qualifier = "trunk-group " + trunkGroup;
req.operation = "display";
AvayaLabCM.returnType results = client.submitRequest(req);
Console.WriteLine("Result Code: " + results.@return.result_code);
Console.WriteLine(Environment.NewLine + "Message: " + results.@return.message_text);
foreach (AvayaLabCM.IncomingCallHandlingType value in results.@return.result_data.Items)
{
AvayaLabCM.IncomingCallHandlingType sType = new AvayaLabCM.IncomingCallHandlingType();
sType.Called_Length.SetValue("10", 3);
sType.Called_Number.SetValue("1234567890", 3);
sType.Del.SetValue("10", 3);
sType.Insert.SetValue("12345", 3);
choices.Items.SetValue(sType, 3);
req.modelFields = choices;
req.objectname = "";
req.qualifier = "trunk-group " + trunkGroup;
req.operation = "change";
results = client.submitRequest(req);
}
Console.WriteLine("Result Code: " + results.@return.result_code);
Console.WriteLine("Message: " + results.@return.message_text);
client.Dispose();
client.release(null);
}
catch (Exception ex)
{
client.Dispose();
client.release(null);
Console.WriteLine(ex.ToString());
}
}