Hello,
I am using the code below to get a list of all hosts.
All commands execute successfully - meaning APIStatus equals "passed".
The HostListInfoIterStart returns the correct number of 10 records.
But when I invoke HostListInfoIterNext and set the Maximum member to 10 (see below), I get an InvalidOperationException in System.XML.dll.
If I dont set the Maximum member, then the exception is not thrown. But in HostListInfoIterNextResult the members Hosts and Records are null - allthough the APIStatus equals "passed".
I hope you can help me!
Thanks,
Georg
NaDfm server = null;
server = new NaDfm(_server);
server.Credentials = new NetworkCredential(_user, _password);
server.Protocol = ServerProtocol.HTTPS;
server.Port = 8443;
try
{
HostListInfoIterStart startInput = new HostListInfoIterStart();
HostListInfoIterStartResult startOutput = startInput.Invoke(server);
if (startOutput.APIStatus.Equals("passed"))
{
if (startOutput.Records.HasValue)
{
HostListInfoIterNext nextInput = new HostListInfoIterNext();
nextInput.Tag = startOutput.Tag;
nextInput.Maximum = startOutput.Records;
HostListInfoIterNextResult nextOutput = nextInput.Invoke(server);
if (nextOutput.APIStatus.Equals("passed"))
{
HostInfo[] hostInfos = nextOutput.Hosts;
foreach (HostInfo info in hostInfos)
{
}
}
else
{
Debug.WriteLine("API Status: " + nextOutput.APIStatus);
Debug.WriteLine("Errno: " + nextOutput.Errno + " Failure Reason: " + nextOutput.FailureReason);
}
}
HostListInfoIterEnd endInput = new HostListInfoIterEnd();
endInput.Tag = startOutput.Tag;
HostListInfoIterEndResult endOutput = endInput.Invoke(server);
if (endOutput.APIStatus.Equals("passed"))
{
Debug.WriteLine("Stopped with iteration");
}
else
{
Debug.WriteLine("API Status: " + endOutput.APIStatus);
Debug.WriteLine("Errno: " + endOutput.Errno + " Failure Reason: " + endOutput.FailureReason);
}
}
else
{
Debug.WriteLine("API Status: " + startOutput.APIStatus);
Debug.WriteLine("Errno: " + startOutput.Errno + " Failure Reason: " + startOutput.FailureReason);
}
}
catch (NaException ne)
{
Debug.WriteLine("Exception: " + ne.Message);
}
catch (Exception e)
{
Debug.WriteLine("Exception: " + e.StackTrace);
}