I get this error after I add the first name: Code Below
and xml file below too
public XmlDocument AddUsers(string queryXml)
{
try
{
Dictionary<string, string> fields = new Dictionary<string, string>();
for (int i = 1; i < 11; i++)
{
XmlDocument xmlDocument = new XmlDocument();
try
{
xmlDocument.LoadXml(queryXml);
}
catch (Exception)
{
throw new Exception("Error reading query string passed to AddUsers Web Service. It may not be a well formed XML.");
}
fields.Add("FirstName", Util.GetXPath(xmlDocument, "//FirstName" + i.ToString()));
fields.Add("MiddleName", Util.GetXPath(xmlDocument, "//MiddleName" + i.ToString()));
fields.Add("LastName", Util.GetXPath(xmlDocument, "//LastName" + i.ToString()));
fields.Add("DisplayName", Util.GetXPath(xmlDocument, "//DisplayName" + i.ToString()));
fields.Add("LoginName", Util.GetXPath(xmlDocument, "//Login" + i.ToString()));
fields.Add("Password", Util.GetXPath(xmlDocument, "//Password" + i.ToString()));
fields.Add("ArchiveStatus", "False");
Inserter inserter = new Inserter("DOCUMENTS_PEOPLE");
foreach (string key in fields.Keys)
{
inserter[key] = fields[key].ToString();
}
}
XmlDocument xmlReturnDoc = new XmlDocument();
XmlDeclaration xmlDeclaration = xmlReturnDoc.CreateXmlDeclaration("1.0", "utf-8", null);
XmlElement rootNode = xmlReturnDoc.CreateElement("AddSysOptions");
xmlReturnDoc.InsertBefore(xmlDeclaration, xmlReturnDoc.DocumentElement);
XmlNode NewNode = xmlReturnDoc.AppendChild(rootNode);
NewNode.InnerText = "Success";
return xmlReturnDoc;
}
catch (Exception ex)
{
AcXmlClasses.AddLogEntry("Error when calling AddUsers: " + ex.ToString(), 1);
return AcException.GetXmlException(ex);
}
}
Kirtan PatelPosted Jan 10, 2010, 9:15 PM
once you have added First name,Last Name you can not add it again in dictionary as every key must me unique in Dictionary .
Hope it clears your doubt .