Blue Theme Orange Theme Green Theme Red Theme
 
MindFusion's Components
Home | Forums | Videos | Photos | Downloads | Blogs | E-Books | Interviews | Jobs | Beginners | Training
 | Consulting  
Submit an Article Submit a Blog 
 Login Close
User Id:
Password:
 
Forgot Password
Forgot Username
Why Register
 Jump to
Skip Navigation Links
TechnologyExpand Technology
WebsiteExpand Website
 Resources  
Close
 Our Network  
Close
Search :       Advanced Search »
Home » BizTalk Server » Parsing BizTalk messages in .NET Components through Orchestration

Parsing BizTalk messages in .NET Components through Orchestration

This article discusses how to parse BizTalk messages in .NET Components through Orchestration.

Technologies: .NET 2.0,Visual C# .NET
Total downloads :
Total page views :  1081
Rating :
 5/5
This article has been rated :  1 times
   Print Read/Post comments Post a comment  Rate  
   Email to a friend  Bookmark  Similar Articles  Author's other articles  
 
Powerful ASP.NET Hosting w/ NO Setup Fees. Click Here!
Become a Sponsor


Related EbooksTop Videos



In most of our orchestrations where we need to parse a message, let's say for storing data from the message in a database to loop through the records in the message, we use XML Parsing. For this purpose, we have XpathNavigator class or we can use XMLDocument SelectNodes method, which returns an iterator and we can iterate the records in the XML. But consider a complex XML. For example, if there are many parent child nodes and we have to dig deeper into the nodes come back again to the parent and use nested while loops for parsing the whole XML.

Well for a good coder this won't be much of a problem but like a messy coder like me will run into exceptions and bugs. :)
Well how about if we take advantage of .NET Serialization/Deserialization? We pass the message as an XMLDocument object to our component method as a parameter we deserialize the xmldocument to an object. But wait which object? From where will this class come from?

We just need a proxy class of the web message type. The proxy class will contain the web message type and all of its nodes and then we can deserialize the xmldocument object containing the xml into a much managed object which we can iterate easily. You can generate the proxy class from visual studio command prompt and giving the proper switches will create the proxy class.
You can see the MSDN help for more switches of wsdl.
 wsdl /out:[dir]proxy.cs http://localhost/[webservice URI].asmx?wsdl
If you notice the webservice URI is missing from the command and we need a wsdl of the web service.

A simple workaround for this is in our BizTalk Schema project, which contains the type of message (schema) is built and then a web message should be published from the BizTalk Web Services Publishing Wizard. Just build your project and run the wizard. In the first step select the "Publish schemas as web services" option.

You will get a tree in the next step and yes the web service requires at least a request and response schemas.
 web_pub_1
 Right click the request schema and select the assembly (This assembly should be your BizTalk schemas project).
 choose_schema
  Select the root node of your schema, in the same way configure the response message as well (of your own choice) and you are done.
 web_pub
 In the next step give the URI of the web service and then the hierarchy in your IIS.
By running the command given above you will get the proxy class. Include this class in your component project (which will be most likely a .NET library project). (Note: If you don't see your schema type class in the intellisense, do check the proxy class and your component project namespaces). In your components method which will be parsing your message deserialize your xmldocument object to the object type of the proxy class. This will be the Root node (If you have one) name of your schema. In my case I used the code below. Xdoc is the object variable name of the type XMLDocument which will contain my xml data. And one more thing which I am sure most of the BizTalk guys will know you can assign your message freely to the XMLDocument type variable in your orchestration.
IFX response = new IFX();
XmlSerializer xs = new XmlSerializer(response.GetType());
XmlNodeReader reader = new XmlNodeReader(xdoc.DocumentElement,"Namespace");
response = (IFX)xs.Deserialize(reader);
In the above code, I was receiving a response and wanted to insert the records from the response into my table. This made me comfortably access the inner child records and arrays of the XML. May be you would get xml document runtime errors. Do check your XML that if it contains namespaces then deserialization will give exceptions. For this supply the Namespace of the root node in the XmlNodeReader constructor.


Login to add your contents and source code to this article
 [Top] Rate this article
 About the author
 
Abdul Rafay
Looking for C# Consulting?
C# Consulting is founded in 2002 by the founders of C# Corner. Unlike a traditional consulting company, our consultants are well-known experts in .NET and many of them are MVPs, authors, and trainers. We specialize in Microsoft .NET development and utilize Agile Development and Extreme Programming practices to provide fast pace quick turnaround results. Our software development model is a mix of Agile Development, traditional SDLC, and Waterfall models.
Click here to learn more about C# Consulting.
 
Introducing MaxV - one click. infinite control. Hyper-V Hosting from MaximumASP.
Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
Dynamic PDF
ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications.
Go.NET
Build custom interactive diagrams, network, workflow editors, flowcharts, or software design tools. Includes many predefined kinds of nodes, links, and basic shapes. Supports layers, scrolling, zooming, selection, drag-and-drop, clipboard, in-place editing, tooltips, grids, printing, overview window, palette. 100% implemented in C# as a managed .NET Control. Document/View/Tool architecture with many properties&events. Optional automatic layout.
Dundas Software
Dundas Chart for .NET is the most advanced .NET charting package available today.  With an extremely complete feature set, elegant architecture and easy implementation, Dundas Chart can quickly add advanced Charting functionality to enhance and transform ASP.NET and Windows Forms applications.  Whether you are implementing charting into internal projects, or building applications for clients, Dundas Chart offers advanced technology and advanced results to get the most out of data.
Clickatell's SMS Gateway
Clickatell's Developer Solutions allow you to SMS enable any website or application via a range of API's. Learn More about our API connections.
Free access to .NET Memory Management video
Everything you need to know about Garbage Collection, Temporary Objects, Fragmentation, Finalization and common causes of memory leaks in .NET. Watch the video here.
Microsoft Visual Studio 2010
Microsoft Visual Studio 2010 offers more to developers than any other Visual Studio release. Work more productively and collaboratively-with greater control over your work at every step. The Beta 2 can give you a head start on achieving efficiency.
 
   Print Read/Post comments Post a comment  Rate  
   Email to a friend  Bookmark  Similar Articles  Author's other articles  
 
 Post a Feedback, Comment, or Question about this article
Subject:  
Comment:  
Powerful ASP.NET Hosting w/ NO Setup Fees. Click Here!
Become a Sponsor
 Comments
Missing images by Mahesh On May 10, 2009
Abdul,
Can you edit this article and fix the images?

Thanks,
Mahesh
Reply | Email | Delete | Modify | 
You can comment on this article and give a feedback by Abdul On May 18, 2009
You can comment on this article and give a feedback. You can read the original article on my blog http://abdulrafaysbiztalk.wordpress.com/2008/10/15/63/ and you can visit my blog at http://abdulrafaysbiztalk.wordpress.com/
Reply | Email | Delete | Modify | 
sss by Suvasish On September 23, 2009
xxx
Reply | Email | Delete | Modify | 

 Hosted by MaximumASP  |  Found a broken link?  |  Contact Us  |  Terms & conditions  |  Privacy Policy  |  Site Map  |  Suggest an Idea  |  Media Kit
Current Version: 5.2009.6.2
 © 1999 - 2009  Mindcracker LLC. All Rights Reserved