<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:copyright="http://blogs.law.harvard.edu/tech/rss" xmlns:image="http://purl.org/rss/1.0/modules/image/">
    <channel>
        <title>Yossi Dahan</title>
        <link>http://geekswithblogs.net/Connected/Default.aspx</link>
        <description> </description>
        <language>en-GB</language>
        <copyright>Yossi Dahan</copyright>
        <managingEditor>yossi.dahan@sabratech.co.uk</managingEditor>
        <generator>Subtext Version 0.0.0.0</generator>
        <image>
            <title>Yossi Dahan</title>
            <url>http://geekswithblogs.net/images/RSS2Image.gif</url>
            <link>http://geekswithblogs.net/Connected/Default.aspx</link>
            <width>77</width>
            <height>60</height>
        </image>
        <item>
            <title>Shutting down</title>
            <link>http://geekswithblogs.net/Connected/archive/2009/04/02/shutting-down.aspx</link>
            <description>&lt;p&gt;When I was over at PDC the guys from GWB convinced me to move my blog to them (well, it didn’t take much convincing…), so I have, but  I kept cross-posting on my old blog as well until I make up my mind. &lt;/p&gt;  &lt;p&gt; &lt;/p&gt;  &lt;p&gt;Took me way too long, but I have now decided to stick with my old place. &lt;/p&gt;  &lt;p&gt;Cross posting is naturally not a good idea, and I shouldn’t have done that for that long – apart from me having to post twice each time, other people comments are not visible for all which is the worst aspect of it, and also I can’t get good statistics on traffic. &lt;/p&gt;  &lt;p&gt; &lt;/p&gt;  &lt;p&gt;The reason I stay on blogger is exactly that – I can easily point google analytics to it and get great reports (and I can better control my template, etc.&lt;/p&gt;  &lt;p&gt; &lt;/p&gt;  &lt;p&gt;Sorry if anybody find this irritating, I do hope anyone reading this would consider moving accross to &lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.sabratech.co.uk/blogs/yossidahan"&gt;www.sabratech.co.uk/blogs/yossidahan&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=130672"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=130672" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/Connected/aggbug/130672.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Yossi Dahan</dc:creator>
            <guid>http://geekswithblogs.net/Connected/archive/2009/04/02/shutting-down.aspx</guid>
            <pubDate>Thu, 02 Apr 2009 19:03:49 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/Connected/comments/130672.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/Connected/archive/2009/04/02/shutting-down.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/Connected/comments/commentRss/130672.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/Connected/services/trackbacks/130672.aspx</trackback:ping>
        </item>
        <item>
            <title>RoleClaimsMapper for the Geneva Framework</title>
            <category>Federated Identity</category>
            <category>Geneva</category>
            <link>http://geekswithblogs.net/Connected/archive/2009/04/01/roleclaimsmapper-for-the-geneva-framework.aspx</link>
            <description>&lt;p&gt;Briefly back on my STS work - &lt;/p&gt;  &lt;p&gt;Our STS implementation can already replace the authentication implementation of most of our applications; naturally we can’t do that just yet, given that the Geneva-framework has not been released yet, but all of my tests are quite positive so we’re just waiting for the opportunity to start using it.&lt;/p&gt;  &lt;p&gt;However, so far, we  were not in a position to replace the authorisation mechanism, not easily anyway, and that’s something that was on my list for some time now.&lt;/p&gt;  &lt;p&gt;The STS provides a list of claims, which the applications can relatively easily access via code, as many samples show, and this proves very useful; application can investigate various claims about a user and drive their functionality from that.&lt;/p&gt;  &lt;p&gt;It does mean, though, that the applications need to change to support this new claims based mode for authorisation, which is not something we can just assume we would be able to do; as a start, we just want to achieve an in-place replacement for our current authorisation logic.&lt;/p&gt;  &lt;p&gt;Most of our web apps currently use ASP.net membership and roles and so they extensively use ‘IsInRole’ checks to figure out user authorisation and drive the application behaviour, to start with, we had to hook to that mechanism.&lt;/p&gt;  &lt;p&gt;Luckily the Geveva framework has a relatively good support for exactly this need - , out of the box, it would convert any claims of the Microsoft role namespace (‘&lt;a title="http://schemas.microsoft.com/ws/2008/06/identity/claims/role" href="http://schemas.microsoft.com/ws/2008/06/identity/claims/role"&gt;http://schemas.microsoft.com/ws/2008/06/identity/claims/role&lt;/a&gt;’) to roles; so – if a token included a claim of this type with a value of ‘Manager’, a call to HttpContext.Current.User.IsInRole(“Manager”) would return true.&lt;/p&gt;  &lt;p&gt;And so I made sure my STS adds any roles with the correct claim type, very easy. &lt;/p&gt;  &lt;p&gt;However – this is very Microsoft centric. what about all those claims that come from systems that don’t follow Microsoft’s approach? (how dare they!) ? and what about us wanting to have our own claims, using our own types, some matching roles (while others may not…) - &lt;/p&gt;  &lt;p&gt;Well – we needed a way to map any claims to ms-role claims before the Geneva framework does its bit.&lt;/p&gt;  &lt;p&gt;As is often the case - Dominick Baier was most helpful in &lt;a href="http://www.leastprivilege.com/ClaimsAuthenticationManagerInGeneva.aspx" target="_blank"&gt;posting&lt;/a&gt; on exactly that, and so, following his example, I created my RoleClaimsMapper - &lt;/p&gt;  &lt;pre class="csharpcode"&gt;    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; RoleClaimMapper : ClaimsAuthenticationManager
    {
        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;override&lt;/span&gt; IClaimsPrincipal Authenticate(&lt;span class="kwrd"&gt;string&lt;/span&gt; endpointUri, IClaimsPrincipal incomingPrincipal)
        {
            &lt;span class="rem"&gt;//load configuration section for component&lt;/span&gt;
            RoleClaimsMapperConfigurationSection config = 
                (RoleClaimsMapperConfigurationSection)ConfigurationManager.GetSection(&lt;span class="str"&gt;"RoleClaimsMapper"&lt;/span&gt;);
            &lt;span class="rem"&gt;//create a collection of claim types and populate from configuratoin&lt;/span&gt;
            List&amp;lt;&lt;span class="kwrd"&gt;string&lt;/span&gt;&amp;gt; claimsToMap = &lt;span class="kwrd"&gt;new&lt;/span&gt; List&amp;lt;&lt;span class="kwrd"&gt;string&lt;/span&gt;&amp;gt;(config.RoleClaims.Count);
            &lt;span class="kwrd"&gt;foreach&lt;/span&gt; (RoleClaimConfigurationElement claimElement &lt;span class="kwrd"&gt;in&lt;/span&gt; config.RoleClaims)
                claimsToMap.Add(claimElement.ClaimType);
                
            &lt;span class="rem"&gt;//loop on all identities, we really only expect one, but can easily support multiple.&lt;/span&gt;
            &lt;span class="kwrd"&gt;foreach&lt;/span&gt; (IClaimsIdentity identity &lt;span class="kwrd"&gt;in&lt;/span&gt; incomingPrincipal.Identities)
            {
                &lt;span class="rem"&gt;//extract the claims that we need to map (matching the configured list of claims)&lt;/span&gt;
                IEnumerable&amp;lt;Claim&amp;gt; roleClaims = 
                    identity.Claims.Where&amp;lt;Claim&amp;gt;(c =&amp;gt; claimsToMap.Contains(c.ClaimType));
                &lt;span class="rem"&gt;//now create a role claim (using the MS role claim type) for each claim found; &lt;/span&gt;
                &lt;span class="rem"&gt;//need to keep this outside claim loop so we don't modify the collection while iterating&lt;/span&gt;
                List&amp;lt;Claim&amp;gt; claimsToAdd = &lt;span class="kwrd"&gt;new&lt;/span&gt; List&amp;lt;Claim&amp;gt;(roleClaims.Count()); 
                &lt;span class="kwrd"&gt;foreach&lt;/span&gt; (Claim claim &lt;span class="kwrd"&gt;in&lt;/span&gt; roleClaims)
                    claimsToAdd.Add(&lt;span class="kwrd"&gt;new&lt;/span&gt; Claim(Microsoft.IdentityModel.Claims.ClaimTypes.Role, claim.Value,claim.ValueType,&lt;span class="str"&gt;"local"&lt;/span&gt;,claim.Issuer));
                &lt;span class="rem"&gt;//add new claims to current identity&lt;/span&gt;
                identity.Claims.AddRange(claimsToAdd);
            }

            &lt;span class="kwrd"&gt;return&lt;/span&gt; incomingPrincipal;
        }
    }&lt;/pre&gt;
&lt;style type="text/css"&gt;&lt;![CDATA[


.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }]]&gt;&lt;/style&gt;

&lt;p&gt;I then configured my authentication manager with the framework - &lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;microsoft.identityModel&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;claimsAuthenticationManager&lt;/span&gt; &lt;span class="attr"&gt;type&lt;/span&gt;&lt;span class="kwrd"&gt;="RoleClaimMapper,Identity.Utilities"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;
  &lt;/pre&gt;
&lt;style type="text/css"&gt;&lt;![CDATA[


.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }]]&gt;&lt;/style&gt;

&lt;p&gt;and added my bit of custom configuration&lt;/p&gt;

&lt;pre class="csharpcode"&gt;  &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;RoleClaimsMapper&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;RoleClaims&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;add&lt;/span&gt; &lt;span class="attr"&gt;Type&lt;/span&gt;&lt;span class="kwrd"&gt;="http://someDomain.com/identity/claims/SomeRole"&lt;/span&gt;&lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;
      &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;add&lt;/span&gt; &lt;span class="attr"&gt;Type&lt;/span&gt;&lt;span class="kwrd"&gt;="http://someDomain.com/identity/claims/AnotherRole"&lt;/span&gt;&lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;RoleClaims&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;RoleClaimsMapper&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;style type="text/css"&gt;&lt;![CDATA[


.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }]]&gt;&lt;/style&gt;

&lt;p&gt;As you can see this code would take a list of claim types from configuration, and map all claims of these types to roles, adding them to the identity’s claims collection using the required claim type (leaving the original claim intact), and voila – when the app executes it can check the roles, corresponding to the values supplied in my custom claims using - &lt;/p&gt;

&lt;pre class="csharpcode"&gt;HttpContext.Current.User.IsInRole(“[custom claim &lt;span class="kwrd"&gt;value&lt;/span&gt;"]”);&lt;/pre&gt;

&lt;pre class="csharpcode"&gt;Very nice indeed!&lt;/pre&gt;
&lt;style type="text/css"&gt;&lt;![CDATA[


.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }]]&gt;&lt;/style&gt;

&lt;p align="left"&gt;&lt;font color="#ff0000"&gt;UPDATE: Dominic’s comment on this post  had indirectly suggested an even cleaner solution; instead of duplicating the claims, I can add the claim types I have as roles to each identity’s RoleClaimTypes collection; this achieves the same result in a much cleaner way, here is the updated function - &lt;/font&gt;&lt;/p&gt;

&lt;pre class="csharpcode"&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;override&lt;/span&gt; Microsoft.IdentityModel.Claims.IClaimsPrincipal Authenticate(&lt;span class="kwrd"&gt;string&lt;/span&gt; endpointUri, Microsoft.IdentityModel.Claims.IClaimsPrincipal incomingPrincipal)
        {
            &lt;span class="rem"&gt;//load configuration section for component&lt;/span&gt;
            RoleClaimsMapperConfigurationSection config = 
                (RoleClaimsMapperConfigurationSection)ConfigurationManager.GetSection(&lt;span class="str"&gt;"RoleClaimsMapper"&lt;/span&gt;);
                
            &lt;span class="rem"&gt;//loop on all identities, we really only expect one, but can easily support multiple.&lt;/span&gt;
            &lt;span class="kwrd"&gt;foreach&lt;/span&gt; (IClaimsIdentity identity &lt;span class="kwrd"&gt;in&lt;/span&gt; incomingPrincipal.Identities)
                &lt;span class="rem"&gt;//for each identity, add all the claim types that are role claim types.&lt;/span&gt;
                &lt;span class="kwrd"&gt;foreach&lt;/span&gt; (RoleClaimConfigurationElement claimElement &lt;span class="kwrd"&gt;in&lt;/span&gt; config.RoleClaims)
                    identity.RoleClaimTypes.Add(claimElement.ClaimType);

            &lt;span class="kwrd"&gt;return&lt;/span&gt; incomingPrincipal;
        }&lt;/pre&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=130631"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=130631" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/Connected/aggbug/130631.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Yossi Dahan</dc:creator>
            <guid>http://geekswithblogs.net/Connected/archive/2009/04/01/roleclaimsmapper-for-the-geneva-framework.aspx</guid>
            <pubDate>Wed, 01 Apr 2009 13:34:56 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/Connected/comments/130631.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/Connected/archive/2009/04/01/roleclaimsmapper-for-the-geneva-framework.aspx#feedback</comments>
            <slash:comments>1</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/Connected/comments/commentRss/130631.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/Connected/services/trackbacks/130631.aspx</trackback:ping>
        </item>
        <item>
            <title>Oslo based solution for deploying BizTalk applications &amp;ndash; the runtime</title>
            <category>M</category>
            <category>Oslo</category>
            <category>BizTalk</category>
            <link>http://geekswithblogs.net/Connected/archive/2009/03/29/oslo-based-solution-for-deploying-biztalk-applications-ndash-the-runtime.aspx</link>
            <description>&lt;p&gt;This is a third post in a series describing my Oslo based solution for deploying BizTalk applications; I’ve used this exercise to play around with ‘M’, but it was important for me to work on a real solution, with real benefits – something I could actually use…in &lt;a href="http://sabratech.co.uk/blogs/yossidahan/2009/03/oslo-based-solution-for-deploying.html" target="_blank"&gt;Part I&lt;/a&gt; I discussed the concept and presented both the “source code” of my app and the output I was working toward; &lt;a href="http://www.sabratech.co.uk/blogs/yossidahan/2009/03/oslo-based-solution-for-deploying_14.html" target="_blank"&gt;Part II&lt;/a&gt; was all about the MGrammar part of the solution.&lt;/p&gt;  &lt;p&gt;In this, third, part I will discuss the last missing piece –the runtime.&lt;/p&gt;  &lt;p&gt;Before I start, though, I would say that I did find getting into ‘M’ somewhat confusing at first; and while it’s more than just possible I’m still missing some things , I hope this series could help one or two people in their journey with Oslo – which is, without a doubt, an exciting one!&lt;/p&gt;  &lt;p&gt;There are two things, I believe, that contributed to my confusion - the first is the fact the M is really many things, quite different things, actually; from what I hear Microsoft have identified the challenge some of us (me) are having getting a grasp on ‘M’ and are hard at work to bring things [closer] together; hopefully it won’t be long before we know how the converged language looks like, in the mean time one simply has to remember that - &lt;/p&gt;  &lt;p&gt;There’s &lt;strong&gt;MSchema&lt;/strong&gt; - which you could use to define models,  a bit like xml-schema, or declaring your classes in code or even tables in SQL; I haven’t really touched on MSchema in this series butI might come back to that later.&lt;/p&gt;  &lt;p&gt;Then there’s &lt;strong&gt;MGraph&lt;/strong&gt;, which is a way to define instances of things, possibly ones that have been modelled using MSchema, but, as is evident from my little project, not necessarily - MGraph can be very useful even if you don’t have a model- as long as you have your grammar – in comes &lt;strong&gt;MGrammar&lt;/strong&gt;, the third spect of ‘M’, which can be used to define a syntax for your very own [domain-sepcific-]languge for describing things;     &lt;br /&gt;A ‘runtime’ could then be used to processes instances described as MGrammar as a result of inputs in your language.&lt;/p&gt;  &lt;p&gt;And that is the second thing that really confused me – what is that ‘runtime’? in all the ‘M’ presentations I’ve seen, the ‘runtime’ was merely mentioned and has never received enough “floor space” and yet – an MGrammar without a runtime, in the majority of cases, is, quite useless; you have to have a runtime that would act on your source code; in fact – the runtime would act on the MGraph resulting from your language, which is what makes it all so brilliant, because in a sense, this is where everything comes together – you runtime can work on instances described in your language, on MGraph instances stored in the repository created using MSchema and possibly even ones defined using Quadrant.&lt;/p&gt;  &lt;p&gt;The point is that there must be a runtime that understand the model behind your language , can parse its graph and then do whatever you need it to do; and it is your job to build that runtime.&lt;/p&gt;  &lt;p&gt;So what have I done for my runtime? here’s a quick overview (reminder: the full source code will find its way shortly onto codeplex) - &lt;/p&gt;  &lt;p&gt;My runtime is a console application, one that takes a source code file path as an argument and outputs MSBuild files (and dependencies) that can be used to deploy the application described in the source code onto BizTalk Server.&lt;/p&gt;  &lt;p&gt;The first part of my runtime - which I will not bore you with -  is about validating the command line arguments; standard stuff.&lt;/p&gt;  &lt;p&gt;The second part is about creating  the parser for my language, where, thankfully, the Oslo SDK does all of the heavy lifting – it includes a class called DynamicParser which, once created, you can use to parse your source code.&lt;/p&gt;  &lt;p&gt;To create the DynamicParser you must first compile your language, and that’s easy enough to do – you start by creating a compiler&lt;/p&gt;  &lt;pre class="code"&gt;&lt;span style="color: #2b91af"&gt;MGrammarCompiler &lt;/span&gt;compiler = &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;MGrammarCompiler&lt;/span&gt;();&lt;/pre&gt;

&lt;p&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;and continue by supplying your grammar &lt;/p&gt;

&lt;pre class="code"&gt;compiler.SourceItems = &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;SourceItem&lt;/span&gt;[] {
        &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;SourceItem &lt;/span&gt;{
            Name=&lt;span style="color: #a31515"&gt;"BTSDeploy"&lt;/span&gt;,
            ContentType = &lt;span style="color: #2b91af"&gt;ContentType&lt;/span&gt;.Mg,
            TextReader = &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;StreamReader&lt;/span&gt;(GetLanguageDefinition())
        }
    };&lt;/pre&gt;

&lt;p&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;(GetLanguageDefinition() is a simple helper method I wrote to get the grammar file embedded as a resource in the exe)&lt;/p&gt;

&lt;p&gt;Now you’re ready to compile your language, but to make things manageable you want to provide it with an error reported; the compiler would report any errors to the stream you would provide, I’ve naturally used the console &lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: #2b91af"&gt;TextWriterReporter &lt;/span&gt;errorReporter = &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;TextWriterReporter&lt;/span&gt;(&lt;span style="color: #2b91af"&gt;Console&lt;/span&gt;.Out);
&lt;span style="color: blue"&gt;if &lt;/span&gt;(compiler.Compile(errorReporter) != 0 || errorReporter.HasErrors)
{
    Log(&lt;span style="color: #a31515"&gt;"Failed to compile language definition\nSee above for details"&lt;/span&gt;);
    &lt;span style="color: blue"&gt;return null&lt;/span&gt;;
}&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;p&gt;If the compilation succeeded you are ready to create your parser - &lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: #2b91af"&gt;DynamicParser &lt;/span&gt;parser = &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;DynamicParser&lt;/span&gt;();
compiler.LoadDynamicParser(parser);&lt;/pre&gt;

&lt;p&gt;That’s part one of three done.&lt;/p&gt;

&lt;p&gt;The next step is to use the dynamic parser to parse your source code, the output of which would be a graph representation of the source; luckily the SDK does virtually all the lifting here as well, and it comes down to one line - &lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;object &lt;/span&gt;rootNode = parser.Parse&amp;lt;&lt;span style="color: blue"&gt;object&lt;/span&gt;&amp;gt;(sourceCodeFileName, &lt;span style="color: blue"&gt;null&lt;/span&gt;, errorReporter);&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;p&gt;Note that the output type is object – which, as you will find out if you try this out, is quite painful– currently all the types used in the Graph are internal, which makes debugging quite difficult (you can’t quite look at any variables you hold in any meaningful way, you have to keep calling methods, as you’ll see next; hopefully this will change one of the next updates to the SDK.&lt;/p&gt;

&lt;p&gt;In any case rootNode is now pointing at the root of a graph – a tree like structure you could ‘walk’ to extract the pieces of information you care about in the source code; here you’re expected to use methods like GetLabel, GetSequenceElements and GetSuccessors to reach nodes and their values in the graph and, of course, to do that you need to know exactly how your graph looks like; my first instinct was to look at the PreviewMode pane in intellipad (usually the right most pane when working with MGrammar) as it shows you a representation of the MGraph created for the source code and language used; this worked quite well, but, as I found out, wasn’t the most trivial thing – the two didn’t align completely and I ended up having to resort to trail-and-error to get the parsing logic right.&lt;/p&gt;

&lt;p&gt;The reason is that M has a few shortcuts one could take, but the graph you would be working on is the very basic, more verbose format; some information on this is mentioned &lt;a href="http://social.msdn.microsoft.com/Forums/en-US/oslo/thread/51ddc676-3a9b-4de4-92d1-b24f80cd57dc/" target="_blank"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Then, on a recent visit to Redmond, &lt;a href="http://blogs.msdn.com/dkaufman/" target="_blank"&gt;Dana Kaufman&lt;/a&gt; passed on a great tip – if you ‘compile’ your grammar using mg.exe to create the mgx file (basically a ZIP file containing XAML representation of language) and then use mgx.exe on your source file adding  a reference to the mgx file you just created, you end up with an ‘M’ file which is exactly the graph your runtime would be working on.end up with; so useful!&lt;/p&gt;

&lt;p&gt;So – here are a few example of how I worked the graph – to start with I knew my root node should be a node with the label ‘Application’, so I checked it this way - &lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;string&lt;/span&gt; label = graph.GetLabel(rootNode).ToString();
&lt;span class="kwrd"&gt;if&lt;/span&gt; (label != &lt;span class="str"&gt;"Application"&lt;/span&gt;)&lt;/pre&gt;
&lt;style type="text/css"&gt;&lt;![CDATA[



.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }]]&gt;&lt;/style&gt;&lt;style type="text/css"&gt;&lt;![CDATA[



.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }]]&gt;&lt;/style&gt;

&lt;p&gt;I then knew that the application name would be a child element of the root node, so I extracted it like this &lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="rem"&gt;// extract the application's data - this should contain two nodes - the application name and the list of items in the application&lt;/span&gt;
List&amp;lt;&lt;span class="kwrd"&gt;object&lt;/span&gt;&amp;gt; appData = graph.GetSequenceElements(rootNode).ToList&amp;lt;&lt;span class="kwrd"&gt;object&lt;/span&gt;&amp;gt;();
&lt;span class="rem"&gt;//first line should be the application name, make sure it is not a node and extract the label&lt;/span&gt;
&lt;span class="kwrd"&gt;if&lt;/span&gt; (!graph.IsNode(appData[0]))
    Contents.AppName = appData[0].ToString();&lt;/pre&gt;
&lt;style type="text/css"&gt;&lt;![CDATA[



.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }]]&gt;&lt;/style&gt;

&lt;p&gt;the second node in the appData collection is where the graph ‘continues’, so to get the list of things that compose my application I needed to walk down that path -&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="rem"&gt;//the second element should be the list of lines&lt;/span&gt;
&lt;span class="kwrd"&gt;foreach&lt;/span&gt; (&lt;span class="kwrd"&gt;object&lt;/span&gt; section &lt;span class="kwrd"&gt;in&lt;/span&gt; graph.GetSuccessors(appData[i]))
{
  &lt;span class="rem"&gt;//each successor would be a category (reference, importing binding, resource, etc), with a list of items&lt;/span&gt;
  processSection(graph,section);
}&lt;/pre&gt;

&lt;p&gt;&lt;/p&gt;&lt;style type="text/css"&gt;&lt;![CDATA[



.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }]]&gt;&lt;/style&gt;with processSection start with 

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;string&lt;/span&gt; sectionName = graph.GetSequenceLabel(graph.GetSuccessors(section).First()).ToString();
List&amp;lt;&lt;span class="kwrd"&gt;object&lt;/span&gt;&amp;gt; items = graph.GetSuccessors(graph.GetSuccessors(section).First()).ToList&amp;lt;&lt;span class="kwrd"&gt;object&lt;/span&gt;&amp;gt;();

Log(&lt;span class="str"&gt;"Found section '{0}'"&lt;/span&gt;, sectionName);
&lt;span class="kwrd"&gt;switch&lt;/span&gt; (sectionName)&lt;/pre&gt;

&lt;p&gt;&lt;/p&gt;&lt;style type="text/css"&gt;&lt;![CDATA[



.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }]]&gt;&lt;/style&gt;

&lt;p&gt;I hope that from these few examples you can see what it takes to work the graph – the graphBuilder (which is a somewhat confusing name, as I’m using it to walk the graph, not build it) has all the methods you need to access the various nodes ( but there’s no xpath-like- support), but as all the types are (currently) internal to the MS assembly you’re always working with objects, which is less then ideal.&lt;/p&gt;

&lt;p&gt;Again – my full source code is on its way to codeplex, I just want to make sure it’s commented well enough to be well understood, and am struggling with time, but the bottom line is that once you figure out how the graph builder works, learnt how to see your graph visually (using mg.exe and mgx.exe) and got used to the fact that you’re dealing with objects for now, parsing the source code is very easy.&lt;/p&gt;

&lt;p&gt;Obviously it is completely down to you what you then do with all the information you’ve extracted from the source code; in my case  my runtime is using a plug-in model so the first part is all about using the Oslo SDK to get an instance of a BizTalkDeployment class populated based on the contents of the input file, this class looks like - &lt;/p&gt;

&lt;pre class="csharpcode"&gt;    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; BizTalkDeployment
    {
        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; AppName { get; set; }
        &lt;span class="kwrd"&gt;public&lt;/span&gt; List&amp;lt;&lt;span class="kwrd"&gt;object&lt;/span&gt;&amp;gt; References { get; set; }
        &lt;span class="kwrd"&gt;public&lt;/span&gt; List&amp;lt;&lt;span class="kwrd"&gt;object&lt;/span&gt;&amp;gt; Build { get; set; }
        &lt;span class="kwrd"&gt;public&lt;/span&gt; List&amp;lt;BizTalkAssembly&amp;gt; BizTalkAssemblies { get; set; }
        &lt;span class="kwrd"&gt;public&lt;/span&gt; List&amp;lt;&lt;span class="kwrd"&gt;object&lt;/span&gt;&amp;gt; ImportBindings { get; set; }
        &lt;span class="kwrd"&gt;public&lt;/span&gt; List&amp;lt;Binding&amp;gt; AddBindings { get; set; }
        &lt;span class="kwrd"&gt;public&lt;/span&gt; List&amp;lt;Assembly&amp;gt; Resources { get; set; }
    }&lt;/pre&gt;
&lt;style type="text/css"&gt;&lt;![CDATA[



.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }]]&gt;&lt;/style&gt;I then use late binding and configuration to load a plug in that would take an instance of this class and do the work, be it generation of msbuild scripts, deploying to the local machine using BTSTask or anything else. 

&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=130494"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=130494" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/Connected/aggbug/130494.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Yossi Dahan</dc:creator>
            <guid>http://geekswithblogs.net/Connected/archive/2009/03/29/oslo-based-solution-for-deploying-biztalk-applications-ndash-the-runtime.aspx</guid>
            <pubDate>Sun, 29 Mar 2009 14:56:28 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/Connected/comments/130494.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/Connected/archive/2009/03/29/oslo-based-solution-for-deploying-biztalk-applications-ndash-the-runtime.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/Connected/comments/commentRss/130494.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/Connected/services/trackbacks/130494.aspx</trackback:ping>
        </item>
        <item>
            <title>On Atomic Scope and Message Publishing</title>
            <category>BizTalk</category>
            <link>http://geekswithblogs.net/Connected/archive/2009/03/23/on-atomic-scope-and-message-publishing.aspx</link>
            <description>&lt;p&gt;A few weeks back I worked on a process that looked something like this - &lt;/p&gt;  &lt;p&gt;It was triggered by the &lt;a href="http://biztalkscheduledtask.codeplex.com/" target="_blank"&gt;scheduled task adapter&lt;/a&gt; and then used a SQL send port to call SP to return list of ‘things’.     &lt;br /&gt;It needed to split the things in the list to individual records, and to start a new, different, process, through pub/sub (to avoid the binary dependency with the called process), for each ‘thing’.&lt;/p&gt;  &lt;p&gt;Fairly simple. &lt;/p&gt;  &lt;p&gt;A lot of have been said on the different ways to split messages, I won’t repeat this discussion here; I would just say that initially I used a different approach – I used the SQL adapter in the initial, triggering, receive port and then used a receive pipeline, with an XmlDisassembler component, to split the incoming  message so that each record was published individually thus avoiding the need to have a ‘master process’; that back fired though, in my case – I quickly realised I’ll be choking the server with the amount of messages published and needed a way to throttle the execution; I’ve played a bit with host throttling but then came to the conclusion the best approach for me would be to throttle in a process, which is what I’ve done.&lt;/p&gt;  &lt;p&gt;And so - to make things interesting, and because I already had it all ready - I decided to use a call to a pipeline from my process to split the message.&lt;/p&gt;  &lt;p&gt;The first thing I realised, trying to take that approach, was that I had to change type of the response message received from the SQL port to be XmlDocument (which is an approach I generally dislike – I’m a sucker for strongly-typed-everything) – but my schema was configured as an envelope so that when I call the pipeline from my process it knows how to split it correctly, but, when used in the SQL port BizTalk split the message too early for me – I needed to whole message in the process first, which was no good to me; if , however, I removed the envelope definition from the schema when I would call the pipeline directly from my process it won’t know how to split the message, which is no good either; nor could i have two schemas (BizTalk, as we all know, dones’t like that bit at all, not without even more configuration); XmlDocument it is.&lt;/p&gt;  &lt;p&gt;It then came back to me (in the form of a compile time error :-)) that the pipeline variable has to exist in an atomic scope, and so I added one to contain my pipeline variable; I then added the necessary loop with the condition set to the GetNext() method of the pipeline and in each iteration constructed a message using the GetCurrent() method; all standard stuff.&lt;/p&gt;  &lt;p&gt;I would then set some context properties to route my message correctly and allow me to correlate the responses (I used a scatter-gather pattern in my master process) and published it to the message box&lt;/p&gt;  &lt;p&gt;What I noticed when testing my shiny new process was that all those sub-processes that were meant to start as a result the published messages in my loop were delayed by quite a few minutes (6-8), which seemed completely unreasonable, so I embarked on a troubleshooting exercise which resulting in that big “I should have thought of that!” moment.&lt;/p&gt;  &lt;p&gt;While the send shape in my loop successfully completed its act of publishing the message in each iteration, moving my loop to the next message and so on, being in an atomic scope BizTalk would not commit the newly published messages to the message box database, allowing subscriptions to kick in, before the atomic scope would finish; that is to allow it to rollback should something in the atomic scope would fail.    &lt;br /&gt;What it meant for me though, was that all the messages were still effectively published at once, which brought me back to square one (or, minus one, actually, considering that the great delay caused my this approach means I’m even worse off from my first debatch-in-pipeline approach).&lt;/p&gt;  &lt;p&gt;And so I went back to the old and familiar approach of splitting the messages using xpath in the process, which allowed me to carefully control the publishing rate of messages for my process and throttle them as needed.&lt;/p&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=130322"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=130322" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/Connected/aggbug/130322.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Yossi Dahan</dc:creator>
            <guid>http://geekswithblogs.net/Connected/archive/2009/03/23/on-atomic-scope-and-message-publishing.aspx</guid>
            <pubDate>Mon, 23 Mar 2009 14:16:31 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/Connected/comments/130322.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/Connected/archive/2009/03/23/on-atomic-scope-and-message-publishing.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/Connected/comments/commentRss/130322.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/Connected/services/trackbacks/130322.aspx</trackback:ping>
        </item>
        <item>
            <title>ASMX, WCF and enums woes</title>
            <category>BizTalk</category>
            <category>WCF</category>
            <link>http://geekswithblogs.net/Connected/archive/2009/03/18/asmx-wcf-and-enums-woes.aspx</link>
            <description>&lt;p&gt;We’ve been slowly migrating our services from asmx to WCF, but as we’re still using BizTalk 2006 with no support for WCF we’ve been exposing endpoints configured for basicHttpBinding and consume them using the SOAP adapter.&lt;/p&gt; &lt;p&gt;Generally speaking things have been going well, although we completely gave up on the idea of moving the services to WCF and NOT have to change the client, until yesterday we’ve stumbled into a serialisation issue – &lt;/p&gt; &lt;p&gt;The SOAP adapter, as part of its work deserialises the request message arriving through the send port into t he web service proxy class it generated, before calling the web service (which would result in the class now being serialised back into xml, which is another story); that deserialisation failed.&lt;/p&gt; &lt;p&gt;The error message was clear enough and indicated it failed to deserialise an enum parameter the service was expecting, and that ran a bell – I &lt;a href="http://www.sabratech.co.uk/blogs/yossidahan/2008/09/calling-web-service-with-enumeration.html"&gt;posted&lt;/a&gt; on exactly that back in September, but after carefully checking and re-checking everything we could swear that our message (which was now suspended) matches perfectly the schema generated by the add web reference wizard; what’s going on then??&lt;/p&gt; &lt;p&gt;After chasing our tail for a short while we brought up reflector to the rescue and found out the cause of our woe is a combination of a difference in behaviour between WCF and ASMX and the use of BizTalk – here are the details – &lt;/p&gt; &lt;p&gt;Consider the following asmx web method  – &lt;/p&gt;&lt;pre class="code"&gt;[&lt;span style="color: #2b91af"&gt;WebMethod]
 &lt;/span&gt;&lt;span style="color: blue"&gt;public string GetDataUsingDataContract(&lt;/span&gt;&lt;span style="color: #2b91af"&gt;CompositeType.someEnum myEnum)
 {
     &lt;/span&gt;&lt;span style="color: blue"&gt;return &lt;/span&gt;&lt;span style="color: #a31515"&gt;"Hello World";
 }
&lt;/span&gt;&lt;/pre&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;
&lt;p&gt;With CompositeType being &lt;/p&gt;&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;public class &lt;/span&gt;&lt;span style="color: #2b91af"&gt;CompositeType
 {
   &lt;/span&gt;&lt;span style="color: blue"&gt;public enum &lt;/span&gt;&lt;span style="color: #2b91af"&gt;someEnum
   {
      Value1,
      Value2
   }
 }&lt;/span&gt;&lt;/pre&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;
&lt;p&gt;(..and pretend CompositeType has many more things, but these are irrelevant to this topic)&lt;/p&gt;
&lt;p&gt;The definition for myEnum in the WSDL looks like &lt;/p&gt;&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;s:element &lt;/span&gt;&lt;span style="color: red"&gt;minOccurs&lt;/span&gt;&lt;span style="color: blue"&gt;="1" &lt;/span&gt;&lt;span style="color: red"&gt;maxOccurs&lt;/span&gt;&lt;span style="color: blue"&gt;="1" &lt;/span&gt;&lt;span style="color: red"&gt;name&lt;/span&gt;&lt;span style="color: blue"&gt;="myEnum" &lt;/span&gt;&lt;span style="color: red"&gt;type&lt;/span&gt;&lt;span style="color: blue"&gt;="tns:someEnum" /&amp;gt;
&lt;/span&gt;&lt;/pre&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;
&lt;p&gt;Where the type tns:someEnum looks like &lt;/p&gt;&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;s:simpleType &lt;/span&gt;&lt;span style="color: red"&gt;name&lt;/span&gt;&lt;span style="color: blue"&gt;="someEnum"&amp;gt;
    &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;s:restriction &lt;/span&gt;&lt;span style="color: red"&gt;base&lt;/span&gt;&lt;span style="color: blue"&gt;="s:string"&amp;gt;
    &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;s:enumeration &lt;/span&gt;&lt;span style="color: red"&gt;value&lt;/span&gt;&lt;span style="color: blue"&gt;="Value1" /&amp;gt;
    &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;s:enumeration &lt;/span&gt;&lt;span style="color: red"&gt;value&lt;/span&gt;&lt;span style="color: blue"&gt;="Value2" /&amp;gt;
    &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;s:restriction&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
 &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;s:simpleType&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
&lt;/span&gt;&lt;/pre&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;
&lt;p&gt;As a result the definition of the enum in a proxy generated via the add web reference VS 2005 option (which is what BizTalk would use) looks like – &lt;/p&gt;&lt;pre class="code"&gt;[System.CodeDom.Compiler.&lt;span style="color: #2b91af"&gt;GeneratedCodeAttribute&lt;/span&gt;(&lt;span style="color: #a31515"&gt;"System.Xml"&lt;/span&gt;, &lt;span style="color: #a31515"&gt;"2.0.50727.3053"&lt;/span&gt;)]
 [System.&lt;span style="color: #2b91af"&gt;SerializableAttribute&lt;/span&gt;()]
 [System.Xml.Serialization.&lt;span style="color: #2b91af"&gt;XmlTypeAttribute&lt;/span&gt;(Namespace=&lt;span style="color: #a31515"&gt;"http://tempuri.org/"&lt;/span&gt;)]
 &lt;span style="color: blue"&gt;public enum &lt;/span&gt;&lt;span style="color: #2b91af"&gt;someEnum &lt;/span&gt;&lt;/pre&gt;&lt;pre class="code"&gt;&lt;span style="color: #2b91af"&gt; &lt;/span&gt;{
     Value1,
     Value2,
 }
&lt;/pre&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;span style="color: gray"&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;/span&gt;
&lt;p&gt;All makes sense.&lt;/p&gt;
&lt;p&gt;Now, let’s look at what WCF does in the same case; consider the following service – &lt;/p&gt;&lt;pre class="code"&gt;[&lt;span style="color: #2b91af"&gt;ServiceContract&lt;/span&gt;]
 &lt;span style="color: blue"&gt;public interface &lt;/span&gt;&lt;span style="color: #2b91af"&gt;IService1
 &lt;/span&gt;{

   [&lt;span style="color: #2b91af"&gt;OperationContract&lt;/span&gt;]
    &lt;span style="color: blue"&gt;string &lt;/span&gt;GetDataUsingDataContract(&lt;span style="color: #2b91af"&gt;CompositeType&lt;/span&gt;.&lt;span style="color: #2b91af"&gt;someEnum &lt;/span&gt;myEnum);
 }

 [&lt;span style="color: #2b91af"&gt;DataContract&lt;/span&gt;]
 &lt;span style="color: blue"&gt;public class &lt;/span&gt;&lt;span style="color: #2b91af"&gt;CompositeType
 &lt;/span&gt;{

    &lt;span style="color: blue"&gt;public enum &lt;/span&gt;&lt;span style="color: #2b91af"&gt;someEnum
    &lt;/span&gt;{
        Value1,
        Value2
    }
 }
&lt;/pre&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;
&lt;p&gt;The WSDL generated looks like &lt;/p&gt;&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;xs:simpleType &lt;/span&gt;&lt;span style="color: red"&gt;name&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;CompositeType.someEnum&lt;/span&gt;"&lt;span style="color: blue"&gt;&amp;gt;
 &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;xs:restriction &lt;/span&gt;&lt;span style="color: red"&gt;base&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;xs:string&lt;/span&gt;"&lt;span style="color: blue"&gt;&amp;gt;
   &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;xs:enumeration &lt;/span&gt;&lt;span style="color: red"&gt;value&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;Value1&lt;/span&gt;" &lt;span style="color: blue"&gt;/&amp;gt;
   &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;xs:enumeration &lt;/span&gt;&lt;span style="color: red"&gt;value&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;Value2&lt;/span&gt;" &lt;span style="color: blue"&gt;/&amp;gt;
 &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;xs:restriction&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
 &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;xs:simpleType&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
 &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;xs:element &lt;/span&gt;&lt;span style="color: red"&gt;name&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;CompositeType.someEnum&lt;/span&gt;" &lt;span style="color: red"&gt;nillable&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;true&lt;/span&gt;" &lt;span style="color: red"&gt;type&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;tns:CompositeType.someEnum&lt;/span&gt;" &lt;span style="color: blue"&gt;/&amp;gt;
&lt;/span&gt;&lt;/pre&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;
&lt;p&gt;The key difference is that the name of the class containing the enum has made it into the type name for the enum, which never happened in the ASMX version.&lt;/p&gt;
&lt;p&gt;As a result the proxy is generated as such - &lt;/p&gt;&lt;pre class="code"&gt;[System.CodeDom.Compiler.&lt;span style="color: #2b91af"&gt;GeneratedCodeAttribute&lt;/span&gt;(&lt;span style="color: #a31515"&gt;"System.Runtime.Serialization"&lt;/span&gt;, &lt;span style="color: #a31515"&gt;"3.0.0.0"&lt;/span&gt;)]
 [System.Runtime.Serialization.&lt;span style="color: #2b91af"&gt;DataContractAttribute&lt;/span&gt;(Name=&lt;span style="color: #a31515"&gt;"CompositeType.someEnum"&lt;/span&gt;, &lt;br /&gt;                  Namespace=&lt;span style="color: #a31515"&gt;"http://schemas.datacontract.org/2004/07/WcfService1"&lt;/span&gt;)]
 &lt;span style="color: blue"&gt;public enum &lt;/span&gt;&lt;span style="color: #2b91af"&gt;CompositeTypesomeEnum &lt;/span&gt;: &lt;span style="color: blue"&gt;int &lt;/span&gt;&lt;/pre&gt;&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;&lt;/span&gt;{
   [System.Runtime.Serialization.&lt;span style="color: #2b91af"&gt;EnumMemberAttribute&lt;/span&gt;()]
    Value1 = 0,
   [System.Runtime.Serialization.&lt;span style="color: #2b91af"&gt;EnumMemberAttribute&lt;/span&gt;()]
    Value2 = 1,
 }
&lt;/pre&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;
&lt;p&gt;Again – note the name given to the element now contains the class name and, crucially, a dot (‘.’).&lt;/p&gt;
&lt;p&gt;On it’s own – nothing to malicious – although it’s another nail in the coffin for the idea that you can substitute web service with WCF service, configured them to use basicHttpBinding and all should be the same (ok – am I the only one still wishing this was possible?)&lt;/p&gt;
&lt;p&gt;Enters BizTalk.&lt;/p&gt;
&lt;p&gt;When you use the add web reference wizard to add a reference to the &lt;b&gt;WCF&lt;/b&gt; service, BizTalk generates all the schemas and proxy for you, which is what you would use to create requests going to the service (and process responses).&lt;/p&gt;
&lt;p&gt;Because the WSDL of the WCF service contains the longer name of the enum (with the class name, the dot and the enum name) the .net proxy generated is identical to the one created for the WCF service above; the schema, however, is generated incorrectly!&lt;/p&gt;
&lt;p&gt;BizTalk “kindly” decides that having dots in the element name is not a good idea and removes it so the schema generated looks like this – &lt;/p&gt;&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;xs:schema &lt;/span&gt;&lt;span style="color: red"&gt;xmlns:tns&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;http://schemas.datacontract.org/2004/07/WcfService1&lt;/span&gt;" &lt;span style="color: red"&gt;elementFormDefault&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;qualified&lt;/span&gt;" &lt;br /&gt;          &lt;span style="color: red"&gt;targetNamespace&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;http://schemas.datacontract.org/2004/07/WcfService1&lt;/span&gt;" &lt;br /&gt;          &lt;span style="color: red"&gt;xmlns:xs&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;&lt;a href="http://www.w3.org/2001/XMLSchema&amp;quot;&amp;gt;"&gt;http://www.w3.org/2001/XMLSchema&lt;/a&gt;&lt;/span&gt;"&lt;span style="color: blue"&gt;&amp;gt;
 &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;xs:element &lt;/span&gt;&lt;span style="color: red"&gt;name&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;CompositeTypesomeEnum&lt;/span&gt;" &lt;span style="color: red"&gt;type&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;tns:CompositeTypesomeEnum&lt;/span&gt;" &lt;span style="color: blue"&gt;/&amp;gt;
 &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;xs:simpleType &lt;/span&gt;&lt;span style="color: red"&gt;name&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;CompositeTypesomeEnum&lt;/span&gt;"&lt;span style="color: blue"&gt;&amp;gt;
   &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;xs:restriction &lt;/span&gt;&lt;span style="color: red"&gt;base&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;xs:string&lt;/span&gt;"&lt;span style="color: blue"&gt;&amp;gt;
      &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;xs:enumeration &lt;/span&gt;&lt;span style="color: red"&gt;value&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;Value1&lt;/span&gt;" &lt;span style="color: blue"&gt;/&amp;gt;
      &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;xs:enumeration &lt;/span&gt;&lt;span style="color: red"&gt;value&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;Value2&lt;/span&gt;" &lt;span style="color: blue"&gt;/&amp;gt;
   &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;xs:restriction&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
 &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;xs:simpleType&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;xs:schema&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
&lt;/span&gt;&lt;/pre&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;
&lt;p&gt;“CompositeTypesomeEnum”??????&lt;/p&gt;
&lt;p&gt;Well, we’ve seen this, and created a message with exactly that element, which – of course – the SOAP adapter failed to deserialise into &lt;/p&gt;&lt;pre class="code"&gt;[System.Runtime.Serialization.&lt;span style="color: #2b91af"&gt;DataContractAttribute&lt;/span&gt;(Name=&lt;span style="color: #a31515"&gt;"CompositeType.someEnum"&lt;/span&gt;, &lt;br /&gt;                                                    Namespace=&lt;span style="color: #a31515"&gt;"http://schemas.datacontract.org/2004/07/WcfService1"&lt;/span&gt;)]
 &lt;span style="color: blue"&gt;public enum &lt;/span&gt;&lt;span style="color: #2b91af"&gt;CompositeTypesomeEnum &lt;/span&gt;: &lt;span style="color: blue"&gt;int &lt;/span&gt;&lt;/pre&gt;&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;&lt;/span&gt;{
   [System.Runtime.Serialization.&lt;span style="color: #2b91af"&gt;EnumMemberAttribute&lt;/span&gt;()]
   Value1 = 0,
   [System.Runtime.Serialization.&lt;span style="color: #2b91af"&gt;EnumMemberAttribute&lt;/span&gt;()]
   Value2 = 1,
 }
&lt;/pre&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;The solution was fairly simple – we’ve simple change our xsl to put the element name as the .net proxy requires it, and not as the schema describes it, and it all worked well.&lt;/p&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=130182"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=130182" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/Connected/aggbug/130182.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Yossi Dahan</dc:creator>
            <guid>http://geekswithblogs.net/Connected/archive/2009/03/18/asmx-wcf-and-enums-woes.aspx</guid>
            <pubDate>Wed, 18 Mar 2009 15:18:08 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/Connected/comments/130182.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/Connected/archive/2009/03/18/asmx-wcf-and-enums-woes.aspx#feedback</comments>
            <slash:comments>4</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/Connected/comments/commentRss/130182.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/Connected/services/trackbacks/130182.aspx</trackback:ping>
        </item>
        <item>
            <title>Ok, got your message, now let us have xsl re-use!</title>
            <category>BizTalk</category>
            <link>http://geekswithblogs.net/Connected/archive/2009/03/16/ok-got-your-message-now-let-us-have-xsl-re-use.aspx</link>
            <description>&lt;p&gt;From the &lt;a href="http://support.microsoft.com/kb/945924" target="_blank"&gt;Microsoft Knowledgebase&lt;/a&gt;  - &lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;The &amp;lt;xsl:import&amp;gt; element is used to import an external XSLT file. The &amp;lt;xsl:include&amp;gt; element is used to include an external XSLT file. You cannot use these elements in custom XSLT files that are defined in the Custom XSL Path Grid Properties in a BizTalk project. You cannot do this because a Uniform Resource Identifier (URI) that is defined in an external XSLT file may be from a nonsecure source such as the Internet.&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Am I (well, and Ben Gimblett here)  the only one who thinks this is a lame excuse? since when MS tries to protect developers from stupidity? and in any case, if they really wanted to do that – wouldn’t they have to prevent us from writing ANY code?&lt;/p&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=130110"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=130110" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/Connected/aggbug/130110.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Yossi Dahan</dc:creator>
            <guid>http://geekswithblogs.net/Connected/archive/2009/03/16/ok-got-your-message-now-let-us-have-xsl-re-use.aspx</guid>
            <pubDate>Mon, 16 Mar 2009 13:46:55 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/Connected/comments/130110.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/Connected/archive/2009/03/16/ok-got-your-message-now-let-us-have-xsl-re-use.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/Connected/comments/commentRss/130110.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/Connected/services/trackbacks/130110.aspx</trackback:ping>
        </item>
        <item>
            <title>Oslo based solution for deploying BizTalk applications &amp;ndash; the grammar</title>
            <category>M</category>
            <category>BizTalk</category>
            <category>Oslo</category>
            <link>http://geekswithblogs.net/Connected/archive/2009/03/14/oslo-based-solution-for-deploying-biztalk-applications-ndash-the-grammar.aspx</link>
            <description>&lt;p&gt;A couple of weeks ago I published a &lt;a href="http://sabratech.co.uk/blogs/yossidahan/2009/03/oslo-based-solution-for-deploying.html" target="_blank"&gt;post&lt;/a&gt; describing my Oslo based deployment framework for BizTalk.&lt;/p&gt;  &lt;p&gt;Two parts were missing from that post – the actual MGrammar and the runtime that processes the source code files. &lt;/p&gt;  &lt;p&gt;In this post I will go over the grammar I created for the framework; I will try to go over the complete grammar explaining the various steps, this is not intended to be a complete description of MGrammar (not that there’s a chance I could write one), but rather an overview by example; for more information on Oslo and ‘M’ visit the &lt;a href="http://msdn.microsoft.com/en-us/oslo/default.aspx" target="_blank"&gt;Oslo Dev Centre on MSDN&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;It was important for me to create a solution that is completely usable, and indeed I have started to use this to generate the build scripts for my application, the price of which is that it might not be the best example code out there, but I hope you will find this useful.&lt;/p&gt;  &lt;p&gt;Below is the complete grammar, after which I walk though it step by step; it might be useful to have anther look at the example source code I included in my previous post to better understand what I’m trying to achieve with the syntax -&lt;/p&gt;  &lt;div class="csharpcode"&gt;   &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;    module Sabra.BizTalk.Deployment&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt;    {&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   3:  &lt;/span&gt; &lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   4:  &lt;/span&gt;        language BTSDeploy&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   5:  &lt;/span&gt;        {&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   6:  &lt;/span&gt;            //main syntax is the entry point for the grammar - the first syntax to be parsed&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   7:  &lt;/span&gt;            syntax Main = app:AppDef &lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   8:  &lt;/span&gt;                               "{" &lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   9:  &lt;/span&gt;                               items:ApplicationItems &lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  10:  &lt;/span&gt;                               "}" =&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; Application[app,valuesof(items)];&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  11:  &lt;/span&gt;            &lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  12:  &lt;/span&gt;            //application definition at root of source code&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  13:  &lt;/span&gt;            syntax AppDef = applicationKW name:ApplicationName =&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; name;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  14:  &lt;/span&gt; &lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  15:  &lt;/span&gt;            //application items supports including all possible items multiple times in any order&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  16:  &lt;/span&gt;            syntax ApplicationItems = items:(Add | Build | ImportBinding | Comment)* =&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; {valuesof(items)};&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  17:  &lt;/span&gt; &lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  18:  &lt;/span&gt;            //now define the syntax for each item type - &lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  19:  &lt;/span&gt;            &lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  20:  &lt;/span&gt;            //'Build' deinfes a solution or project to build during execution&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  21:  &lt;/span&gt;            //(due to limitations in our msbuild framework, runtime currently supports solutions only, but language should support both)&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  22:  &lt;/span&gt;            syntax Build = "build" path:Path";" =&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; Build[path];&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  23:  &lt;/span&gt;            //binding to import into application&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  24:  &lt;/span&gt;            syntax ImportBinding = importKW bindingKW path:Path";" =&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; ImportBinding{Path = path};&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  25:  &lt;/span&gt; &lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  26:  &lt;/span&gt;            //syntax of add further specified different add 'options'&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  27:  &lt;/span&gt;            syntax Add = addKW add:(Add_Reference | Add_Binding | Add_Assembly | Add_BTS_Assembly) =&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; Add{valuesof(add)};&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  28:  &lt;/span&gt;            //each add option is defined next&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  29:  &lt;/span&gt;                        &lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  30:  &lt;/span&gt;            //binding to add as resource to application. must specify environment name&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  31:  &lt;/span&gt;            syntax Add_Binding = bindingKW path:Path env:MultiWordName";" =&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; Binding[path,env];&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  32:  &lt;/span&gt;            //defined a reference to another application, supports providing multiple applications in the same instruction&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  33:  &lt;/span&gt;            syntax Add_Reference = referenceKW ref1:ApplicationName refs:Add_AdditionalReferences*";" =&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; Reference{ref1,valuesof(refs)};&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  34:  &lt;/span&gt;            syntax Add_AdditionalReferences = "," app:ApplicationName =&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; app;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  35:  &lt;/span&gt;            //add assembly defines an assembly to be added as a resource to the application&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  36:  &lt;/span&gt;            syntax Add_Assembly = assemblyKW path:Path details:AssemblyDetails";" =&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; Resource[path,Details{details}];&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  37:  &lt;/span&gt;            //add biztalk assembly is similar to assembly, but allows specifiying any contained orchestrations&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  38:  &lt;/span&gt;            syntax Add_BTS_Assembly = "biztalk" assemblyKW path:Path orch:Orchestrations? details:AssemblyDetails";" =&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; BizTalkAssembly[path,orch,Details{details}];&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  39:  &lt;/span&gt;            syntax Orchestrations  = withKW orchestrationsKW "{" type1:ApplicationName types:AdditionalOrchestrations* "}" =&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; Orchestrations{type1,valuesof(types)};&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  40:  &lt;/span&gt;            syntax AdditionalOrchestrations = "," type:ApplicationName =&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; type;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  41:  &lt;/span&gt;            &lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  42:  &lt;/span&gt;            //assembly details&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  43:  &lt;/span&gt;            syntax AssemblyDetails = ver:AssemblyVersion+ culture:Culture+ pkt:PublicKeyToken+=&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;{Version{valuesof(ver)},Culture{valuesof(culture)},PublicKeyToken{valuesof(pkt)}};&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  44:  &lt;/span&gt;            token AssemblyVersion = versionKW "=" version:(AnyDigit*"."AnyDigit*"."AnyDigit*"."AnyDigit*)=&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;version;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  45:  &lt;/span&gt;            token Culture = cultureKW "=" culture:Word=&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;culture; &lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  46:  &lt;/span&gt;            //TODO: token should be 16 chars exactly&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  47:  &lt;/span&gt;            token PublicKeyToken = publicKeyTokenKW "="pkt:(AnyChar|AnyDigit)*=&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;pkt;   &lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  48:  &lt;/span&gt;            &lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  49:  &lt;/span&gt;            //keywords&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  50:  &lt;/span&gt;            @{Classification["Keyword"]}&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  51:  &lt;/span&gt;            token applicationKW = "Application";&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  52:  &lt;/span&gt;            @{Classification["Keyword"]}&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  53:  &lt;/span&gt;            token addKW = "add";&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  54:  &lt;/span&gt;            @{Classification["Keyword"]}&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  55:  &lt;/span&gt;            token bindingKW = "binding";&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  56:  &lt;/span&gt;            @{Classification["Keyword"]}&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  57:  &lt;/span&gt;            token referenceKW = "reference";&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  58:  &lt;/span&gt;            @{Classification["Keyword"]}&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  59:  &lt;/span&gt;            token importKW = "import";&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  60:  &lt;/span&gt;            @{Classification["Keyword"]}&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  61:  &lt;/span&gt;            token buildKW  = "build";&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  62:  &lt;/span&gt;            @{Classification["Keyword"]}&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  63:  &lt;/span&gt;            token assemblyKW = "assembly";&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  64:  &lt;/span&gt;            @{Classification["Keyword"]}&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  65:  &lt;/span&gt;            token biztalkKW = "biztalk";&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  66:  &lt;/span&gt;            @{Classification["Keyword"]}&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  67:  &lt;/span&gt;            token withKW = "with";&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  68:  &lt;/span&gt;            @{Classification["Keyword"]}&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  69:  &lt;/span&gt;            token orchestrationsKW = "orchestrations";&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  70:  &lt;/span&gt;            @{Classification["Keyword"]}&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  71:  &lt;/span&gt;            token versionKW = "version";        &lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  72:  &lt;/span&gt;            @{Classification["Keyword"]}&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  73:  &lt;/span&gt;            token cultureKW = "culture";        &lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  74:  &lt;/span&gt;            @{Classification["Keyword"]}&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  75:  &lt;/span&gt;            token publicKeyTokenKW = "publicKeyToken";        &lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  76:  &lt;/span&gt;            &lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  77:  &lt;/span&gt;            //definition of a comment, similar to c# syntax&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  78:  &lt;/span&gt;            @{Classification["Comment"]}&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  79:  &lt;/span&gt;            token Comment = "//" CommentLineContent*;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  80:  &lt;/span&gt;            token CommentLineContent&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  81:  &lt;/span&gt;                = ^(&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  82:  &lt;/span&gt;                     '\u000A' // New Line&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  83:  &lt;/span&gt;                  |  '\u000D' // Carriage Return&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  84:  &lt;/span&gt;                  |  '\u0085' // Next Line&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  85:  &lt;/span&gt;                  |  '\u2028' // Line Separator&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  86:  &lt;/span&gt;                  |  '\u2029' // Paragraph Separator&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  87:  &lt;/span&gt;                );&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  88:  &lt;/span&gt;                &lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  89:  &lt;/span&gt;            //application name must start with a character and then include any character, digit or '.'&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  90:  &lt;/span&gt;            token ApplicationName = AnyChar+(AnyChar | AnyDigit | ".")*;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  91:  &lt;/span&gt;            &lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  92:  &lt;/span&gt;            //tokens use for definition of a file path&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  93:  &lt;/span&gt;            token Path = "\""PathRoot?FileSystemName("\\"FileSystemName)*"\"";&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  94:  &lt;/span&gt;            token PathRoot = AnyChar":\\";&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  95:  &lt;/span&gt;            token FileSystemName = (AnyChar | AnyDigit | Space | "-" | "_" | ".")+;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  96:  &lt;/span&gt; &lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  97:  &lt;/span&gt;            //common token definitions&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  98:  &lt;/span&gt;            token AnyChar = "A".."Z" | "a".."z";&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  99:  &lt;/span&gt;            token AnyDigit = "0".."9";&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt; 100:  &lt;/span&gt;            token MultiWordName  = "\""a:(Word | Space)"\"" =&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; a;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 101:  &lt;/span&gt;            token Word = (AnyChar | AnyDigit | "-" | "_")+;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt; 102:  &lt;/span&gt; &lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 103:  &lt;/span&gt;            //the interleave will ensure the language allows whitespace anywhere&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt; 104:  &lt;/span&gt;            interleave Whitespace = Tab | LF | CR | Space | Comment;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 105:  &lt;/span&gt;            token LF = "\u000A";&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt; 106:  &lt;/span&gt;            token CR = "\u000D";&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 107:  &lt;/span&gt;            token Space = "\u0020";&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt; 108:  &lt;/span&gt;            token Tab = "\u0009";&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 109:  &lt;/span&gt; &lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt; 110:  &lt;/span&gt;           }&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 111:  &lt;/span&gt;    }&lt;/pre&gt;
&lt;/div&gt;
&lt;style type="text/css"&gt;&lt;![CDATA[















.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }]]&gt;&lt;/style&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;I’ve build the grammar top down and this is how I will walk through it - &lt;/p&gt;

&lt;p&gt;First (1) I define my module, in a namespace like manner; this is the logical container for my language; I then(4) declare my language and give it a name.&lt;/p&gt;

&lt;p&gt;The main constructs in mgrammar are &lt;em&gt;syntax &lt;/em&gt;and &lt;em&gt;token; &lt;/em&gt;I often heard the guys at Redmond explain that when it comes to languages you can think of syntax as being the sentence and tokens as being the words; I think this is a very clear explanations; there are a few rules relating to them as you can imagine, important ones to remember at this point are that syntaxes can contain other syntaxes as well as tokens (and literals), tokens can only contain other tokens (and literals); also – interleave does not apply to tokens .&lt;/p&gt;

&lt;p&gt;The main syntax, and the entry point for any language is Main and you can see mine defined on line 7, and it looks like this - &lt;/p&gt;

&lt;div class="csharpcode"&gt;
  &lt;pre class="alt"&gt;//main syntax is the entry point for the grammar - the first syntax to be parsed&lt;/pre&gt;

  &lt;pre&gt;            syntax Main = app:AppDef &lt;/pre&gt;

  &lt;pre class="alt"&gt;                               "{" &lt;/pre&gt;

  &lt;pre&gt;                               items:ApplicationItems &lt;/pre&gt;

  &lt;pre class="alt"&gt;                               "}" =&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; Application[app,valuesof(items)];&lt;/pre&gt;
&lt;/div&gt;
&lt;style type="text/css"&gt;&lt;![CDATA[















.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }]]&gt;&lt;/style&gt;

&lt;p&gt;‘//’ is used for comments, just like in c#, so the first line will be ignored.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;syntax&lt;/em&gt; is one of the few keywords that exist in mgrammar, no explanation needed;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Main&lt;/em&gt; is the name of the syntax, which allows is to be referred to (used) by other syntaxes; in this case, as I’ve mentioned, ‘Main’ is also the entry point –the syntax the parser will start at; everything else should flow from here.&lt;/p&gt;

&lt;p&gt;Now for - &lt;em&gt;app:AppDef&lt;/em&gt;, but first – a note - in my mind there are two aspects to creating a language in mgrammar – there is the ‘parsing aspect’ – you define your language so that it describes the rules to parse your source code; and there is the ‘output aspect’ (or ‘production aspect’) – this is where you define the output of your language – in ‘M’ this is mgraph – so that it descries accurately the intent of any source code (and is easy-ish to work with at runtime)&lt;/p&gt;

&lt;p&gt;Two are inevitably very mixed in any real-world work with ‘M’ which can be confusing, and today I want to focus on the parsing aspect – firstly because it is the more important one in my view (there’s nothing to work with before you’ve declared a good syntax for your language), and secondly – because I suspect we’re going to see some changes to the production aspect in the near future.&lt;/p&gt;

&lt;p&gt;Mainly production aspect ‘stuff’ is defined after the ‘=&amp;gt;’ operator as you can see in my syntax above, so for the time being just try to ignore that; there will be a bit more to ignore as you will see shortly.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;AppDef&lt;/em&gt; is a name of a syntax declared somewhere else in the language ( line 13); it could also be defined in any imported languages, but I don’t have any, we will look at that in a second; &lt;em&gt;app:&lt;/em&gt; is an alias assigned to this syntax which allows for it to be referenced in the production on the right side of the arrow operator; again – for the time being feel free to ignore any aliases, they have no impact on the parsing aspect.&lt;/p&gt;

&lt;p&gt;So – my syntax main basically says we’re expecting to have in our source code something that matches the &lt;em&gt;AppDef&lt;/em&gt; syntax, then an opening curly bracket then something that matches the &lt;em&gt;ApplicationItems&lt;/em&gt; syntax and then closing curly bracket. simple.&lt;/p&gt;

&lt;p&gt;Of course next the parser would look at the definition of &lt;em&gt;AppDef&lt;/em&gt; and &lt;em&gt;ApplicationItems&lt;/em&gt;, and so will we.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;AppDef &lt;/em&gt;is defined in line 13 as an &lt;em&gt;ApplicationKW &lt;/em&gt;followed by &lt;em&gt;ApplicationName&lt;/em&gt;; these are defined in lines 51 and 90 respectively; lets look at the &lt;em&gt;ApplicationKW &lt;/em&gt;definition- &lt;/p&gt;

&lt;div class="csharpcode"&gt;
  &lt;pre class="alt"&gt;            @{Classification["Keyword"]}&lt;/pre&gt;

  &lt;pre&gt;            token applicationKW = "Application";&lt;/pre&gt;
&lt;/div&gt;
&lt;style type="text/css"&gt;&lt;![CDATA[












.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }]]&gt;&lt;/style&gt;

&lt;p&gt;&lt;em&gt;ApplicationKW&lt;/em&gt; itself is a token with a fixed literal 'Application’ – this is a very simple rule to follow, and in fact I could have simply included this literal in the syntax definition and not use this token at all (which is what I have done previously).&lt;/p&gt;

&lt;p&gt;The reason I have separated it out to its own token is related to the preceding line in the grammar - the classification attribute allows me to mark this token as a “keyword” for my language, this would tell intellipad (and, presumably, any other editor that would learn how to work with mgrammar), that this token is a keyword and should be displayed as such; in intellipad this means it would be bolded in the editor, as you can see in the image below of my language open in intellipad - &lt;/p&gt;

&lt;p&gt;&lt;a href="http://geekswithblogs.net/images/geekswithblogs_net/Connected/WindowsLiveWriter/4f3a5a20d920_7A35/image_2.png" rel="lightbox"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://geekswithblogs.net/images/geekswithblogs_net/Connected/WindowsLiveWriter/4f3a5a20d920_7A35/image_thumb.png" width="627" height="388" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Back to the main syntax’ components - &lt;em&gt;ApplicationName, &lt;/em&gt;defined in line 51 states that an application name is composed of &lt;em&gt;AnyChar&lt;/em&gt;  followed by any number of &lt;em&gt;AnyChar&lt;/em&gt;, &lt;em&gt;AnyDigit&lt;/em&gt; or the literal ‘.’ with &lt;em&gt;AnyChar&lt;/em&gt; and &lt;em&gt;AnyDigit&lt;/em&gt; defined in lines 98 and 99.&lt;/p&gt;

&lt;p&gt;The ‘+’ sign indicates the syntax or token it follows must exist at least once; the ‘*’ sign indicates the syntax or token it follows can exist 0 or more times.&lt;/p&gt;

&lt;p&gt;So – we have the definition of our application name, now lets look at what &lt;em&gt;ApplicationItems&lt;/em&gt; says - &lt;/p&gt;

&lt;pre class="csharpcode"&gt;syntax ApplicationItems = items:(Add | Build | ImportBinding | Comment)* =&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; {valuesof(items)};&lt;/pre&gt;
&lt;style type="text/css"&gt;&lt;![CDATA[











.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }]]&gt;&lt;/style&gt;

&lt;p&gt;This syntaxt tells the parser that an application can have any number of &lt;em&gt;Add, Build, ImportBinding or Comment &lt;/em&gt;&lt;strong&gt;in any order.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Moving on we’ll look briefly at how ImportBinding looks like - &lt;/p&gt;

&lt;pre class="csharpcode"&gt;syntax ImportBinding = importKW bindingKW path:Path";" =&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; ImportBinding{Path = path};&lt;/pre&gt;
&lt;style type="text/css"&gt;&lt;![CDATA[











.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }]]&gt;&lt;/style&gt;

&lt;p&gt;The importKW (which is the literal  ‘import’, look it up!) followed by the bindingKW (‘binding’) and the syntax for &lt;em&gt;Path.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;I could have combined both literals import and binding to a single token and mark that as a keyword, but there are two benefits to splitting them up- firstly, by having two tokens I can have as many whitespaces as I want between them, which I think is what developers generally expect, and, secondly – the 'binding’ keyword is re-used for the add binding syntax I’ll describe shortly.&lt;/p&gt;

&lt;p&gt;I’ll skip the Path definition, you can follow it yourself if you wish to; so next we can look at another item in the application items list – &lt;em&gt;Add:&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;syntax Add = addKW add:(Add_Reference | Add_Binding | Add_Assembly | Add_BTS_Assembly) =&amp;gt; Add{valuesof(add)};&lt;/p&gt;

&lt;p&gt;The &lt;em&gt;Add&lt;/em&gt; syntax starts with the addKW (‘add’) followed by one of the syntaxes for adding a reference, adding a binding, adding an assembly or adding a BizTalk assembly, but it only allows one; the add keyword (and therefore the entire add syntax) must be repeated as a whole to add multiple items to the application, as is suggested by the &lt;em&gt;ApplicationItems &lt;/em&gt;syntax.&lt;/p&gt;

&lt;p&gt;Lets look at a couple of these items; first – the syntax for add binding - &lt;/p&gt;

&lt;p&gt;syntax Add_Binding = bindingKW path:Path env:MultiWordName";" =&amp;gt; Binding[path,env]; &lt;/p&gt;

&lt;p&gt;Here you can see the binding keyword being reused, as does the Path syntax; I’m then allowing a multi-word-name (which is essentially a string contained in double quotes) as the environment name for the added binding.&lt;/p&gt;

&lt;p&gt;Quite simple, right? that’s the thing I love about mgrammar. let’s look at one more syntax - &lt;/p&gt;

&lt;p&gt;syntax Add_BTS_Assembly = "biztalk" assemblyKW path:Path orch:Orchestrations? details:AssemblyDetails";" =&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; BizTalkAssembly[path,orch,Details{details}]; 

  &lt;br /&gt;syntax Orchestrations  = withKW orchestrationsKW "{" type1:ApplicationName types:AdditionalOrchestrations* "}" =&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; Orchestrations{type1,valuesof(types)}; 

  &lt;br /&gt;syntax AdditionalOrchestrations = "," type:ApplicationName =&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; type;&lt;/p&gt;
&lt;style type="text/css"&gt;&lt;![CDATA[











.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }]]&gt;&lt;/style&gt;

&lt;p&gt;The &lt;em&gt;Add_BTS_Assembly syntax&lt;/em&gt; should be very clear, the only thing I haven’t mentioned so far is the ? sign which indicates 1 or 0 appearances of the syntax/token it follows, I use this to allow a BizTalk assembly to &lt;strong&gt;optionally&lt;/strong&gt; describe the orchestrations it contains so that, potentially, any instances of these could be terminated when undeploying the application.&lt;/p&gt;

&lt;p&gt;The &lt;em&gt;Orchestrations &lt;/em&gt;syntax, if exists, requires at least one orchestration to be specified (I’m reusing the &lt;em&gt;ApplicationName &lt;/em&gt;token as the orchestration name) but allows additional orchestratiosn to be specified as well; I’ve used the same approach for the add reference syntax.&lt;/p&gt;

&lt;p&gt;I hope this makes sense, and that it gives you a glimpse into a practical use of mgrammar, I am certainly excited about this stuff.&lt;/p&gt;

&lt;p&gt;Soon I hope to post about the last missing piece of the puzzle – the runtime that uses the language definition to parse, and then execute, any source code provided; after that the whole thing is likely to find a spot on CodePlex, bare with me a little bit longer….&lt;/p&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=130085"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=130085" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/Connected/aggbug/130085.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Yossi Dahan</dc:creator>
            <guid>http://geekswithblogs.net/Connected/archive/2009/03/14/oslo-based-solution-for-deploying-biztalk-applications-ndash-the-grammar.aspx</guid>
            <pubDate>Sat, 14 Mar 2009 15:47:16 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/Connected/comments/130085.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/Connected/archive/2009/03/14/oslo-based-solution-for-deploying-biztalk-applications-ndash-the-grammar.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/Connected/comments/commentRss/130085.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/Connected/services/trackbacks/130085.aspx</trackback:ping>
        </item>
        <item>
            <title>MSBuild support in BizTalk 2009</title>
            <category>BizTalk</category>
            <link>http://geekswithblogs.net/Connected/archive/2009/03/08/msbuild-support-in-biztalk-2009.aspx</link>
            <description>&lt;p&gt;In my &lt;a href="http://www.sabratech.co.uk/blogs/yossidahan/2008/12/notes-on-biztalk-2009.html" target="_blank"&gt;notes on BizTalk 2009&lt;/a&gt; post I have highlighted the fact that now, as part of the BizTalk installation, you can select the “Project Build Components” which allow you to build BizTalk projects without Visual Studio or BizTalk installed on the build machine.&lt;/p&gt;  &lt;p&gt;This is very cool feature of the product, but I have to admit that I have missed something quite important; luckily - &lt;a href="http://blogical.se/blogs/mikael/default.aspx" target="_blank"&gt;Mikael Hakansson&lt;/a&gt; hadn’t – the provided tasks do not support deployment of BizTalk projects, but only build (see Mikael’s article &lt;a href="http://blogical.se/blogs/mikael/archive/2009/02/11/biztalk-2009-build-amp-deploy-automation-with-team-foundation-server-2008-part-1.aspx" target="_blank"&gt;here&lt;/a&gt;).&lt;/p&gt;  &lt;p&gt;What this means is that, while you can use the tasks deployed through the installation to verify that your BizTalk projects build correctly (as part of continuous integration setup, for example), you have no way of verifying that they can be deployed or, more importantly, run any automated tests;&lt;/p&gt;  &lt;p&gt;The &lt;a href="http://sdctasks.codeplex.com/" target="_blank"&gt;SDC tasks&lt;/a&gt;, with their support for BizTalk deployment, can come in very handy here, and you can certainly use them to augment the built in build support with deployment capabilities, but they add more dependencies to the plate, which has to be planned for.&lt;/p&gt;  &lt;p&gt;Of course, attending the MVP summit in Redmond last week we had a great chance of raising this (and various other) subjects with the product group, and we certainly have not let that opportunity go missed, now we just need to wait and see if they “pick up the glove”.&lt;/p&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=129920"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=129920" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/Connected/aggbug/129920.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Yossi Dahan</dc:creator>
            <guid>http://geekswithblogs.net/Connected/archive/2009/03/08/msbuild-support-in-biztalk-2009.aspx</guid>
            <pubDate>Sun, 08 Mar 2009 21:49:31 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/Connected/comments/129920.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/Connected/archive/2009/03/08/msbuild-support-in-biztalk-2009.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/Connected/comments/commentRss/129920.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/Connected/services/trackbacks/129920.aspx</trackback:ping>
        </item>
        <item>
            <title>Oslo based solution for deploying BizTalk applications</title>
            <category>M</category>
            <category>Oslo</category>
            <category>BizTalk</category>
            <link>http://geekswithblogs.net/Connected/archive/2009/03/04/oslo-based-solution-for-deploying-biztalk-applications.aspx</link>
            <description>&lt;p&gt;Since PDC I’ve been working on and off on an “Oslo” based solution for deploying a BizTalk application; unfortunately I couldn’t get a good chunk of time to play with this, so it’s been dragging a bit, but I’m getting close, so here are some details - &lt;/p&gt;  &lt;p&gt;I’m a big advocate of automated builds; it’s a topic that probably deserves a post of its own, so I won’t get started on this here, but the idea is that one must have a way to be confident that, when its time to [re-]deploy the app, it will get deployed successfully time after time, without a hitch; &lt;/p&gt;  &lt;p&gt;From my experience, deploying a BizTalk application of a decent size is often not trivial, and often it does not go smoothly if done manually (things are being missed, done out of order, wrong versions being picked up, etc), which does not help to boost the confidence in the solution (or BizTalk as a whole) in the organisation; automating the process can save a lot of time (can be done unattended, while in a meeting, out for lunch or overnight), save a lot of head scratching, boost the confidence in the solution and set the ground for proper automated builds, auto testing etc.&lt;/p&gt;  &lt;p&gt;To that extent, I have previously built an MSBuild based framework for deploying BizTalk applications. &lt;/p&gt;  &lt;p&gt;While I’m sure it does not suit all purposes as it was developed to support those scenarios I had, I think it’s quite comprehensive and had served me well over the past couple of years.&lt;/p&gt;  &lt;p&gt;It allows one to provide an MSBuild-formatted file with some parameters and lists and, using the pre-created framework, would do things like remove the existing application (after terminating current instances and un-enlisting services), build the new solution(s), deploy assemblies to BizTalk, add/import binding files, start ports etc.&lt;/p&gt;  &lt;p&gt;This is working great for us, and we’ve been using it extensively for quite a while now, but there’s one major downside – it requires one to maintain those MSBuild scripts. &lt;/p&gt;  &lt;p&gt;Now -  MSBuild is cool, I do like it very much, but as it’s generic – it does not speak in BizTalk terms, and as it’s XML – it’s quite verbose, and I wanted an easier format for all of us to work with.&lt;/p&gt;  &lt;p&gt;So – inspired after seeing Oslo and even more driven after visiting PDC - I’ve decided to come up with an MGrammar based language for describing a BizTalk application to be deployed.&lt;/p&gt;  &lt;p&gt;So far I’ve come up with “version 1.0” of my grammar that allows to describe the major artifacts in a BizTalk application and a basic runtime to process source files written in this language, the language allows you to describe things like -&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;References to other applications &lt;/li&gt;    &lt;li&gt;Solutions and projects to build &lt;/li&gt;    &lt;li&gt;BizTalk assemblies to deploy &lt;/li&gt;    &lt;li&gt;Orchestrations contained in those (these can then be terminated before attempting to remove the application prior to deployment) &lt;/li&gt;    &lt;li&gt;.net assemblies to deploy &lt;/li&gt;    &lt;li&gt;Binding file to import &lt;/li&gt;    &lt;li&gt;Binding files to add (and the name of the environment to attach to those) &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;As Oslo hasn’t RTM-ed yet, I can’t quite rely on it yet, and so I cannot use it in production in any shape or form, or can I?    &lt;br /&gt;I found a good middle ground for us which allows us to gain from the benefits I’m hoping to get by using my language, while not exposing ourselves too much to the risks of using early technology – &lt;/p&gt;  &lt;p&gt;At the moment the runtime I’ve built for this is used to generate the MSBuild scripts we’re already using out of the source files; in this way - if Oslo disappears tomorrow, or significantly changes (not that I think that’s going to be the case), we’re safe – we still have the MSBuild scripts as “checked-in artifacts” and so we have lost nothing.&lt;/p&gt;  &lt;p&gt;So – how does an instance of my language looks like? here’s an example: &lt;/p&gt;  &lt;pre class="csharpcode"&gt;Application MyApp
{
    &lt;span class="rem"&gt;//add references to other applications&lt;/span&gt;
    add reference SomeOtherApp;
    add reference AndAnother,andAThird;
    
    &lt;span class="rem"&gt;//build the solution&lt;/span&gt;
    build &lt;span class="str"&gt;"SomeFolder\SomeOtherFolder\SomeSolution.sln"&lt;/span&gt;;
    build &lt;span class="str"&gt;"SomeFolder\SomeOtherFolder\SomeProject.btproj"&lt;/span&gt;;
    
    &lt;span class="rem"&gt;//add required biztalk assemblies&lt;/span&gt;
    add biztalk assembly &lt;span class="str"&gt;"SomeFolder\SomeOtherFolder\bin\deployment\Schemas.dll"&lt;/span&gt;
        version=1.0.0.0 
        culture=neutral 
        publicKeyToken=314bd7037656ea65;

    add biztalk assembly &lt;span class="str"&gt;"SomeFolder\SomeOtherFolder\bin\deployment\Maps.dll"&lt;/span&gt;
        version=1.0.0.0 
        culture=neutral 
        publicKeyToken=314bd7037656ea65;

    add biztalk assembly &lt;span class="str"&gt;"SomeFolder\SomeOtherFolder\bin\deployment\Orchestrations.dll"&lt;/span&gt; 
    with orchestrations
        {
            MyApp.SomeOrchestration,
            MyApp.AnottherOrchestration,
            MyApp.AndAnotherOrchestration
        }        
        version=1.0.0.0 
        culture=neutral 
        publicKeyToken=314bd7037656ea65;
    
    &lt;span class="rem"&gt;//and .net helpers assembly&lt;/span&gt;
    add assembly &lt;span class="str"&gt;"SomeFolder\SomeOtherFolder\bin\release\HRG.FareWatch.Hotel.Helpers.dll"&lt;/span&gt; 
        version=1.0.0.0 
        culture=neutral 
        publicKeyToken=314bd7037656ea65;
    &lt;span class="rem"&gt;//import dev bindings&lt;/span&gt;
    import binding &lt;span class="str"&gt;"SomeFolder\SomeOtherFolder\Bindings.xml"&lt;/span&gt;;

    &lt;span class="rem"&gt;//add various environment's bindings.&lt;/span&gt;
    add binding &lt;span class="str"&gt;"SomeFolder\SomeOtherFolder\Bindings.Dev.xml"&lt;/span&gt; &lt;span class="str"&gt;"development"&lt;/span&gt;;
    add binding &lt;span class="str"&gt;"SomeFolder\SomeOtherFolder\Bindings.Stage.xml"&lt;/span&gt; &lt;span class="str"&gt;"stage"&lt;/span&gt;;
    add binding &lt;span class="str"&gt;"SomeFolder\SomeOtherFolder\Bindings.Prod.xml"&lt;/span&gt; &lt;span class="str"&gt;"production"&lt;/span&gt;;
}&lt;/pre&gt;

&lt;p&gt;as I’ve said – I already have a runtime that generates the MSBuild scripts required to deploy these - the runtime outputs several files to the temp folder - &lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;The “framework” MSBuild script that contains all the targets I’m using &lt;/li&gt;

  &lt;li&gt;The Microsoft.Sdc.Tasks.BizTalk.dll and the Microsoft.Sdc.Tasks.dll which contains many useful custom tasks. &lt;/li&gt;

  &lt;li&gt;The relevant import file for the SDC tasks &lt;/li&gt;

  &lt;li&gt;The generated MSBuild file that contains all the various artifacts based on the source code &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;That latter file, which is the equivalent of my source code, and what we had to maintain so far, looks like - &lt;/p&gt;

&lt;pre class="csharpcode"&gt;&amp;lt;?xml version=&lt;span class="str"&gt;"1.0"&lt;/span&gt; encoding=&lt;span class="str"&gt;"utf-8"&lt;/span&gt;?&amp;gt;
&amp;lt;Project xmlns=&lt;span class="str"&gt;"http://schemas.microsoft.com/developer/msbuild/2003"&lt;/span&gt; DefaultTargets=&lt;span class="str"&gt;"DeployAll"&lt;/span&gt;&amp;gt;
  &amp;lt;Import Project=&lt;span class="str"&gt;"Deploy.Framework"&lt;/span&gt; /&amp;gt;
  &amp;lt;ItemGroup&amp;gt;
    &amp;lt;MyApp Include=&lt;span class="str"&gt;"SomeOtherApp"&lt;/span&gt; /&amp;gt;
    &amp;lt;MyApp Include=&lt;span class="str"&gt;"AndAnother"&lt;/span&gt; /&amp;gt;
    &amp;lt;MyApp Include=&lt;span class="str"&gt;"andAThird"&lt;/span&gt; /&amp;gt;
  &amp;lt;/ItemGroup&amp;gt;
  &amp;lt;ItemGroup&amp;gt;
    &amp;lt;Bindings Include=&lt;span class="str"&gt;"General"&lt;/span&gt;&amp;gt;
      &amp;lt;path&amp;gt;SomeFolder\SomeOtherFolder\Bindings.xml&amp;lt;/path&amp;gt;
    &amp;lt;/Bindings&amp;gt;
  &amp;lt;/ItemGroup&amp;gt;
  &amp;lt;ItemGroup&amp;gt;
    &amp;lt;EnvironmentBindings Include=&lt;span class="str"&gt;"General"&lt;/span&gt;&amp;gt;
      &amp;lt;path&amp;gt;&lt;span class="str"&gt;"SomeFolder\SomeOtherFolder\Bindings.Dev.xml"&lt;/span&gt;&amp;lt;/path&amp;gt;
      &amp;lt;environment&amp;gt;development&amp;lt;/environment&amp;gt;
    &amp;lt;/EnvironmentBindings&amp;gt;
    &amp;lt;EnvironmentBindings Include=&lt;span class="str"&gt;"General"&lt;/span&gt;&amp;gt;
      &amp;lt;path&amp;gt;&lt;span class="str"&gt;"SomeFolder\SomeOtherFolder\Bindings.Stage.xml"&lt;/span&gt;&amp;lt;/path&amp;gt;
      &amp;lt;environment&amp;gt;stage&amp;lt;/environment&amp;gt;
    &amp;lt;/EnvironmentBindings&amp;gt;
    &amp;lt;EnvironmentBindings Include=&lt;span class="str"&gt;"General"&lt;/span&gt;&amp;gt;
      &amp;lt;path&amp;gt;&lt;span class="str"&gt;"SomeFolder\SomeOtherFolder\Bindings.Prod.xml"&lt;/span&gt;&amp;lt;/path&amp;gt;
      &amp;lt;environment&amp;gt;production&amp;lt;/environment&amp;gt;
    &amp;lt;/EnvironmentBindings&amp;gt;
  &amp;lt;/ItemGroup&amp;gt;
  &amp;lt;ItemGroup&amp;gt;
    &amp;lt;ExternNetAssembly Include=&lt;span class="str"&gt;"HRG.FareWatch.Hotel.Helpers"&lt;/span&gt;&amp;gt;
      &amp;lt;Version&amp;gt;1.0.0.0&amp;lt;/Version&amp;gt;
      &amp;lt;Culture&amp;gt;neutral&amp;lt;/Culture&amp;gt;
      &amp;lt;PublicKeyToken&amp;gt;314bd7037656ea65&amp;lt;/PublicKeyToken&amp;gt;
      &amp;lt;ProcessorArchitecture&amp;gt;MSIL&amp;lt;/ProcessorArchitecture&amp;gt;
      &amp;lt;path&amp;gt;SomeFolder\SomeOtherFolder\bin\release&amp;lt;/path&amp;gt;
    &amp;lt;/ExternNetAssembly&amp;gt;
  &amp;lt;/ItemGroup&amp;gt;
  &amp;lt;ItemGroup&amp;gt;
    &amp;lt;Solution Include=&lt;span class="str"&gt;"SomeSolution"&lt;/span&gt;&amp;gt;
      &amp;lt;path&amp;gt;SomeFolder\SomeOtherFolder&amp;lt;/path&amp;gt;
    &amp;lt;/Solution&amp;gt;
    &amp;lt;Solution Include=&lt;span class="str"&gt;"SomeProject"&lt;/span&gt;&amp;gt;
      &amp;lt;path&amp;gt;SomeFolder\SomeOtherFolder&amp;lt;/path&amp;gt;
    &amp;lt;/Solution&amp;gt;
  &amp;lt;/ItemGroup&amp;gt;
  &amp;lt;ItemGroup&amp;gt;
    &amp;lt;BTSProject Include=&lt;span class="str"&gt;"Schemas"&lt;/span&gt;&amp;gt;
      &amp;lt;Version&amp;gt;1.0.0.0&amp;lt;/Version&amp;gt;
      &amp;lt;Culture&amp;gt;neutral&amp;lt;/Culture&amp;gt;
      &amp;lt;PublicKeyToken&amp;gt;314bd7037656ea65&amp;lt;/PublicKeyToken&amp;gt;
      &amp;lt;ProcessorArchitecture&amp;gt;MSIL&amp;lt;/ProcessorArchitecture&amp;gt;
      &amp;lt;path&amp;gt;SomeFolder\SomeOtherFolder\bin\deployment&amp;lt;/path&amp;gt;
    &amp;lt;/BTSProject&amp;gt;
    &amp;lt;BTSProject Include=&lt;span class="str"&gt;"Maps"&lt;/span&gt;&amp;gt;
      &amp;lt;Version&amp;gt;1.0.0.0&amp;lt;/Version&amp;gt;
      &amp;lt;Culture&amp;gt;neutral&amp;lt;/Culture&amp;gt;
      &amp;lt;PublicKeyToken&amp;gt;314bd7037656ea65&amp;lt;/PublicKeyToken&amp;gt;
      &amp;lt;ProcessorArchitecture&amp;gt;MSIL&amp;lt;/ProcessorArchitecture&amp;gt;
      &amp;lt;path&amp;gt;SomeFolder\SomeOtherFolder\bin\deployment&amp;lt;/path&amp;gt;
    &amp;lt;/BTSProject&amp;gt;
    &amp;lt;BTSProject Include=&lt;span class="str"&gt;"Orchestrations"&lt;/span&gt;&amp;gt;
      &amp;lt;Version&amp;gt;1.0.0.0&amp;lt;/Version&amp;gt;
      &amp;lt;Culture&amp;gt;neutral&amp;lt;/Culture&amp;gt;
      &amp;lt;PublicKeyToken&amp;gt;314bd7037656ea65&amp;lt;/PublicKeyToken&amp;gt;
      &amp;lt;ProcessorArchitecture&amp;gt;MSIL&amp;lt;/ProcessorArchitecture&amp;gt;
      &amp;lt;path&amp;gt;SomeFolder\SomeOtherFolder\bin\deployment&amp;lt;/path&amp;gt;
    &amp;lt;/BTSProject&amp;gt;
  &amp;lt;/ItemGroup&amp;gt;
  &amp;lt;PropertyGroup&amp;gt;
    &amp;lt;BTApplicationName&amp;gt;MyApp&amp;lt;/BTApplicationName&amp;gt;
    &amp;lt;!-- Set &lt;span class="kwrd"&gt;for&lt;/span&gt; a remote deployment --&amp;gt;
    &amp;lt;!-- Deploying BizTalk Server name - leave blank &lt;span class="kwrd"&gt;if&lt;/span&gt; local--&amp;gt;
    &amp;lt;!-- not currently supported by runtime--&amp;gt;
    &amp;lt;BTServerName&amp;gt;
    &amp;lt;/BTServerName&amp;gt;
    &amp;lt;!-- Deploying BizTalk Server database - leave blank &lt;span class="kwrd"&gt;if&lt;/span&gt; BizTalkMsgBoxDb--&amp;gt;
    &amp;lt;BTServerDatabase&amp;gt;
    &amp;lt;/BTServerDatabase&amp;gt;
    &amp;lt;!-- Deploying BizTalk Server SQL user name - leave blank &lt;span class="kwrd"&gt;if&lt;/span&gt; local--&amp;gt;
    &amp;lt;BTServerUserName&amp;gt;
    &amp;lt;/BTServerUserName&amp;gt;
    &amp;lt;!-- Deploying BizTalk Server SQL password - leave blank &lt;span class="kwrd"&gt;if&lt;/span&gt; local--&amp;gt;
    &amp;lt;BTServerPassword&amp;gt;
    &amp;lt;/BTServerPassword&amp;gt;
  &amp;lt;/PropertyGroup&amp;gt;
&amp;lt;/Project&amp;gt;&lt;/pre&gt;

&lt;p&gt;Would you agree that the former source code is easier to maintain? &lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;&lt;em&gt;note: one thing you would notice is that none of the paths contains a root; I assume that this would be used by different developers/IT pros which may have the code in a different path; however, as the assumption is that the code will come from source control, my framework script expects you to provide the root path to your source code and assumes the specified paths start there.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;
  &lt;br /&gt;So – what’s next? &lt;/p&gt;

&lt;p&gt;From a coding perspective - I plan to add support in my runtime to perform the actual deployment; this is I would like it to do once Oslo is in production so I’ll add it as an option through a command line switch.&lt;/p&gt;

&lt;p&gt;This option would tell the runtime to deploy the artifacts to a specified BizTalk server using BTSTask or the Object model instead of generated the MSBuild script.&lt;/p&gt;

&lt;p&gt;I also want to make some modification to my language definition to make the MGraph produced cleaner (and better geared towards using the repository and Quadrant at a later stage) as well as, obviously, add support for more features, after which I plan to publish both my language and the runtime somewhere (here, codeplex, DevCente..we’ll see) &lt;/p&gt;

&lt;p&gt;I’ll post some more notes on all of these here in the near future hopefully…&lt;/p&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=129822"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=129822" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/Connected/aggbug/129822.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Yossi Dahan</dc:creator>
            <guid>http://geekswithblogs.net/Connected/archive/2009/03/04/oslo-based-solution-for-deploying-biztalk-applications.aspx</guid>
            <pubDate>Wed, 04 Mar 2009 06:12:18 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/Connected/comments/129822.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/Connected/archive/2009/03/04/oslo-based-solution-for-deploying-biztalk-applications.aspx#feedback</comments>
            <slash:comments>1</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/Connected/comments/commentRss/129822.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/Connected/services/trackbacks/129822.aspx</trackback:ping>
        </item>
        <item>
            <title>Serialisation, mixed content and string[]</title>
            <category>XML</category>
            <link>http://geekswithblogs.net/Connected/archive/2009/02/21/serialisation-mixed-content-and-string.aspx</link>
            <description>&lt;p&gt;When you generate a class out of a schema with an element configured to allow mixed content (child attributes and elements as well as text), you should expect the corresponding generated field type to be a string array;  &lt;/p&gt;&lt;p&gt;So  - if you have a schema that looks like this  &lt;/p&gt;&lt;p&gt;&lt;span style="color: blue"&gt;&amp;lt;?&lt;/span&gt;&lt;span style="color: #a31515"&gt;xml &lt;/span&gt;&lt;span style="color: red"&gt;version&lt;/span&gt;&lt;span style="color: blue"&gt;="1.0" &lt;/span&gt;&lt;span style="color: red"&gt;encoding&lt;/span&gt;&lt;span style="color: blue"&gt;="utf-8"?&amp;gt;&lt;br /&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;xs:schema &lt;/span&gt;&lt;span style="color: red"&gt;targetNamespace&lt;/span&gt;&lt;span style="color: blue"&gt;="http://tempuri.org/XMLSchema.xsd" &lt;/span&gt;&lt;span style="color: red"&gt;elementFormDefault&lt;/span&gt;&lt;span style="color: blue"&gt;="qualified"  &lt;/span&gt;&lt;span style="color: red"&gt;xmlns&lt;/span&gt;&lt;span style="color: blue"&gt;="http://tempuri.org/XMLSchema.xsd"  &lt;/span&gt;&lt;span style="color: red"&gt;xmlns:mstns&lt;/span&gt;&lt;span style="color: blue"&gt;="http://tempuri.org/XMLSchema.xsd"&lt;br /&gt;&lt;/span&gt;&lt;span style="color: red"&gt;xmlns:xs&lt;/span&gt;&lt;span style="color: blue"&gt;="http://www.w3.org/2001/XMLSchema"&amp;gt;&lt;br /&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;xs:element &lt;/span&gt;&lt;span style="color: red"&gt;name&lt;/span&gt;&lt;span style="color: blue"&gt;="SomeElement"&amp;gt;&lt;br /&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;xs:complexType &lt;/span&gt;&lt;span style="color: red"&gt;mixed&lt;/span&gt;&lt;span style="color: blue"&gt;="true"&amp;gt;&lt;br /&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;xs:sequence&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;br /&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;xs:element &lt;/span&gt;&lt;span style="color: red"&gt;name&lt;/span&gt;&lt;span style="color: blue"&gt;="Child1" &lt;/span&gt;&lt;span style="color: red"&gt;type&lt;/span&gt;&lt;span style="color: blue"&gt;="xs:string"/&amp;gt;&lt;br /&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;xs:element &lt;/span&gt;&lt;span style="color: red"&gt;name&lt;/span&gt;&lt;span style="color: blue"&gt;="Child2" &lt;/span&gt;&lt;span style="color: red"&gt;type&lt;/span&gt;&lt;span style="color: blue"&gt;="xs:string"/&amp;gt;&lt;br /&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;xs:element &lt;/span&gt;&lt;span style="color: red"&gt;name&lt;/span&gt;&lt;span style="color: blue"&gt;="Child3" &lt;/span&gt;&lt;span style="color: red"&gt;type&lt;/span&gt;&lt;span style="color: blue"&gt;="xs:string"/&amp;gt;&lt;br /&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;xs:sequence&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;br /&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;xs:attribute &lt;/span&gt;&lt;span style="color: red"&gt;name&lt;/span&gt;&lt;span style="color: blue"&gt;="SomeAttribute" &lt;/span&gt;&lt;span style="color: red"&gt;type&lt;/span&gt;&lt;span style="color: blue"&gt;="xs:string"/&amp;gt;&lt;br /&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;xs:complexType&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;br /&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;xs:element&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;br /&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;xs:schema&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;(not ‘SomeElement’ being a complex type allowing mixed content)&lt;/p&gt; &lt;p&gt;The fields in the generated class would look like  &lt;/p&gt;&lt;p&gt; &lt;/p&gt;&lt;span style="color: blue"&gt;&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;public partial class &lt;/span&gt;&lt;span style="color: #2b91af"&gt;SomeElement {
 
 &lt;/span&gt;&lt;span style="color: blue"&gt;private string child1Field;
 
 private string child2Field;
 
 private string child3Field;
 
&lt;strong&gt; private string[] textField;
&lt;/strong&gt; 
 private string someAttributeField;
.
.
.
&lt;/span&gt;&lt;/pre&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;/span&gt;
&lt;p&gt;&lt;font color="#000000"&gt;The reason is that an XML corresponding to the schema might look like this – &lt;/font&gt;
&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;SomeElement &lt;/span&gt;&lt;span style="color: red"&gt;xmlns&lt;/span&gt;&lt;span style="color: blue"&gt;="http://tempuri.org/XMLSchema.xsd" &lt;/span&gt;&lt;span style="color: red"&gt;SomeAttribute&lt;/span&gt;&lt;span style="color: blue"&gt;="someAttributeValue"&amp;gt;
 Some free text
 &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Child1&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;Child1 text&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;Child1&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
 Some more free text
 &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Child2&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;Child2 text&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;Child2&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
 yet some more free text
 &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Child3&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;Child3 text&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;Child3&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;SomeElement&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
&lt;/span&gt;&lt;/pre&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;
&lt;p&gt;&lt;font color="#000000"&gt;And so by using a string array to hold the text the deserialiser can keep string portion separately.&lt;/font&gt; 
&lt;/p&gt;&lt;p&gt;&lt;font color="#000000"&gt;Initially, I thought, this allows the structure to represent the original xml accurately, but this is not exactly the case – you would still not know for certain where each string portion existed, especially if in the source XML you get a few elements that don’t have text between them, which , I suspect, is why when I serialise the instance back to xml I actually get – &lt;/font&gt;&lt;/p&gt;&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;&amp;lt;?&lt;/span&gt;&lt;span style="color: #a31515"&gt;xml &lt;/span&gt;&lt;span style="color: red"&gt;version&lt;/span&gt;&lt;span style="color: blue"&gt;="1.0"?&amp;gt;
&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;SomeElement &lt;/span&gt;&lt;span style="color: red"&gt;xmlns:xsi&lt;/span&gt;&lt;span style="color: blue"&gt;="http://www.w3.org/2001/XMLSchema-instance" &lt;/span&gt;&lt;span style="color: red"&gt;xmlns:xsd&lt;/span&gt;&lt;span style="color: blue"&gt;="http://www.w3.org/2001/XMLSchema" &lt;/span&gt;&lt;span style="color: red"&gt;SomeAttribute&lt;/span&gt;&lt;span style="color: blue"&gt;="someAttributeValue" &lt;/span&gt;&lt;span style="color: red"&gt;xmlns&lt;/span&gt;&lt;span style="color: blue"&gt;="http://tempuri.org/XMLSchema.xsd"&amp;gt;
 &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Child1&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;Child1 text&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;Child1&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
 &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Child2&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;Child2 text&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;Child2&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
 &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Child3&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;Child3 text&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;Child3&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
 Some free text
 
 Some more free text
 
 yet some more free text
 &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;SomeElement&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
&lt;/span&gt;&lt;/pre&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;
&lt;p&gt;Now, I don’t particularly like this sort of xml, and shy away from mixed content; I don’t believe that xml snippets like my samples above are useful, specifically I don’t think that mixing elements and text is particularly nice.&lt;/p&gt;
&lt;p&gt;However, consider an element with an attribute and some text – the following is quite reasonable I think, and yet requires mixed content - &lt;/p&gt;
&lt;p&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Phone &lt;span style="color: red"&gt;type&lt;/span&gt;&lt;span style="color: blue"&gt;="mobile"&lt;/span&gt;&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;some text here&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;Phone&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=129578"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=129578" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/Connected/aggbug/129578.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Yossi Dahan</dc:creator>
            <guid>http://geekswithblogs.net/Connected/archive/2009/02/21/serialisation-mixed-content-and-string.aspx</guid>
            <pubDate>Sat, 21 Feb 2009 12:59:11 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/Connected/comments/129578.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/Connected/archive/2009/02/21/serialisation-mixed-content-and-string.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/Connected/comments/commentRss/129578.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/Connected/services/trackbacks/129578.aspx</trackback:ping>
        </item>
    </channel>
</rss>