Updating the TypedXmlDocument in BRE from a .NET Static Method (to add a new node)

Home Page Forums BizTalk 2004 – BizTalk 2010 Updating the TypedXmlDocument in BRE from a .NET Static Method (to add a new node)

Viewing 1 reply thread
  • Author
    Posts
    • #20239

       I’ve not worked much with the TypedXmlDocument yet.
      I have a C# unit tester calling a C# static method.  When I put “ref” on the TypedXmlDocument it works fine.
      I’m not sure why I lose my changed XmlDocument when I do not put “ref”.  But when trying to test in the Business Rule Composer, it looks like the BRE does not support “ref”, because when I tried to drop my schema root element there, it gave an error.

      So in my method, I load the outerxml of the TypedXmlDocument into a regular XmlDocument, do my manipulation, and then convert it back as follows:

       

       

      public static void AddItineraryItem(TypedXmlDocument TMXMLDocInTyped, string  stepName)
      {
      …misc code omitted here…
      TypedXmlDocument docOut = new TypedXmlDocument(TMXMLDocInTyped.DocumentType, TMXMLDocIn);
      TMXMLDocInTyped = docOut; 
      // overlay the input typedXmlDoc
      return;
      }

      I also noted there is a registry setting that I’ll probably have to change to be able to call a static method, but I don’t think that is related to my issue above.  Right now, my goal is to get the C# to C# working without using REF.

      Thanks,
      Neal

    • #20240

       I’m pretty sure what I need to do is update the TypedXmlDocument with my new xml without constructing a new TypedXmlDocument.

      I proved that if you construct a new object, it won’t pass back with this code:

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

      namespace

       

      TestPassObjectCons

      {

       

       

      class Program

      {

       

       

      static void Main(string[] args)

      {

       

       

      employee objEmployee = new employee();

      objEmployee.lastname =

      “Walters”;
      objEmployee.firstname =
      “Neal”;

       

       

      subs.mysub(objEmployee);

       

       

      Console.WriteLine(“Result lastname=” + objEmployee.lastname);

       

       

      Console.ReadLine();

      }

      }

       

       

      public class employee

      {

       

       

      public string lastname;

       

       

      public string firstname;

      }

       

       

      public class subs

      {

       

       

      public static void mysub(employee passEmp)

      {

       

       

      //passEmp.lastname = “Something else”;  // (this sends back the changed value)

       

       

      employee newEmployee = new employee();

      newEmployee.lastname =

      “Something else”;

      newEmployee.firstname =

      “John”;

      passEmp = newEmployee;  // this does not send back the changed value

       

       

      return;

      }

      }
      }

Viewing 1 reply thread
  • The forum ‘BizTalk 2004 – BizTalk 2010’ is closed to new topics and replies.