Wednesday, January 12, 2011

Modifying BizTalk Message using .NET




In Message Assignment

MsgOutput=Namespace.Class.NodePositionRecord(MsgISOResponse);

.Net Class Code function:
public static XmlDocument NodePositionRecord(XmlDocument InputMSGRequest)

{
XmlDocument InputDoc = PositionMSGRequest;
try
{

XmlDocument PositionMSGResponse = new XmlDocument(InputDoc.NameTable);

//Your XML Operation

MSGResponse = InputDoc ;

return MSGResponse;

}

catch (Exception ex)

{

return InputMSGRequest;

}

}

private void AddNode(XmlNode node, string elementName)

{

XmlElement newElement = node.OwnerDocument.CreateElement(elementName);

node.AppendChild(newElement);

}

private void AddNode(XmlNode node, string elementName, string value)

{

XmlElement newElement = node.OwnerDocument.CreateElement(elementName);

XmlText elementText = node.OwnerDocument.CreateTextNode(value);

node.AppendChild(newElement);

node.LastChild.AppendChild(elementText);

}
private XmlNode GetNode(XmlDocument doc, string xpath)


{

XmlNamespaceManager xmlnsManager = new XmlNamespaceManager(doc.NameTable); xmlnsManager.AddNamespace("ns0", "http://xyz.BizTalk.ESB.Schemas.BREResult");
return doc.SelectSingleNode(xpath, xmlnsManager);



}

No comments:

Post a Comment