Home Page › Forums › BizTalk 2004 – BizTalk 2010 › Updating the TypedXmlDocument in BRE from a .NET Static Method (to add a new node)
- This topic has 4 replies, 1 voice, and was last updated 9 years, 2 months ago by
community-content.
-
AuthorPosts
-
-
July 25, 2008 at 10:41 AM #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 -
July 25, 2008 at 10:54 AM #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;
}
}
}-
July 25, 2008 at 10:55 AM #20241
Sorry – is there a clean way to paste C# code into my posts?
-
July 28, 2008 at 7:40 AM #20250
Do I have to implement FactRetriever or FactCreator to do update the XML message?
The typedXmlDocument.Document is read-only.-
July 28, 2008 at 8:48 AM #20252
I found this sample code which will probably do the job.
http://blogs.msdn.com/scottwoo/archive/2004/09/16/230472.aspx
For some reason, the ImportNode method is not avilable on the typedXmlDocument.Document, which means a little more coding for me.
txd.Document.ImportNode
Neal
-
-
-
-
-
AuthorPosts
- The forum ‘BizTalk 2004 – BizTalk 2010’ is closed to new topics and replies.