CaseMap Server Helper Methods

The following methods are used in the code samples throughout this reference.

 

DisplayMethod

This method displays the return codes and XML body of a message. DisplayMethod is used by all methods to display the returned messages.

 

using System.Xml;

using System.Xml.XPath;

 

public static void DisplayMessage(HttpWebResponse response)

{

  //Write out the status code number and name

  Console.WriteLine((int)response.StatusCode + " " + response.StatusCode);

 

  //stream the body of the message into an XML reader.

  XmlTextReader reader = new XmlTextReader(response.GetResponseStream());

  reader.WhitespaceHandling = WhitespaceHandling.None;

 

  //try to load the XML into an XML doc and display it.

  XmlDocument xd = new XmlDocument();

     try

        {

           xd.Load(reader);

          XmlNode xnodDE = xd.DocumentElement;

 

           ChildDisplay(xnodDE, 0);

           reader.Close();

         }

      //if anything goes wrong, return.

      catch

         {

            return;

         }

}

 

private static void ChildDisplay(XmlNode xnod, int level)

{

  XmlNode xnodWorking;

  String pad = new String(' ', level * 2);

 

  Console.WriteLine(pad + xnod.Name + "(" + xnod.NodeType.ToString() + ": " + xnod.Value + ")");

 

  if (xnod.NodeType == XmlNodeType.Element)

   {

      XmlNamedNodeMap mapAttributes = xnod.Attributes;

      for (int i = 0; i < mapAttributes.Count; i++)

       {

          Console.WriteLine(pad + " " + mapAttributes.Item(i).Name + " = " + mapAttributes.Item(i).Value);

       }

   }

 

  if (xnod.HasChildNodes)

   {

       xnodWorking = xnod.FirstChild;

      while (xnodWorking != null)

       {

           ChildDisplay(xnodWorking, level + 1);

           xnodWorking = xnodWorking.NextSibling;

       }

   }

}

 

Need additional help? Email the CaseMap Support team at: casemap.support@lexisnexis.com, or contact a support representative at 1-800-833-3346 (option 3). The CaseMap Support team is available between the hours of 9:00 a.m. to 7:00 p.m. Eastern Time, Monday - Friday.

© 2017 LexisNexis. All rights reserved.