It's obvious requirement for every BizTalk developer to do some manipulation with the content of message. There are various ways to achieve the same namely distinguished fields, Property promotion, Xpath expression, etc. In this blog I am going to discuss using xpathreader to achieve the same.
"An XLANGMessage object represents a message instance declared with an XLANG service. This object is obtained by passing a reference to a message as a parameter in a method invocation. An orchestration message variable may be passed to a user component and received as an XLANGMessage object. The XLANGMessage object allows accessing the parts and accessing message properties.The user may "hold on" to an XLANGMessage and thereby extend its lifetime beyond the declared scope. Subsequently, an XLANGMessage may be retuned from a method and assigned to a message variable in an orchestration." [MSDN]
Namespace: Microsoft.XLANGs.BaseTypes Platforms: Windows, Windows XP Professional, Windows Server Assembly: Microsoft XLANG/s Base Types (in Microsoft.XLANGs.BaseTypes.dll)
using
System;
Microsoft.XLANGs.BaseTypes;
System.IO;
Microsoft.BizTalk.XPath;
System.Xml;
namespace
XlangHelper
[Serializable()]
public
class
XlangHelperMethods
{
static
string
SelectSingleNode(XLANGMessage message,
xPath)
try
if
(message ==
null
||
.IsNullOrEmpty(xPath))
return
.Empty;
}
(XmlReader reader = (XmlReader)message[0].RetrieveAs(
typeof
(XmlReader)))
XPathCollection xPathCollection =
new
XPathCollection();
XPathReader xPathReader =
XPathReader(reader, xPathCollection);
xPathCollection.Add(xPath);
while
(xPathReader.ReadUntilMatch())
(xPathReader.Match(0))
xPathReader.ReadString();
catch
(Exception ex)
throw
(ex);
finally
message.Dispose();
ReadValue = XlangHelper.XlangHelperMethods.SelectSingleNode(mSg_In,
"/*[local-name()='Company' and namespace-uri()='http://SampProj1.Input']/*[local-name()='Name' and namespace-uri()='']"
);
Another important place to find a huge amount of BizTalk related articles is the TechNet Wiki itself. The best entry point is BizTalk Server Resources on the TechNet Wiki.
Interesting article, thanks!
Good One.. thanks ashish