<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogical.se/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Mikael Håkansson</title><link>http://blogical.se/blogs/mikael/default.aspx</link><description>&lt;span style="font-weight:normal;"&gt;
&amp;quot;Sometimes the road less traveled is less traveled for a reason.&amp;quot; &lt;br /&gt;
&lt;span style="color:Orange;"&gt;- Jerry, in &amp;quot;The Baby Shower&amp;quot; &lt;/span&gt;&lt;/span&gt; </description><dc:language>en</dc:language><generator>CommunityServer 2007.1 (Build: 20917.1142)</generator><item><title>Changing xsn prefix and grouping using XSLT with BizTalk</title><link>http://blogical.se/blogs/mikael/archive/2015/10/06/changing-xsn-prefix-and-grouping-using-xslt-with-biztalk.aspx</link><pubDate>Tue, 06 Oct 2015 12:07:00 GMT</pubDate><guid isPermaLink="false">19a535f3-07d9-4378-9c5a-8d019d91e842:37510</guid><dc:creator>wmmihaa</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;I’m not an expert in XSLT, nor am I a fan of it. But although my feeling for XSLT (which I’m sure is mutual) are cold and hostile at best, I recognize it as sometimes the only solution to the problem. Recently, I’ve come across two scenarios where it was the only way to solve the problem, and since I spent way too much time on it, I thought it be a good idea to share it. If not to anyone else, at least to myself as I don’t want to do this again…&lt;/p&gt;  &lt;p&gt;The first scenario we had to send a file to a destination, and the consumer of the message requested that we’d use specific prefixes for the namespaces. BizTalk Server sets these namespaces for us starting from ns0, ns1…ns*. There isn’t built in way for us to control this, and given the complexity of hieratical structures from different namespaces I can understand why.&lt;/p&gt;  &lt;p&gt;However in my case, as I said, the consumer of the message required the namespace to be set to “tns”. My first approach was to create a pipeline component and use the &lt;a href="https://msdn.microsoft.com/en-us/library/microsoft.biztalk.streaming.xmltranslatorstream.aspx"&gt;XmlTranslatorStream&lt;/a&gt; which comes as part of the Microsoft.BizTalk.Streaming. The XmlTranslatorStream allows derived classes to intercept XML node translation through virtual methods such as &lt;a href="https://msdn.microsoft.com/en-us/library/microsoft.biztalk.streaming.xmltranslatorstream.translatestartelement.aspx#M:Microsoft.BizTalk.Streaming.XmlTranslatorStream.TranslateStartElement(System.String,System.String,System.String)"&gt;TranslateStartElement&lt;/a&gt;.&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; XmlNamespaceHandlerStream : XmlTranslatorStream
    {
        &lt;span class="kwrd"&gt;string&lt;/span&gt; _fromPrefix;
        &lt;span class="kwrd"&gt;string&lt;/span&gt; _xmlNamespace;
        &lt;span class="kwrd"&gt;string&lt;/span&gt; _toPrefix;

        &lt;span class="kwrd"&gt;protected&lt;/span&gt; &lt;span class="kwrd"&gt;override&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; TranslateStartElement(&lt;span class="kwrd"&gt;string&lt;/span&gt; prefix, &lt;span class="kwrd"&gt;string&lt;/span&gt; localName, &lt;span class="kwrd"&gt;string&lt;/span&gt; nsURI)
        {
            &lt;span class="kwrd"&gt;if&lt;/span&gt; (prefix == _fromPrefix &amp;amp;&amp;amp; nsURI == _xmlNamespace) 
                &lt;span class="kwrd"&gt;base&lt;/span&gt;.TranslateStartElement(_toPrefix, localName, nsURI);
            &lt;span class="kwrd"&gt;else&lt;/span&gt; &lt;span class="kwrd"&gt;if&lt;/span&gt; (nsURI == _xmlNamespace) 
                &lt;span class="kwrd"&gt;base&lt;/span&gt;.TranslateStartElement(&lt;span class="kwrd"&gt;null&lt;/span&gt;, localName, &lt;span class="kwrd"&gt;null&lt;/span&gt;);
            &lt;span class="kwrd"&gt;else&lt;/span&gt;
                &lt;span class="kwrd"&gt;base&lt;/span&gt;.TranslateStartElement(prefix, localName, nsURI);
        }
        
        &lt;span class="kwrd"&gt;protected&lt;/span&gt; &lt;span class="kwrd"&gt;override&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; TranslateAttribute()
        {
            &lt;span class="kwrd"&gt;if&lt;/span&gt; (&lt;span class="kwrd"&gt;this&lt;/span&gt;.m_reader.Prefix != &lt;span class="str"&gt;&amp;quot;xmlns&amp;quot;&lt;/span&gt;)
                &lt;span class="kwrd"&gt;base&lt;/span&gt;.TranslateAttribute();
        }
        &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;
        &lt;span class="rem"&gt;/// Intercepts the processing of the XML stream and changes prefixes from &lt;/span&gt;
        &lt;span class="rem"&gt;/// a specific namespace to a new prefix.&lt;/span&gt;
        &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;
        &lt;span class="rem"&gt;/// &amp;lt;param name=&amp;quot;input&amp;quot;&amp;gt;Inbound message stream. Eg inmsg.BodyPart.Data&amp;lt;/param&amp;gt;&lt;/span&gt;
        &lt;span class="rem"&gt;/// &amp;lt;param name=&amp;quot;fromPrefix&amp;quot;&amp;gt;The prefix to be changed. Eg ns0&amp;lt;/param&amp;gt;&lt;/span&gt;
        &lt;span class="rem"&gt;/// &amp;lt;param name=&amp;quot;xmlNamespace&amp;quot;&amp;gt;whatever namespace is associated with the fromPrefix&amp;lt;/param&amp;gt;&lt;/span&gt;
        &lt;span class="rem"&gt;/// &amp;lt;param name=&amp;quot;toPrefix&amp;quot;&amp;gt;Name of the new prefix&amp;lt;/param&amp;gt;&lt;/span&gt;
        &lt;span class="kwrd"&gt;public&lt;/span&gt; XmlNamespaceHandlerStream(Stream input, &lt;span class="kwrd"&gt;string&lt;/span&gt; fromPrefix, &lt;span class="kwrd"&gt;string&lt;/span&gt; xmlNamespace, &lt;span class="kwrd"&gt;string&lt;/span&gt; toPrefix)
            : &lt;span class="kwrd"&gt;base&lt;/span&gt;(&lt;span class="kwrd"&gt;new&lt;/span&gt; XmlTextReader(input), Encoding.Default)
        {
            &lt;span class="kwrd"&gt;this&lt;/span&gt;._fromPrefix = fromPrefix;
            &lt;span class="kwrd"&gt;this&lt;/span&gt;._toPrefix = toPrefix;
            &lt;span class="kwrd"&gt;this&lt;/span&gt;._xmlNamespace = xmlNamespace;
        }
    }&lt;/pre&gt;

&lt;p&gt;The TranslateStartElement is called for every XML element, and if the prefix (and namespace) is the same as the one I like to change, I proceed with changing the prefix. To process the message in a pipeline component, I simply use like this:&lt;/p&gt;

&lt;pre class="csharpcode"&gt;inmsg.BodyPart.Data = &lt;span class="kwrd"&gt;new&lt;/span&gt; XmlNamespaceHandlerStream(
    inmsg.BodyPart.GetOriginalDataStream(),  &lt;span class="rem"&gt;// Inbound stream&lt;/span&gt;
    &lt;span class="kwrd"&gt;this&lt;/span&gt;.FromPrefix,  &lt;span class="rem"&gt;// Property of pipeline component&lt;/span&gt;
    &lt;span class="kwrd"&gt;this&lt;/span&gt;.XmlNamespace,  &lt;span class="rem"&gt;// Property of pipeline component&lt;/span&gt;
    &lt;span class="kwrd"&gt;this&lt;/span&gt;.ToPrefix);  &lt;span class="rem"&gt;// Property of pipeline component&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;The good thing with this approach is that it’s done with a streaming pattern. However, the problem was that it moves all namespace declarations except the one I want to change from the root element to each element using it. This might not be a problem if the message is small, but in my case the message contained 100.000+ person elements. The inbound flat file format was about 20Mb and the original output using ns0 as prefix was close to 80Mb. After I changed the namespace prefix using the XmlTranslatorStream it was more than 140Mb. The additional namespace declarations added approximately 75%.&lt;/p&gt;

&lt;p&gt;So although my intensions were good, I was forced to fall back to sworn enemy, mr XSLT:&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;&amp;lt;?&lt;/span&gt;&lt;span class="html"&gt;xml&lt;/span&gt; &lt;span class="attr"&gt;version&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;1.0&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;encoding&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;utf-16&amp;quot;&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;xsl:stylesheet&lt;/span&gt; &lt;span class="attr"&gt;xmlns:xsl&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;http://www.w3.org/1999/XSL/Transform&amp;quot;&lt;/span&gt;
                &lt;span class="attr"&gt;xmlns:msxsl&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;urn:schemas-microsoft-com:xslt&amp;quot;&lt;/span&gt;
                &lt;span class="attr"&gt;xmlns:var&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;http://schemas.microsoft.com/BizTalk/2003/var&amp;quot;&lt;/span&gt;
                &lt;span class="attr"&gt;exclude-result-prefixes&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;msxsl var s0 userCSharp&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;version&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;1.0&amp;quot;&lt;/span&gt;
                &lt;span class="attr"&gt;xmlns:cmn&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;http://somenamespace/CommonInformationInt&amp;quot;&lt;/span&gt;
                &lt;span class="attr"&gt;xmlns:s0&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;http://schemas.microsoft.com/BizTalk/2003/aggschema&amp;quot;&lt;/span&gt;
                &lt;span class="attr"&gt;xmlns:ns0&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;http://somenamespace/Person&amp;quot;&lt;/span&gt;
                &lt;span class="attr"&gt;xmlns:tns&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;http://somenamespace/Person&amp;quot;&lt;/span&gt;
                &lt;span class="attr"&gt;xmlns:fi&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;http://somenamespace/FileInfo&amp;quot;&lt;/span&gt;
                &lt;span class="attr"&gt;xmlns:ci&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;http://somenamespace/CustomerInfo&amp;quot;&lt;/span&gt;
                &lt;span class="attr"&gt;xmlns:userCSharp&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;http://schemas.microsoft.com/BizTalk/2003/userCSharp&amp;quot;&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;xsl:output&lt;/span&gt; &lt;span class="attr"&gt;method&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;xml&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;indent&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;yes&amp;quot;&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;xsl:template&lt;/span&gt; &lt;span class="attr"&gt;match&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;ns0:PersonInfo&amp;quot;&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;tns:PersonInfo&lt;/span&gt;
        &lt;span class="attr"&gt;xmlns:xsi&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;http://www.w3.org/2001/XMLSchema-instance&amp;quot;&lt;/span&gt;
        &lt;span class="attr"&gt;xmlns:xsd&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;http://www.w3.org/2001/XMLSchema&amp;quot;&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;xsl:apply-templates&lt;/span&gt; &lt;span class="attr"&gt;select&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;@*|node()&amp;quot;&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;tns:PersonInfo&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;xsl:template&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;xsl:template&lt;/span&gt; &lt;span class="attr"&gt;match&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;ns0:*&amp;quot;&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;xsl:element&lt;/span&gt; &lt;span class="attr"&gt;name&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;tns:{local-name()}&amp;quot;&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;xsl:apply-templates&lt;/span&gt; &lt;span class="attr"&gt;select&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;@* | node()&amp;quot;&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;xsl:element&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;xsl:template&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;xsl:template&lt;/span&gt; &lt;span class="attr"&gt;match&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;cmn:*&amp;quot;&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;xsl:element&lt;/span&gt; &lt;span class="attr"&gt;name&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;cmn:{local-name()}&amp;quot;&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;xsl:apply-templates&lt;/span&gt; &lt;span class="attr"&gt;select&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;@* | node()&amp;quot;&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;xsl:element&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;xsl:template&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;xsl:template&lt;/span&gt; &lt;span class="attr"&gt;match&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;@ns0:*&amp;quot;&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;xsl:attribute&lt;/span&gt; &lt;span class="attr"&gt;name&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;tns:{local-name()}&amp;quot;&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;xsl:value-of&lt;/span&gt; &lt;span class="attr"&gt;select&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;.&amp;quot;&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;xsl:attribute&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;xsl:template&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;xsl:template&lt;/span&gt; &lt;span class="attr"&gt;match&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;node()&amp;quot;&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;xsl:copy&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;xsl:apply-templates&lt;/span&gt; &lt;span class="attr"&gt;select&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;@* | node()&amp;quot;&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;xsl:copy&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;xsl:template&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;xsl:template&lt;/span&gt; &lt;span class="attr"&gt;match&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;@*&amp;quot;&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;xsl:copy&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;xsl:template&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;xsl:stylesheet&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;I then used a pipeline component for do the transformation using the XslCompiledTransform class:&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="rem"&gt;// Using a VirtualStream to limit memory resources from being used.&lt;/span&gt;
var outStream = &lt;span class="kwrd"&gt;new&lt;/span&gt; VirtualStream(VirtualStream.MemoryFlag.AutoOverFlowToDisk);

XmlTextReader xmlTextReader = &lt;span class="kwrd"&gt;new&lt;/span&gt; XmlTextReader(inmsg.BodyPart.Data);
XslCompiledTransform xsl = &lt;span class="kwrd"&gt;new&lt;/span&gt; XslCompiledTransform(&lt;span class="kwrd"&gt;false&lt;/span&gt;);

MemoryStream stream = &lt;span class="kwrd"&gt;new&lt;/span&gt; MemoryStream(Encoding.Unicode.GetBytes(Resources.[&lt;font style="background-color:#ffff00;"&gt;YOUR EMBEDDED XSLT DOC&lt;/font&gt;]));

XmlTextReader xsltTextReader = &lt;span class="kwrd"&gt;new&lt;/span&gt; XmlTextReader(stream);
XsltSettings settings = &lt;span class="kwrd"&gt;new&lt;/span&gt; XsltSettings(&lt;span class="kwrd"&gt;true&lt;/span&gt;, &lt;span class="kwrd"&gt;true&lt;/span&gt;);
xsl.Load(xsltTextReader, settings, &lt;span class="kwrd"&gt;new&lt;/span&gt; XmlUrlResolver());

xsl.Transform(xmlTextReader, &lt;span class="kwrd"&gt;new&lt;/span&gt; XsltArgumentList(), outStream);

outStream.Position = 0;
inmsg.BodyPart.Data = outStream;

inmsg.BodyPart.Charset = &lt;span class="str"&gt;&amp;quot;utf-8&amp;quot;&lt;/span&gt;;
&lt;span class="kwrd"&gt;return&lt;/span&gt; inmsg;&lt;/pre&gt;

&lt;p&gt;The second scenario was about sending information to a destination where the receiver of the message could not handle the entire message at once. So we had to split the message in chunks of 50.000 person records per message.&lt;/p&gt;

&lt;p&gt;Again I turned to my sworn enemy. This time I created two templates with identical match attribute setting and a template mode attribute (“group” or “person”) depending on if I was going to create a new group element or add the person element to the existing group. &lt;/p&gt;

&lt;p&gt;I used the position() XPath function to determine the current count of Person elements, and a modular expression to determine if a group should be created.&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;&amp;lt;?&lt;/span&gt;&lt;span class="html"&gt;xml&lt;/span&gt; &lt;span class="attr"&gt;version&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;1.0&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;encoding&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;utf-16&amp;quot;&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;xsl:stylesheet&lt;/span&gt; &lt;span class="attr"&gt;xmlns:xsl&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;http://www.w3.org/1999/XSL/Transform&amp;quot;&lt;/span&gt;
                &lt;span class="attr"&gt;xmlns:msxsl&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;urn:schemas-microsoft-com:xslt&amp;quot;&lt;/span&gt;
                &lt;span class="attr"&gt;xmlns:var&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;http://schemas.microsoft.com/BizTalk/2003/var&amp;quot;&lt;/span&gt;
                &lt;span class="attr"&gt;exclude-result-prefixes&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;msxsl var s0&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;version&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;1.0&amp;quot;&lt;/span&gt;
                &lt;span class="attr"&gt;xmlns:ns0&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;http://schemas.microsoft.com/Sql/2008/05/Types/Views/dbo&amp;quot;&lt;/span&gt;
                &lt;span class="attr"&gt;xmlns:ns1&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;http://p.PersonInserts&amp;quot;&lt;/span&gt;
                &lt;span class="attr"&gt;xmlns:s0&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;http://schemas.microsoft.com/Sql/2008/05/ViewOp/dbo/Person&amp;quot;&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;xsl:output&lt;/span&gt; &lt;span class="attr"&gt;omit-xml-declaration&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;yes&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;method&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;xml&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;version&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;1.0&amp;quot;&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;xsl:template&lt;/span&gt; &lt;span class="attr"&gt;match&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;/&amp;quot;&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;ns1:PersonInserts&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;xsl:apply-templates&lt;/span&gt; &lt;span class="attr"&gt;select&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;/s0:SelectResponse&amp;quot;&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;ns1:PersonInserts&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;xsl:template&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;xsl:template&lt;/span&gt; &lt;span class="attr"&gt;match&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;/s0:SelectResponse&amp;quot;&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;xsl:apply-templates&lt;/span&gt; &lt;span class="attr"&gt;select&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;//ns0:Person[position() mod 50000 = 1]&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;mode&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;group&amp;quot;&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;xsl:template&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;xsl:template&lt;/span&gt; &lt;span class="attr"&gt;match&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;//ns0:Person&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;mode&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;person&amp;quot;&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;ns0:Person&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;ns0:customId&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;xsl:value-of&lt;/span&gt; &lt;span class="attr"&gt;select&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;./ns0:customId&amp;quot;&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;ns0:customId&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;ns0:Identifier&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;xsl:value-of&lt;/span&gt; &lt;span class="attr"&gt;select&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;./ns0:Identifier&amp;quot;&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;ns0:Identifier&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;ns0:firstName&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;xsl:value-of&lt;/span&gt; &lt;span class="attr"&gt;select&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;./ns0:firstName&amp;quot;&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;ns0:firstName&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;ns0:lastName&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;xsl:value-of&lt;/span&gt; &lt;span class="attr"&gt;select&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;./ns0:lastName&amp;quot;&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;ns0:lastName&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;ns0:Person&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;xsl:template&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;xsl:template&lt;/span&gt; &lt;span class="attr"&gt;match&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;//ns0:Person&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;mode&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;group&amp;quot;&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;Group&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;xsl:apply-templates&lt;/span&gt; &lt;span class="attr"&gt;select&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;. | following-sibling::ns0:Person[position() &amp;amp;lt; 50000]&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;mode&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;person&amp;quot;&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;Group&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;xsl:template&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;xsl:stylesheet&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;HTH&lt;/p&gt;

&lt;p&gt;Mikael&lt;/p&gt;&lt;img src="http://blogical.se/aggbug.aspx?PostID=37510" width="1" height="1"&gt;</description><category domain="http://blogical.se/blogs/mikael/archive/tags/BizTalk/default.aspx">BizTalk</category><category domain="http://blogical.se/blogs/mikael/archive/tags/Components/default.aspx">Components</category><category domain="http://blogical.se/blogs/mikael/archive/tags/XSLT/default.aspx">XSLT</category></item><item><title>How to use context data with Business Rules</title><link>http://blogical.se/blogs/mikael/archive/2015/02/17/how-to-use-context-data-with-business-rules.aspx</link><pubDate>Tue, 17 Feb 2015 00:51:00 GMT</pubDate><guid isPermaLink="false">19a535f3-07d9-4378-9c5a-8d019d91e842:35981</guid><dc:creator>wmmihaa</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I had never come across the need to execute rules based on message metadata until a colleague of mine asked me the other day. Which is surprising as we often define routing rules based on the message context.&lt;/p&gt;

&lt;p&gt;The basic principle is simple, – Rather than using schema based facts, we use facts based on .Net assemblies. In this case &lt;em&gt;IBaseMessageContext&lt;/em&gt; (Microsoft.BizTalk.Message.Interop). This works well in cases where you’d like to call the rule from within a pipeline, as the context of the pipeline message (&lt;em&gt;IBaseMessage&lt;/em&gt;) is implementing the &lt;em&gt;IBaseMessageContext&lt;/em&gt; interface.&lt;/p&gt;

&lt;p&gt;If, on the other hand, you want to execute the rule form an orchestration we can’t use an interface as a rule fact, as the &lt;em&gt;CallRules Policy &lt;/em&gt;shape can’t work with interfaces. In those cases we’d need to use a custom class (the one the is used by BizTalk is internal).&lt;/p&gt;

&lt;h2&gt;Create the output fact schema&lt;/h2&gt;

&lt;p&gt;Before we create the rule you need to have your facts ready. The input fact is going to be the context object mentioned above but you need to create the output schema where you’re going to store the result if the rule evaluates to true. &lt;/p&gt;

&lt;h2&gt;Create the rule (Messaging scenario)&lt;/h2&gt;

&lt;p&gt;Open the &lt;em&gt;Microsoft Business Rule Compose &lt;/em&gt;and create your policy and rule as you’d normally do. Then in the &lt;em&gt;Fact Explorer&lt;/em&gt; select the &lt;em&gt;.Net Classes &lt;/em&gt;tab, right-click the &lt;em&gt;.Net Assemblies &lt;/em&gt;node and select &lt;em&gt;Browse. &lt;/em&gt;The &lt;em&gt;IBaseMessageContext&lt;/em&gt; interface is found in the &lt;em&gt;Microsoft.BizTalk.Pipeline &lt;/em&gt;assembly. Select the assembly and expand the &lt;em&gt;IBaseMessageContext&lt;/em&gt; in the tree view. &lt;/p&gt;

&lt;p&gt;Drag the &lt;em&gt;Read(String strName, String strNamespace) &lt;/em&gt;method to your rule condition:&lt;/p&gt;

&lt;p&gt;&lt;img width="640" height="211" src="http://blogical.se/blogs/mikael/20140916_1.png" alt="" /&gt;&lt;/p&gt;

&lt;p&gt;&amp;nbsp;&lt;/p&gt;

&lt;p&gt;&amp;nbsp;&lt;/p&gt;

&lt;h2&gt;Create the pipeline component (Messaging scenario)&lt;/h2&gt;

&lt;p&gt;If you haven’t developed a pipeline component before you can use a nuget package like &lt;a href="http://www.nuget.org/packages/Breeze.BizTalkPipelineComponentProject/"&gt;Default Breeze BizTalk Pipeline Component&lt;/a&gt;. Simply create a class library project and install the nuget package. Follow the steps at the top of the pipeline component file before implementing the &lt;em&gt;Execute&lt;/em&gt; method.&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; IBaseMessage Execute(IPipelineContext pc, IBaseMessage inmsg)
{
    &lt;span class="rem"&gt;//Create a policy object based on the name of the Policy&lt;/span&gt;
    Policy policy = &lt;span class="kwrd"&gt;new&lt;/span&gt; Policy(&lt;span class="str"&gt;&amp;quot;MessageContextSamplePolicy&amp;quot;&lt;/span&gt;);
            
    &lt;span class="rem"&gt;// Create the response document&lt;/span&gt;
    XmlDocument doc = &lt;span class="kwrd"&gt;new&lt;/span&gt; XmlDocument();
    doc.LoadXml(&lt;span class="str"&gt;@&amp;quot;&amp;lt;ns0:BreTest xmlns:ns0=&amp;quot;&lt;/span&gt;&lt;span class="str"&gt;&amp;quot;http://BreWithPromotedPropertiesSample.BreTest&amp;quot;&lt;/span&gt;&lt;span class="str"&gt;&amp;quot;&amp;gt;&amp;lt;Field&amp;gt;&amp;lt;/Field&amp;gt;&amp;lt;/ns0:BreTest&amp;gt;&amp;quot;&lt;/span&gt;);
    &lt;span class="kwrd"&gt;var&lt;/span&gt; responseDoc = &lt;span class="kwrd"&gt;new&lt;/span&gt; TypedXmlDocument(&lt;span class="str"&gt;&amp;quot;BreWithPromotedPropertiesSample.BreTest&amp;quot;&lt;/span&gt;, doc);
            
    &lt;span class="rem"&gt;//Execute the policy and pass the message context and the response docoument&lt;/span&gt;
    policy.Execute(&lt;span class="kwrd"&gt;new&lt;/span&gt; &lt;span class="kwrd"&gt;object&lt;/span&gt;[] { inmsg.Context, responseDoc });
            
    &lt;span class="kwrd"&gt;var&lt;/span&gt; responseXml = responseDoc.Document.OuterXml;
           
    &lt;span class="rem"&gt;// TODO&lt;/span&gt;
    &lt;span class="rem"&gt;// Take action on the response XML...&lt;/span&gt;

    &lt;span class="kwrd"&gt;return&lt;/span&gt; inmsg;
}&lt;/pre&gt;

&lt;h2&gt;Create the rule (Orchestration scenario)&lt;/h2&gt;

&lt;p&gt;There are two problems to working with the context data together with orchestrations; Access the metadata and not being able to work with interfaces (CallRules Policy shape can’t work with interfaces).&lt;/p&gt;

&lt;p&gt;Within the orchestration we don’t have the &lt;em&gt;IBaseMessage&lt;/em&gt; from which we can easily access the context. Instead we got the &lt;a href="http://msdn.microsoft.com/en-us/library/ee277265(v=bts.10).aspx"&gt;XLANGMessage&lt;/a&gt;. The message context is not as easily accessible form the XLANGMessage as it is from the IBaseMessage. Thankfully &lt;a href="http://maximelabelle.wordpress.com/2011/01/07/retrieving-the-context-of-a-biztalk-message-from-an-orchestration/"&gt;Maxime Labelle&lt;/a&gt; provided insight of how this can be accomplished. &lt;/p&gt;

&lt;p&gt;I solved these problems be creating my own class called XLANGMessageContext and from within the constructor I read through the metadata. The class also provide a &lt;em&gt;Read&lt;/em&gt; method that will return the value for a specific property:&lt;/p&gt;

&lt;p&gt;&amp;nbsp;&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; XLANGMessageContext
{
    Hashtable _messageContext = &lt;span class="kwrd"&gt;null&lt;/span&gt;;

    &lt;span class="kwrd"&gt;public&lt;/span&gt; XLANGMessageContext(XLANGMessage message, &lt;span class="kwrd"&gt;string&lt;/span&gt; name, &lt;span class="kwrd"&gt;string&lt;/span&gt; ns)
    {
        &lt;span class="kwrd"&gt;try&lt;/span&gt;
        {
            &lt;span class="kwrd"&gt;foreach&lt;/span&gt; (Segment segment &lt;span class="kwrd"&gt;in&lt;/span&gt; Service.RootService._segments)
            {
                IDictionary fields = Context.FindFields(&lt;span class="kwrd"&gt;typeof&lt;/span&gt;(XLANGMessage), segment.ExceptionContext);

                &lt;span class="kwrd"&gt;foreach&lt;/span&gt; (DictionaryEntry field &lt;span class="kwrd"&gt;in&lt;/span&gt; fields)
                {
                    XMessage msg = (field.Value &lt;span class="kwrd"&gt;as&lt;/span&gt; XMessage);
                    &lt;span class="kwrd"&gt;if&lt;/span&gt; (msg == &lt;span class="kwrd"&gt;null&lt;/span&gt;)
                        &lt;span class="kwrd"&gt;continue&lt;/span&gt;;

                    &lt;span class="kwrd"&gt;if&lt;/span&gt; (String.Compare(msg.Name, message.Name) != 0)
                        &lt;span class="kwrd"&gt;continue&lt;/span&gt;;

                    &lt;span class="kwrd"&gt;var&lt;/span&gt; key = &lt;span class="kwrd"&gt;new&lt;/span&gt; XmlQName(name, ns);
                    _messageContext= msg.GetContextProperties();
                       
                }
            }
        }
        &lt;span class="kwrd"&gt;catch&lt;/span&gt; (Exception &lt;span class="rem"&gt;/* e */&lt;/span&gt;)
        {
            &lt;span class="rem"&gt;// do not provoke failure&lt;/span&gt;
            &lt;span class="rem"&gt;// probably best to add some logging here&lt;/span&gt;
        }
    }

    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;object&lt;/span&gt; Read(&lt;span class="kwrd"&gt;string&lt;/span&gt; strName, &lt;span class="kwrd"&gt;string&lt;/span&gt; strNamespace)
    {
        &lt;span class="kwrd"&gt;var&lt;/span&gt; key = &lt;span class="kwrd"&gt;new&lt;/span&gt; XmlQName(strName, strNamespace);
        &lt;span class="kwrd"&gt;var&lt;/span&gt; result = _messageContext[key];
        &lt;span class="kwrd"&gt;return&lt;/span&gt; result;
    }
}&lt;/pre&gt;

&lt;p&gt;Creating the rule is very similar to the messaging scenario, but instead of using the &lt;em&gt;IBaseMessageContext&lt;/em&gt; object you’ll use the &lt;em&gt;Read &lt;/em&gt;method from the XLANGMessageContext:&lt;/p&gt;

&lt;p&gt;&lt;img width="640" height="211" src="http://blogical.se/blogs/mikael/20140916_2.png" alt="" /&gt;&lt;/p&gt;

&lt;h2&gt;Use the XLANGMessageContext (Orchestration scenario)&lt;/h2&gt;

&lt;p&gt;In your orchestration, create&amp;nbsp; a BreHelperComponent.XLANGMessageContext valiable called xlangMessageContext, and construct it in an Expression shape:&lt;/p&gt;

&lt;p&gt;xlangMessageContext = new BreHelperComponent.XLANGMessageContext(myMessage);&lt;/p&gt;

&lt;p&gt;Lastly add a &lt;em&gt;CallRules &lt;/em&gt;shape and provide the parameters:&lt;/p&gt;

&lt;p&gt;&lt;img src="http://blogical.se/blogs/mikael/20140916_3.png" alt="" /&gt;&lt;/p&gt;

&lt;p&gt;&amp;nbsp;&lt;/p&gt;

&lt;p&gt;You can download the sample &lt;a href="http://blogical.se/files/folders/downloads/entry35976.aspx"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;HTH&lt;/p&gt;

&lt;p&gt;Mikael&lt;/p&gt;&lt;img src="http://blogical.se/aggbug.aspx?PostID=35981" width="1" height="1"&gt;</description><category domain="http://blogical.se/blogs/mikael/archive/tags/BizTalk/default.aspx">BizTalk</category><category domain="http://blogical.se/blogs/mikael/archive/tags/Tools/default.aspx">Tools</category><category domain="http://blogical.se/blogs/mikael/archive/tags/Sample/default.aspx">Sample</category></item><item><title>New version of the SFTP Adapter</title><link>http://blogical.se/blogs/mikael/archive/2014/02/09/new-version-of-the-sftp-adapter.aspx</link><pubDate>Sun, 09 Feb 2014 21:42:28 GMT</pubDate><guid isPermaLink="false">19a535f3-07d9-4378-9c5a-8d019d91e842:34125</guid><dc:creator>wmmihaa</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;The bLogical SFTP adapter has been around for a while now, since 2008 to be exact. It has been one of the most popular BizTalk related downloads on Codeplex, and even though BizTalk 2013 is now shipped with an SFTP adapter people still use it since it quite rich on features such as proxy support and more granular scheduling capabilities.&lt;/p&gt;  &lt;p&gt;There has been lots of feedback, most of which I believe I’ve implemented or fixed over the years. However there was one issue I never got around to fix; – the receive location &amp;#39;freeze&amp;#39; issue.&lt;/p&gt;  &lt;p&gt;Luckily Greg Shap from New Zealand came along, fixed the issue and uploaded a patch on Codeplex. I’ve since added Greg to the project and he’s fixed the issues along with an impressive list of other fixes and changes:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Ensure thread-safe write access to SftpHostFiles.config&lt;/li&gt;    &lt;li&gt;Resolve a receive location &amp;#39;freeze&amp;#39; issue where files would stop being picked up until restarting the host instance&lt;/li&gt;    &lt;li&gt;Resolve a zero length file creation issue&lt;/li&gt;    &lt;li&gt;Correct a partial file read issue when consuming large files&lt;/li&gt;    &lt;li&gt;Add X.509 identity certificate support&lt;/li&gt;    &lt;li&gt;Add TransmitLocation context property schema items to fully support all static send port behaviours on dynamic send port&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;a href="https://sftpadapter.codeplex.com/releases/view/19784"&gt;Download it from Codeplex&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;I want to take this opportunity to thank Greg for his work, and also apologise for not getting this post up earlier…&lt;/p&gt;  &lt;p&gt;Greg started working in IT about 20 years ago in Auckland, New Zealand as a junior developer.&amp;#160; Eventually, he gained customer exposure doing on site system installations and upgrades. Having newly acquired soft skills, platform and development experience the next natural career move seemed to be system integration. This is the role he has filled for the past 15 or so years in varying capacities. 5 years ago he crossed the ditch with his wife to Sydney, Australia and now specialise in BizTalk development and implementation.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogical.se/blogs/mikael/logo-codeplex2_0F8D0E1F.png"&gt;&lt;img title="logo-codeplex2" style="border-top:0px;border-right:0px;background-image:none;border-bottom:0px;padding-top:0px;padding-left:0px;border-left:0px;display:inline;padding-right:0px;" border="0" alt="logo-codeplex2" src="http://blogical.se/blogs/mikael/logo-codeplex2_thumb_0EB738E6.png" width="244" height="89" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://blogical.se/aggbug.aspx?PostID=34125" width="1" height="1"&gt;</description><category domain="http://blogical.se/blogs/mikael/archive/tags/BizTalk/default.aspx">BizTalk</category><category domain="http://blogical.se/blogs/mikael/archive/tags/Sftp/default.aspx">Sftp</category><category domain="http://blogical.se/blogs/mikael/archive/tags/Codeplex/default.aspx">Codeplex</category></item><item><title>BizTalk Database Restore cmdlets – Now on Codeplex</title><link>http://blogical.se/blogs/mikael/archive/2014/02/09/biztalk-database-restore-cmdlets-now-on-codeplex.aspx</link><pubDate>Sun, 09 Feb 2014 21:21:00 GMT</pubDate><guid isPermaLink="false">19a535f3-07d9-4378-9c5a-8d019d91e842:34124</guid><dc:creator>wmmihaa</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;Since I published the powershell cmdlets to restore BizTalk databases I got plenty of feed-back and suggestions. Lately my new friend and colleague Farhan, found use for it and got started fixing a few bugs i had laying around.&lt;/p&gt;  &lt;p&gt;Now that it’s all up and running I thought it be a good idea to move in to &lt;a href="https://btsrestore.codeplex.com/"&gt;CodePlex&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogical.se/blogs/mikael/logo-codeplex2_29917396.png"&gt;&lt;img width="244" height="89" title="logo-codeplex2" style="border:0px currentColor;border-image:none;padding-top:0px;padding-right:0px;padding-left:0px;display:inline;background-image:none;" alt="logo-codeplex2" src="http://blogical.se/blogs/mikael/logo-codeplex2_thumb_7B3A7E99.png" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Thank you Farhan. &lt;/p&gt;&lt;img src="http://blogical.se/aggbug.aspx?PostID=34124" width="1" height="1"&gt;</description><category domain="http://blogical.se/blogs/mikael/archive/tags/BizTalk+Restore+Codeplex/default.aspx">BizTalk Restore Codeplex</category></item><item><title>Azure Mobile Services API support for Xamarin</title><link>http://blogical.se/blogs/mikael/archive/2013/11/01/azure-mobile-services-api-support-for-xamarin.aspx</link><pubDate>Fri, 01 Nov 2013 16:01:12 GMT</pubDate><guid isPermaLink="false">19a535f3-07d9-4378-9c5a-8d019d91e842:33993</guid><dc:creator>wmmihaa</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;This might be one of my shorter post, but I thought it was worth sharing. I’ve been working with a game lately and depend heavily on Azure Mobile Services. Microsoft has been kind enough to provide us with the &lt;a href="http://www.windowsazure.com/en-us/develop/mobile/" target="_blank"&gt;Azure Mobile Services&lt;/a&gt; for &lt;a href="http://xamarin.com/" target="_blank"&gt;Xamarin&lt;/a&gt;, which can be found &lt;a href="http://components.xamarin.com/view/azure-mobile-services" target="_blank"&gt;here&lt;/a&gt;. Sadly thought, it does not include support for API’s.&lt;/p&gt;  &lt;p&gt;You can do this:&lt;/p&gt;  &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;var&lt;/span&gt; profiles = App.MobileService.&lt;strong&gt;&lt;font style="background-color:#ffff00;"&gt;GetTable&lt;/font&gt;&lt;/strong&gt;&amp;lt;UserProfile&amp;gt;();&lt;/pre&gt;

&lt;p&gt;But you can’t do this:&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;var&lt;/span&gt; myProfile = App.MobileService.&lt;strong&gt;&lt;font style="background-color:#ffff00;"&gt;InvokeApiAsync&lt;/font&gt;&lt;/strong&gt;&amp;lt;UserProfile&amp;gt;(&lt;span class="str"&gt;&amp;quot;me&amp;quot;&lt;/span&gt;);&lt;/pre&gt;

&lt;p&gt;I find API’s much more useful the working with the tables, so I was bit bummed out when I found out it wasn’t supported. I solved this by simply using the &lt;a href="http://msdn.microsoft.com/en-us/library/system.net.http.httpclient%28v=vs.110%29.aspx" target="_blank"&gt;HttpClient&lt;/a&gt;&lt;em&gt;&lt;/em&gt; to make the calls to the API’s. However that didn’t work to good when enabling the authorization. &lt;/p&gt;

&lt;p&gt;It took a bit of work with fiddler to find our what headers needed to be used. So I updated the calls to include these headers:&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;HttpContent&lt;/span&gt; content = &lt;span class="kwrd"&gt;new&lt;/span&gt; StringContent(payload);
content.Headers.ContentType = &lt;span class="kwrd"&gt;new&lt;/span&gt; MediaTypeHeaderValue(&lt;span class="str"&gt;&amp;quot;application/json&amp;quot;&lt;/span&gt;);
content.Headers.Add(&lt;span class="str"&gt;&amp;quot;x-zumo-application&amp;quot;&lt;/span&gt;, Client.ApplicationKey);
content.Headers.Add(&lt;span class="str"&gt;&amp;quot;x-zumo-auth&amp;quot;&lt;/span&gt;, Client.CurrentUser.MobileServiceAuthenticationToken);

&lt;span class="kwrd"&gt;var&lt;/span&gt; response = await client.PostAsync(url, content);&lt;/pre&gt;

&lt;p&gt;That did the trick, and I could now call the API with the permissions != Everyone.&lt;/p&gt;

&lt;p&gt;- But I was still bothered by the lack of support for API’s, since that meant I couldn’t share my code across the platforms. Of course I could have used the HttpClient approach above with my Windows Phone clients, but that didn’t seem right.&lt;/p&gt;

&lt;p&gt;So I spent some time adding the missing InvokeApi* methods as &lt;a href="http://msdn.microsoft.com/en-us/library/vstudio/bb383977.aspx" target="_blank"&gt;Extension Methods&lt;/a&gt;. And you can download the code &lt;a href="http://blogical.se/files/folders/downloads/entry33992.aspx" target="_blank"&gt;here&lt;/a&gt;: &lt;/p&gt;

&lt;p&gt;To use it, simply download the MobileServiceClientExtensionMethods.cs file and add it to your project. You should update the namespace, and the just add the namespace in the using statement in the class where you want to make the call.&lt;/p&gt;

&lt;p&gt;HTH&lt;/p&gt;

&lt;p&gt;Mikael &lt;/p&gt;&lt;img src="http://blogical.se/aggbug.aspx?PostID=33993" width="1" height="1"&gt;</description><category domain="http://blogical.se/blogs/mikael/archive/tags/Azure/default.aspx">Azure</category><category domain="http://blogical.se/blogs/mikael/archive/tags/Xamarin/default.aspx">Xamarin</category><category domain="http://blogical.se/blogs/mikael/archive/tags/Azure+Mobile+Services/default.aspx">Azure Mobile Services</category></item><item><title>Securing Azure BizTalk Services using ADFS</title><link>http://blogical.se/blogs/mikael/archive/2013/09/01/securing-azure-biztalk-services-using-adfs.aspx</link><pubDate>Sun, 01 Sep 2013 12:27:00 GMT</pubDate><guid isPermaLink="false">19a535f3-07d9-4378-9c5a-8d019d91e842:33859</guid><dc:creator>wmmihaa</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;In all fairness, this post relates to Azure Service Bus in general and not specifically to Windows Azure BizTalk Services (WABS).&lt;/p&gt;  &lt;h2&gt;When is this relevant?&lt;/h2&gt;  &lt;p&gt;Azure Service Bus and WABS both rely on Azure Access Control Service (ACS) to authenticate users before calling the service. This type of authentication is often referred to as Federated Security. In most samples of how to interact with Service Bus or WABS, the client first calls ACS (using user name and password) to receive a token, which is later used upon calling the actual service.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogical.se/blogs/mikael/image_33B30636.png"&gt;&lt;img width="644" height="332" title="image" style="border-width:0px;padding-top:0px;padding-right:0px;padding-left:0px;display:inline;background-image:none;" alt="image" src="http://blogical.se/blogs/mikael/image_thumb_2B4F30DF.png" border="0" /&gt;&lt;/a&gt;&amp;nbsp;&lt;/p&gt;  &lt;p&gt;Using a ACS &lt;em&gt;Service Identity&lt;/em&gt; (service user) makes sense when the client is a system, where you’d probably let each system have its own &lt;em&gt;Service Identity. &lt;/em&gt;&lt;/p&gt;  &lt;p&gt;-But what if the client is a user, such an employee or customer, perhaps calling in from a mobile unit?&lt;/p&gt;  &lt;p&gt;In such cases, you’d have to keep the Service Identity stored on the device/application. Part from the security problems related to some evil person hacking the (Android) phone and then uses the credentials for evil purposes, you can’t do &lt;em&gt;Authorization&lt;/em&gt; as every user is using the same credentials.&lt;/p&gt;  &lt;p&gt;In such cases, you’d probably want to use some other directory than the one provided in ACS. In most cases Active Directory is likely to be the preferred choice.&amp;nbsp; &lt;/p&gt;  &lt;h2&gt;Authentication&lt;/h2&gt;  &lt;p&gt;&lt;em&gt;Token Based Authentication&lt;/em&gt; can be a bit hard to understand, so I’ll try to explain it using an analogy. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogical.se/blogs/mikael/image_43729B3A.png"&gt;&lt;img width="644" height="348" title="image" style="border-width:0px;padding-top:0px;padding-right:0px;padding-left:0px;display:inline;background-image:none;" alt="image" src="http://blogical.se/blogs/mikael/image_thumb_41C1CF66.png" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Imagine you’re going on a vacation to a different country, and upon facing the scary customs officer, you smile and give him your VISA card. Take my word for it, it won’t work, but the interesting part is why. Despite the anger he or she will direct towards you, i’s not about you at all. In fact, they will never trust YOU! &lt;/p&gt;  &lt;p&gt;-The problem is that they don’t trust the VISA organization to vouch for your identity.&lt;/p&gt;  &lt;p&gt;So we need to go to a trusted authority and ask them to vouch for our identity, in Sweden that would be the local police department. They won’t trust you either, and will ask for some other proof, but more on that later. Let’s just assume all goes well and they’ll issue you a passport.&amp;nbsp; &lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogical.se/blogs/mikael/image_6E6A893F.png"&gt;&lt;img width="644" height="451" title="image" style="border-width:0px;padding-top:0px;padding-right:0px;padding-left:0px;display:inline;background-image:none;" alt="image" src="http://blogical.se/blogs/mikael/image_thumb_457F7436.png" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;The passport holds information about you, some information is public others may be hidden or encrypted, but more importantly it is signed by a trusted authority.&lt;/p&gt;  &lt;p&gt;With a passport in our hand, the officer now trust your identity (&lt;strong&gt;Authentication&lt;/strong&gt;), and he will now proceed to check your criminal records and ask a bunch of questions to determine if he will allow you to enter the country (&lt;strong&gt;Authorization&lt;/strong&gt;).&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogical.se/blogs/mikael/image_3CAF6BEA.png"&gt;&lt;img width="644" height="399" title="image" style="border-width:0px;padding-top:0px;padding-right:0px;padding-left:0px;display:inline;background-image:none;" alt="image" src="http://blogical.se/blogs/mikael/image_thumb_505C557E.png" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Leaving the analogy and getting back to &lt;em&gt;Federated Security&lt;/em&gt;. It’s pretty much the same thing. The Swedish Police department plays the role of the &lt;em&gt;Issuer &lt;/em&gt;(ACS) the customs officer plays the role of the &lt;em&gt;Relying Party Application &lt;/em&gt;(WABS or Service Bus), and the passport is of course the &lt;em&gt;Token&lt;/em&gt;.&lt;/p&gt;  &lt;p&gt;The difference between the analogy and Service Bus authentication, is that while the customs trust many different issuers, Windows Azure Service Bus ONLY TRUST ACS!&lt;/p&gt;  &lt;p&gt;However, ACS can be configured to trust other issuers also referred to as &lt;em&gt;Identity Providers.&lt;/em&gt; If we go back to the analogy, and the local Police department that issued the passport, –why did he trust you? There are actually a number of ways to prove your identity, but lets assume you’d use an ID. This is sometime referred to as a &lt;em&gt;chain of trust.&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;This is how Active Directory come in play. Active Directory can be configured with &lt;em&gt;Active Directory Federated Services&lt;/em&gt; (ADFS). ADFS is an issuer, and although Service Bus does not trust your ADFS, ACS can be trusted to do.&lt;/p&gt;  &lt;p&gt;By adding your ADFS as an &lt;em&gt;Identity Provider &lt;/em&gt;in ACS, you can authenticate yourself with ACS using a token provided by ADFS! ACS will then provide you with a new token which can be used to authenticate yourself with Service Bus.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogical.se/blogs/mikael/image_7DFAA8FB.png"&gt;&lt;img width="644" height="317" title="image" style="border-width:0px;padding-top:0px;padding-right:0px;padding-left:0px;display:inline;background-image:none;" alt="image" src="http://blogical.se/blogs/mikael/image_thumb_1C64E9E5.png" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Step 1: Ask ADFS to issue a token for ACS using Active Directory user name and password.&lt;/p&gt;  &lt;p&gt;Step 2: Ask ACS to issue a token for SB, using a token issued by ADFS&lt;/p&gt;  &lt;p&gt;Step 3: Call the service using the token provided by ACS.&lt;/p&gt;  &lt;h2&gt;Authorization&lt;/h2&gt;  &lt;p&gt;Although it won’t be sufficient for us, it’s worth pointing out that ACS provides some level of authorization which you can read more about &lt;a href="http://msdn.microsoft.com/en-us/library/windowsazure/hh403962.aspx"&gt;here&lt;/a&gt;. ACS can however not provide authorization based on AD group membership, as the group membership claim comes as a comma separated string, with all groups:&lt;/p&gt;  &lt;p&gt;Eg: &lt;strong&gt;CN=Sales,CN=Employees,…,…,…,…,…,…,…,CN=Users,DC=MyDomain,DC=net&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Before we dive into &lt;em&gt;BizTalk Services&lt;/em&gt; I’d like to point out a couple “issues” you might encounter. In the case where your service is a REST service (such as with WABS), you’ll face two problems, one small and one big. Both problems relates to the fact that Service Bus will remove your token after the token has been verified by Service Bus. In other words, the token is not for you!&lt;/p&gt;  &lt;p&gt;This little problem can be worked around, by adding the token twice. One using the “Authorization” header, and the other using a custom header.&lt;/p&gt;  &lt;p&gt;The potentially bigger issue relates to the HTTP header it self, or rather its size. Using IIS 7 that limit is 16KB, but might differ depending on the version of IIS. By propagating the group membership claims from ADFS to the token issued by ACS, the token can get pretty big (depending of the number of groups the user is a member of). Adding the token twice, and you might pass the limit. The good news is that this limit is configurable, but the problem can be difficult to identify, as it might not occur for all users.&lt;/p&gt;  &lt;p&gt;Anyway, by adding the token twice we can now evaluate group membership and authorize the user within our service (SB) or itinerary (WABS).&lt;/p&gt;  &lt;h2&gt;The Setup&lt;/h2&gt;  &lt;p&gt;The setup involves many steps, some of witch I’ll assume you have already done. For instance, it’s outside the scope of this post to set up ADFS and install the WABS SDK.&lt;/p&gt;  &lt;h3&gt;1. The Itinerary &lt;/h3&gt;  &lt;p&gt;As the overall sample is complicated enough, we’ll stick with a very simple itinerary .&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogical.se/blogs/mikael/image_1B8C83FB.png"&gt;&lt;img width="644" height="416" title="image" style="border-width:0px;padding-top:0px;padding-right:0px;padding-left:0px;display:inline;background-image:none;" alt="image" src="http://blogical.se/blogs/mikael/image_thumb_1F2A9ED8.png" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;The itinerary received the message using a One-Way bridge, and routs the message to either one of the queues, depending on if the user is part of any of the groups.&lt;/p&gt;  &lt;h3&gt;&lt;/h3&gt;  &lt;h3&gt;2. Extracting the HTTP Custom Header&lt;/h3&gt;  &lt;p&gt;As described earlier, we need to add the token twice. Once for the Service Bus to do Authentication, and the other for us to do Authorization. To do this, double-click the One-Way bridge to open the bridge configuration.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogical.se/blogs/mikael/image_3A62F7D9.png"&gt;&lt;img width="644" height="364" title="image" style="border-width:0px;padding-top:0px;padding-right:0px;padding-left:0px;display:inline;background-image:none;" alt="image" src="http://blogical.se/blogs/mikael/image_thumb_2A078020.png" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Select any of the two &lt;em&gt;Enrish &lt;/em&gt;stages, and click the &lt;em&gt;Property Definition&lt;/em&gt; in the Property Window. Add a new property definition, and set the values as following:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogical.se/blogs/mikael/image_1AF0A146.png"&gt;&lt;img width="644" height="393" title="image" style="border-width:0px;padding-top:0px;padding-right:0px;padding-left:0px;display:inline;background-image:none;" alt="image" src="http://blogical.se/blogs/mikael/image_thumb_616D914E.png" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;I will call my custom header “AUTH”, if you care to use a different name, just change the &lt;em&gt;Identifier&lt;/em&gt; to what ever work for you.&lt;/p&gt;  &lt;h3&gt;3. Create a Message Inspector&lt;/h3&gt;  &lt;p&gt;Now that we have the token, we need to extract the group claim. To do this we’ll need to create a &lt;em&gt;Message Inspector.&lt;/em&gt;&amp;nbsp;&lt;/p&gt;  &lt;p&gt;Follow these steps to create your project:&lt;a title="http://msdn.microsoft.com/en-us/library/windowsazure/dn232389.aspx" href="http://msdn.microsoft.com/en-us/library/windowsazure/dn232389.aspx"&gt;http://msdn.microsoft.com/en-us/library/windowsazure/dn232389.aspx&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Here is the code I used:&lt;/p&gt;  &lt;p&gt;&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; AuthorizationInspector : IMessageInspector 
{
    &lt;span class="kwrd"&gt;const&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; GROUPCLAIM = &lt;span class="str"&gt;&amp;quot;http://schemas.xmlsoap.org/claims/Group&amp;quot;&lt;/span&gt;;

    &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;
    &lt;span class="rem"&gt;/// The name of the custom HTTP header, Eg. &amp;quot;AUTH&amp;quot;&lt;/span&gt;
    &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;
    [PipelinePropertyAttribute(Name = &lt;span class="str"&gt;&amp;quot;AuthToken&amp;quot;&lt;/span&gt;)]
    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; AuthToken { &lt;span class="kwrd"&gt;get&lt;/span&gt;; &lt;span class="kwrd"&gt;set&lt;/span&gt;; }
    &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;
    &lt;span class="rem"&gt;/// A comma separated list of authorized groups, Eg. Sales, Marketing &lt;/span&gt;
    &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;
    [PipelinePropertyAttribute(Name = &lt;span class="str"&gt;&amp;quot;InGroups&amp;quot;&lt;/span&gt;)]
    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; InGroups { &lt;span class="kwrd"&gt;get&lt;/span&gt;; &lt;span class="kwrd"&gt;set&lt;/span&gt;; }
        
    &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;
    &lt;span class="rem"&gt;/// Processesing the Message&lt;/span&gt;
    &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;
    &lt;span class="rem"&gt;/// &amp;lt;param name=&amp;quot;message&amp;quot;&amp;gt;&amp;lt;/param&amp;gt;&lt;/span&gt;
    &lt;span class="rem"&gt;/// &amp;lt;param name=&amp;quot;context&amp;quot;&amp;gt;&amp;lt;/param&amp;gt;&lt;/span&gt;
    &lt;span class="rem"&gt;/// &amp;lt;returns&amp;gt;&amp;lt;/returns&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;public&lt;/span&gt; Task Execute(IMessage message, IMessageInspectorContext context)
    {
        &lt;span class="kwrd"&gt;bool&lt;/span&gt; isInGroup;
        &lt;span class="kwrd"&gt;try&lt;/span&gt;
        {
            &lt;span class="rem"&gt;// Get the incomming SWT token&lt;/span&gt;
            &lt;span class="kwrd"&gt;var&lt;/span&gt; token = message.GetPromotedProperty(AuthToken);

            &lt;span class="kwrd"&gt;if&lt;/span&gt; (token == &lt;span class="kwrd"&gt;null&lt;/span&gt;)
                &lt;span class="kwrd"&gt;throw&lt;/span&gt; &lt;span class="kwrd"&gt;new&lt;/span&gt; Exception(AuthToken + &lt;span class="str"&gt;&amp;quot; token is null&amp;quot;&lt;/span&gt;);

            &lt;span class="kwrd"&gt;var&lt;/span&gt; requestedGroups = InGroups.Split(&lt;span class="str"&gt;&amp;#39;,&amp;#39;&lt;/span&gt;);
            &lt;span class="kwrd"&gt;var&lt;/span&gt; claims = GetClaims(token.ToString());
                
            &lt;span class="kwrd"&gt;var&lt;/span&gt; groups = (&lt;span class="kwrd"&gt;from&lt;/span&gt; c &lt;span class="kwrd"&gt;in&lt;/span&gt; claims[GROUPCLAIM].Split(&lt;span class="str"&gt;&amp;#39;,&amp;#39;&lt;/span&gt;)
                            select &lt;span class="kwrd"&gt;new&lt;/span&gt; GroupEntry(c)).Where(g =&amp;gt; g.Type == &lt;span class="str"&gt;&amp;quot;CN&amp;quot;&lt;/span&gt;);

            &lt;span class="kwrd"&gt;var&lt;/span&gt; isingroup = groups.Where(g =&amp;gt; requestedGroups.Count(r =&amp;gt; r == g.Name) &amp;gt; 0);

            &lt;span class="kwrd"&gt;return&lt;/span&gt; Task.Factory.StartNew(() =&amp;gt;
            {
                message.Promote(&lt;span class="str"&gt;&amp;quot;IsInGroup&amp;quot;&lt;/span&gt;, isingroup.Count() &amp;gt; 0);
            });

        }
        &lt;span class="kwrd"&gt;catch&lt;/span&gt; (Exception ex)
        {
            &lt;span class="kwrd"&gt;throw&lt;/span&gt; ex;
        }
    }
}&lt;/pre&gt;

&lt;p&gt;&lt;em&gt;* The GetClaims method and the GroupEntry class is part of the downloadable sample…&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Compile your project. and go back to your Bridge configuration. Select the &lt;em&gt;Enrich&lt;/em&gt; stage again (outer rim) and click the &lt;em&gt;On Exit Inspector&lt;/em&gt; in the property window.&lt;/p&gt;

&lt;p&gt;Type the FQN of your Inspector class in the Type field, Eg:&lt;/p&gt;

&lt;p&gt;InspectorsLibrary.AuthorizationInspector, InspectorsLibrary, Version=1.0.0.0, Culture=neutral, PublicKeyToken=a1cd373975c6a197&lt;/p&gt;

&lt;p&gt;&amp;nbsp;&lt;/p&gt;

&lt;p&gt;&amp;nbsp;&lt;a href="http://blogical.se/blogs/mikael/image_67B467DC.png"&gt;&lt;img width="597" height="484" title="image" style="border-width:0px;padding-top:0px;padding-right:0px;padding-left:0px;display:inline;background-image:none;" alt="image" src="http://blogical.se/blogs/mikael/image_thumb_193FD572.png" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Our newly created Inspector had two properties: &lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;AuthToken – The name of the custom token we’ll use &lt;/li&gt;

  &lt;li&gt;InGroups – The authorized groups Eg: &lt;em&gt;Sales,Marketing,Finance&lt;/em&gt; &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Build and deploy your bridge.&lt;/p&gt;

&lt;h3&gt;4. Configure ADFS to issue tokens for ACS&lt;/h3&gt;

&lt;p&gt;Open the &lt;a href="https://manage.windowsazure.com"&gt;Azure Management Portal&lt;/a&gt;, and browse to the Active directory. Select the namespace you’re using for WABS, and select &lt;em&gt;Manage &lt;/em&gt;to open the ACS portal. At the bottom of the navigation field, click &lt;em&gt;Application Integration&lt;/em&gt;, and copy the &lt;em&gt;WS-Federation Metadata&lt;/em&gt; URI. This file includes the Realm(s) of the ACS along with public keys etc, needed to configure the &lt;em&gt;Relying Party Trust&lt;/em&gt; in ADFS.&lt;/p&gt;

&lt;p&gt;Next open the ADFS Manager, and browse to the &lt;em&gt;Relying Party Trust &lt;/em&gt;node. Right click the node and select &lt;em&gt;Add Relying Party Trust… &lt;/em&gt;and click the &lt;em&gt;Start&lt;/em&gt; button.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://blogical.se/blogs/mikael/image_5F509285.png"&gt;&lt;img width="600" height="484" title="image" style="border-width:0px;padding-top:0px;padding-right:0px;padding-left:0px;display:inline;background-image:none;" alt="image" src="http://blogical.se/blogs/mikael/image_thumb_7E933958.png" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Keep the “Import data about…” option, and paste in the ACS &lt;em&gt;WS-Federation Metadata&lt;/em&gt; URI. Click &lt;em&gt;Next&lt;/em&gt; *4 and &lt;em&gt;Finish &lt;/em&gt;(leave the checkbox to open the claims configuration).&lt;/p&gt;

&lt;p&gt;In the &lt;em&gt;Edit Rule &lt;/em&gt;dialog, click &lt;em&gt;Add Rule,&lt;/em&gt; and &lt;em&gt;Next. &lt;/em&gt;Give it a name and set the Attribute Store to Active Directory.&lt;/p&gt;

&lt;p&gt;Select the “Is-Member-Of-DL” attribute and map it to the &lt;em&gt;Groups &lt;/em&gt;claim.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://blogical.se/blogs/mikael/image_592945EA.png"&gt;&lt;img width="456" height="484" title="image" style="border-width:0px;padding-top:0px;padding-right:0px;padding-left:0px;display:inline;background-image:none;" alt="image" src="http://blogical.se/blogs/mikael/image_thumb_5CC760C7.png" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Click &lt;em&gt;Ok.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;In the ADFS Manager, browse to the &lt;em&gt;“Endpoints” &lt;/em&gt;node&lt;em&gt;. &lt;/em&gt;Make sure the &lt;em&gt;usernamemixed &lt;/em&gt;endpoint is enabled. Also make a note of the URI together with the &lt;em&gt;FederationMetadata &lt;/em&gt;URI.&lt;/p&gt;

&lt;h3&gt;5. Adding ADFS Identity Provider in ACS&lt;/h3&gt;

&lt;p&gt;Go back to the ACS portal, and click &lt;em&gt;Identity Providers&lt;/em&gt;. Click &lt;em&gt;Add&lt;/em&gt; and select &lt;em&gt;WS-Federation identity provider &lt;/em&gt;and &lt;em&gt;Next.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Give it a name and set the login text (although will never use it). Paste or type the URI to the ADFS FederationMetadata. I ran into some problems here, and needed to copy it locally, and add it using the &lt;em&gt;Browse&lt;/em&gt; option.&lt;em&gt;&amp;nbsp;&lt;/em&gt;This file includes all configured claims from ADFS (among many other things).&amp;nbsp; &lt;/p&gt;

&lt;p&gt;In the &lt;em&gt;Used By&lt;/em&gt; section, deselect all applications but your WABS application.&lt;/p&gt;

&lt;p&gt;To propagate claims from the ADFS token to the ACS token, we need to do one more step. Click the &lt;em&gt;Relying Party Application &lt;/em&gt;node, and select your WABS application. At the bottom of the page, click the selected &lt;em&gt;Rule Group&lt;/em&gt;. Click the &lt;em&gt;Generate&lt;/em&gt; button, and select your new &lt;em&gt;Identity Provider. Click &lt;/em&gt;Save.&lt;/p&gt;

&lt;h3&gt;6. Try it out!&lt;/h3&gt;

&lt;p&gt;Kudos to you if you made it this far!&lt;/p&gt;

&lt;p&gt;If you download the sample, you’ll find the MessageSender project which I originally got from &lt;a href="http://code.msdn.microsoft.com/windowsazure/Windows-Azure-BizTalk-EAI-af9bc99f/sourcecode?fileId=83175&amp;amp;pathId=27530299"&gt;here&lt;/a&gt;. I’ve made some modifications to make it work with ADFS. It generally comes down to two methods at the end of the MessageSender class.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;RequestSamlToken – Uses a WSTrust channel to get the SAML token from ADFS. &lt;/li&gt;

  &lt;li&gt;RequestSwtWithSamlToken – Similar to the GetAcsToken method, but uses assertion to pass along the SAML token rather then username/password as with the GetAcsToken. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="http://blogical.se/files/folders/downloads/entry33858.aspx" target="_blank"&gt;&lt;img width="240" height="81" title="image" style="border-width:0px;padding-top:0px;padding-right:0px;padding-left:0px;display:inline;background-image:none;" alt="download sample" src="http://blogical.se/blogs/mikael/image_50C57093.png" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&amp;nbsp;&lt;/p&gt;

&lt;h1&gt;Related links:&lt;/h1&gt;

&lt;p&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/windowsazure/jj136813.aspx" target="_blank"&gt;Federated Authentication for Azure Service Bus&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="http://www.windowsazure.com/en-us/services/messaging/" target="_blank"&gt;Azure Service Bus&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="http://www.windowsazure.com/en-us/services/biztalk-services/" target="_blank"&gt;BizTalk Services&lt;/a&gt;&lt;/p&gt;&lt;img src="http://blogical.se/aggbug.aspx?PostID=33859" width="1" height="1"&gt;</description><category domain="http://blogical.se/blogs/mikael/archive/tags/BizTalk/default.aspx">BizTalk</category><category domain="http://blogical.se/blogs/mikael/archive/tags/Azure/default.aspx">Azure</category><category domain="http://blogical.se/blogs/mikael/archive/tags/ServiceBus/default.aspx">ServiceBus</category><category domain="http://blogical.se/blogs/mikael/archive/tags/ADFS/default.aspx">ADFS</category><category domain="http://blogical.se/blogs/mikael/archive/tags/ACS/default.aspx">ACS</category><category domain="http://blogical.se/blogs/mikael/archive/tags/BizTalk+Services/default.aspx">BizTalk Services</category></item><item><title>REST Start Kit for BizTalk Server</title><link>http://blogical.se/blogs/mikael/archive/2012/05/28/rest-start-kit-for-biztalk-server.aspx</link><pubDate>Sun, 27 May 2012 22:45:00 GMT</pubDate><guid isPermaLink="false">19a535f3-07d9-4378-9c5a-8d019d91e842:29877</guid><dc:creator>wmmihaa</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;The &lt;a href="http://biztalkrest.codeplex.com/" target="_blank"&gt;REST Start Kit for BizTalk Server&lt;/a&gt; is about providing support for GET, POST, PUT and DELETE operation, for both Receive and Send ports together with support for both XML and JSON.&lt;/p&gt;
&lt;p&gt;In a former &lt;a href="http://blogical.se/blogs/mikael/default.aspx" target="_blank"&gt;post&lt;/a&gt;, I showed how to expose REST services from BizTalk. However I never got it to work for GET operations and did not cover consuming other REST services through Send Ports. Consuming REST services was however greatly covered by &lt;a href="http://social.technet.microsoft.com/profile/nitin%20mehrotra_msft/" target="_blank"&gt;Nitin Mehrotra&lt;/a&gt; in his post “&lt;a href="http://social.technet.microsoft.com/wiki/contents/articles/2474.invoke-restful-web-services-with-biztalk-server-2010.aspx" target="_blank"&gt;Invoke ReSTful Web Services with BizTalk Server 2010&lt;/a&gt;”. In fact I’ve included Nitins code in this solution to compete the REST Start Kit for BizTalk Server.&lt;/p&gt;
&lt;h2&gt;Is this post interesting to me?&lt;/h2&gt;
&lt;p&gt;We are seeing a broader diversity among clients, hosted on various smart devices, running on different runtimes. Commonly among all these, is that applications are becoming commodity with a relatively short life-cycle. These applications needs to be rapidly developed using frameworks that can be re-used on other platforms. These and other factors are reasons we see a broad adoption of HTML5 and JavaScript today.&lt;/p&gt;
&lt;p&gt;When developing these kind of applications, REST-based services are the preferred choice by far. Not only because it’s easy to consume using JQuery (resource orientated JavaScript library), but equally important is the fact that REST is lightweight. -Bandwidth is not infinite on mobile devices!&lt;/p&gt;
&lt;p&gt;Is this important to BizTalk? Yes it is! BizTalk Server is Microsoft’s middleware platform. And as such it should manage REST. Arguably, many web-based application are built together with the service layer in the same application. But what happens when the client needs to access a back-end system like SAP or Oracle EBS? BizTalk can handle these with ease, however it can’t bridge them to REST.&amp;nbsp; &lt;/p&gt;
&lt;p&gt;I’ve tried my best to make the start kit easy to use. However I do realize that many of the topics mentioned in the post are outside the comfort zone for many. But if you only care about HOW to use it, just skip the “How it works” section of the post.&lt;/p&gt;
&lt;h2&gt;What is REST?&lt;/h2&gt;
&lt;p&gt;I assume you already know what REST is, but never the less… Representational state transfer (REST) is a light weight protocol introduced by &lt;a href="http://en.wikipedia.org/wiki/Roy_Fielding" target="_blank"&gt;Roy Fielding&lt;/a&gt; around the year 2000. REST exposes services over HTTP, and can receive the request either through the URI, as in the case of a GET or DELETE operation, or through the payload (POST and PUT). &lt;/p&gt;
&lt;p&gt;HTTP verbs are essential to REST, as REST is focused on entities or resources. For instance, you wouldn’t expose a DeleteCustomerOrder method using REST. Instead you’d let the client access your recourses using the URI, Eg http://somedomain.com/Customers(1234)/Orders. If the user was to delete an Order (with an id of 5678), he or she would call http://somedomain.com/Customers(1234)/Orders(5678) using the HTTP DELETE verb. Using the GET verb, would return the actual order (given that it was not already deleted). If the resource was deleted (or never created), the user should receive a &lt;a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html" target="_blank"&gt;404 status code&lt;/a&gt;. &lt;/p&gt;
&lt;p&gt;POST (and PUT) works a bit different, as it receives it’s request through the payload. This behavior is similar to SOAP (which only uses POST), however REST does not require a specific format (as opposed to SOAP which uses the SOAP envelope). In fact, you don’t even have to use XML. Arguably, most clients call REST services using the JSON format.&lt;/p&gt;
&lt;p&gt;If you don’t know about JSON, it’s a lightweight data format, commonly used by JavaScript and JQuery. Part from being less verbose then XML, it can be parsed to an object on the client which makes it easier to navigate (as oppose to using XPath). &lt;/p&gt;
&lt;p&gt;As such, REST is all about HTTP, and works very much like the architectural principles of the &lt;a href="http://en.wikipedia.org/wiki/World_Wide_Web" target="_blank"&gt;World Wide Web&lt;/a&gt;. This is not an accident, as Roy Fielding was one of the principal authors of the &lt;a href="http://en.wikipedia.org/wiki/HTTP" target="_blank"&gt;HTTP&lt;/a&gt; specification.&lt;/p&gt;
&lt;p&gt;Many more things could (and should) be said about REST (and RESTFul services), but this is not the place. However, it’s important to point out the challenges we face using BizTalk:&lt;/p&gt;
&lt;h3&gt;1. BizTalk requires a Message!&lt;/h3&gt;
&lt;p&gt;This is somewhat problematic as all parameters for a GET or DELETE request is passed along with the URI, not the payload. Because of this, we need to intercept the request and create a “real” message using the parameters passed on by the URI. Using a dynamic URI’s reveals yet an other challenge, as URI’s are generally of a static nature for BizTalk. This is where the &lt;a href="http://msdn.microsoft.com/en-us/library/system.servicemodel.webhttpbinding.aspx" target="_blank"&gt;WebHttpBinding&lt;/a&gt; comes in to place, as it let’s us define a base URI which our service (Receive Location) will listen to, regardless of what proceeds the base URI, Eg http://somedomamin.com/&lt;font style="BACKGROUND-COLOR:#ffff00;"&gt;Customers(1234)&lt;/font&gt;&lt;/p&gt;
&lt;h3&gt;2. BizTalk only accepts POST!&lt;/h3&gt;
&lt;p&gt;This was the most difficult problem to solve, and I’ll get more into detail on this later. But the basic principle is that upon creating the message described before, it will add necessary meta data to the message to let BizTalk think this is a POST message. &lt;/p&gt;
&lt;h3&gt;3. BizTalk only understand XML!&lt;/h3&gt;
&lt;p&gt;If the consumer sends a GET request to the service, it also passes along information in the HTTP header, letting us know what format is expected. This is done through the “Accept” header, and could be either “application/xml” or “application/json” (there are others, but xml and json are the only supported ones using the REST Start Kit). &lt;/p&gt;
&lt;p&gt;In case of a GET request, the outgoing message will get converted from XML to JSON using &lt;a href="http://json.codeplex.com/" target="_blank"&gt;JSON.Net&lt;/a&gt;. If the consumer sends a POST request, the header could state: &lt;em&gt;Content-Type: application/json&lt;/em&gt;. If this is the case, the incoming request will also be converted.&lt;/p&gt;
&lt;h2&gt;How it works&lt;/h2&gt;
&lt;p&gt;To make use of the &lt;em&gt;REST Start Kit for BizTalk&lt;/em&gt; you need to expose your service or consume another REST service using the &lt;strong&gt;WCF-Custom&lt;/strong&gt; adapter with the binding set to &lt;a href="http://msdn.microsoft.com/en-us/library/system.servicemodel.webhttpbinding.aspx" target="_blank"&gt;WebHttpBinding&lt;/a&gt;. In addition to selecting the binding, you also need to add a behavior; &lt;em&gt;BizTalkRESTRequestHandler&lt;/em&gt; for the Receive Location and &lt;em&gt;BizTalkRESTTransmitHandler&lt;/em&gt; for the Send port. These behaviors takes care of underlying pluming needed to make BizTalk accept REST based messages. This is all you have to do.&lt;/p&gt;
&lt;h3&gt;Exposing REST services (Receive Locations)&lt;/h3&gt;
&lt;h4&gt;GET and DELETE&lt;/h4&gt;
&lt;p&gt;Regardless of what HTTP verb is used, BizTalk only exposes one usable method, – the “TwoWayMethod”. This is because BizTalk does not really care about the actual message until it hits the pipeline. The &lt;em&gt;TwoWayMethod &lt;/em&gt;does however care about the &lt;a href="http://msdn.microsoft.com/en-us/library/system.servicemodel.channels.httprequestmessageproperty.method.aspx" target="_blank"&gt;HttpRequestMessageProperty.Method&lt;/a&gt; to be “POST”.&lt;/p&gt;
&lt;p&gt;In order to send anything but a POST request to BizTalk, we need to intercept the message and convert it to a POST, or create a new message (GET &amp;amp; DELETE) and set the &lt;a href="http://msdn.microsoft.com/en-us/library/system.servicemodel.channels.httprequestmessageproperty.method.aspx" target="_blank"&gt;HttpRequestMessageProperty.Method&lt;/a&gt; to “POST”. This action needs to be done in the &lt;em&gt;SelectOperation&lt;/em&gt; method of an &lt;a href="http://msdn.microsoft.com/en-us/library/system.servicemodel.dispatcher.idispatchoperationselector.aspx" target="_blank"&gt;IDispatchOperationSelector&lt;/a&gt; behavior. As we need to use the &lt;em&gt;WebHttpBinding&lt;/em&gt;, the behavior I’ve created inherits from &lt;a href="http://msdn.microsoft.com/en-us/library/system.servicemodel.dispatcher.webhttpdispatchoperationselector.aspx" target="_blank"&gt;WebHttpDispatchOperationSelector&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;As said before, a GET or DELETE request passes it’s parameters through the URI. You may have a base URI (declared on the Receive Location) set to &lt;strong&gt;http://localhost:8080/MyService &lt;/strong&gt;while the consumer may call your service using &lt;strong&gt;http://localhost:8080/MyService/&lt;font style="BACKGROUND-COLOR:#ffff00;"&gt;Bookings/2012/11&lt;/font&gt;&lt;/strong&gt;, expecting all bookings from November 2012. I this case the &lt;em&gt;BizTalkRESTRequestHandler&lt;/em&gt; behavior parses the URI and passes a &lt;em&gt;BizTalkWebHttpRequest&lt;/em&gt; message to BizTalk that would look like this:&lt;/p&gt;&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;ns0:bizTalkWebHttpRequest&lt;/span&gt; 
  &lt;span class="attr"&gt;method&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;GET&amp;quot;&lt;/span&gt; 
  &lt;span class="attr"&gt;xmlns:ns0&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;http://bLogical.RESTSchemas.BizTalkWebHttpRequest/1.0&amp;quot;&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;ns0:params&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;ns0:param&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;font style="BACKGROUND-COLOR:#ffff00;"&gt;2012&lt;/font&gt;&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;ns0:param&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;ns0:param&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;font style="BACKGROUND-COLOR:#ffff00;"&gt;11&lt;/font&gt;&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;ns0:param&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;ns0:params&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;ns0:bizTalkWebHttpRequest&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;On the other hand, the user might use a bit more complex URI such as: &lt;strong&gt;http://localhost:8080/MyService/&lt;font style="BACKGROUND-COLOR:#ffff00;"&gt;Employees?firstname=Caren&amp;amp;lastname=Smith&lt;/font&gt;&lt;/strong&gt;&amp;nbsp;&amp;nbsp; &lt;/p&gt;
&lt;p&gt;In this case you need to instruct the behavior how to parse the URI. If you’ve ever created a REST service using only WCF, you’re probably familiar to the &lt;a href="http://msdn.microsoft.com/en-us/library/system.uritemplate.aspx"&gt;UriTemplate class&lt;/a&gt;, which is also used with the &lt;em&gt;BizTalkRESTRequestHandler&lt;/em&gt; behavior. In the sample above, the UriTemplate could be:&amp;nbsp; &lt;br /&gt;&lt;font face="Courier New"&gt;&lt;font size="3"&gt;Employees?firstname=&lt;strong&gt;&lt;font style="BACKGROUND-COLOR:#ffff00;"&gt;{fname}&lt;/font&gt;&lt;/strong&gt;&amp;amp;lastname=&lt;strong&gt;&lt;font style="BACKGROUND-COLOR:#ffff00;"&gt;{lname}&lt;/font&gt;&lt;/strong&gt;&lt;/font&gt;&lt;/font&gt;&amp;nbsp; &lt;/p&gt;
&lt;p&gt;Which in turn would give you &lt;em&gt;BizTalkWebHttpRequest&lt;/em&gt; looking like this:&lt;/p&gt;&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;ns0:bizTalkWebHttpRequest&lt;/span&gt; 
  &lt;span class="attr"&gt;method&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;GET&amp;quot;&lt;/span&gt; 
  &lt;span class="attr"&gt;xmlns:ns0&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;http://bLogical.RESTSchemas.BizTalkWebHttpRequest/1.0&amp;quot;&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;ns0:params&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;ns0:param&lt;/span&gt; &lt;font style="BACKGROUND-COLOR:#ffff00;"&gt;&lt;span class="attr"&gt;name&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;fname&amp;quot;&lt;/span&gt;&lt;/font&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;Caren&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;ns0:param&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;ns0:param&lt;/span&gt; &lt;font style="BACKGROUND-COLOR:#ffff00;"&gt;&lt;span class="attr"&gt;name&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;lname&amp;quot;&lt;/span&gt;&lt;/font&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;Smith&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;ns0:param&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;ns0:params&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;ns0:bizTalkWebHttpRequest&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;Lastly, if the consumer requires an XML formatted response, the response from BizTalk will be sent straight back to the consumer. However, if the user expects JSON, the response need to be parsed. The DispatchOperationSelector behavior, described above, is only executed on the incoming request, so we need to add an other behavior, –a &lt;a href="http://msdn.microsoft.com/en-us/library/system.servicemodel.dispatcher.idispatchmessageinspector.aspx" target="_blank"&gt;IDispatchMessageInspector&lt;/a&gt; to handle the outgoing response. This behavior is called &lt;em&gt;BizTalkREST&lt;strong&gt;Response&lt;/strong&gt;Handler&lt;/em&gt; and is added by the &lt;em&gt;BizTalkRESTRequestHandler&lt;/em&gt;. In that sense it’s internal and never exposed to you. Never the less, an IDispatchMessageInspector exposes two methods; &lt;em&gt;AfterReceiveRequest&lt;/em&gt; and &lt;em&gt;BeforeSendReply. &lt;/em&gt;The incoming header is added to the operation context in the&amp;nbsp; &lt;em&gt;AfterReceiveRequest&lt;/em&gt; method, and if the “Accept” parameter is set to “application/json”, the response is converted to JSON and sent back, along with the &lt;a href="http://msdn.microsoft.com/en-us/library/system.servicemodel.channels.webbodyformatmessageproperty.aspx" target="_blank"&gt;WebBodyFormatMessageProperty&lt;/a&gt; set to &lt;a href="http://msdn.microsoft.com/en-us/library/system.servicemodel.channels.webcontentformat.aspx" target="_blank"&gt;WebContentFormat.Json&lt;/a&gt;. &lt;/p&gt;
&lt;h4&gt;PUT and POST&lt;/h4&gt;
&lt;p&gt;If the client sends a POST or PUT request with a content type set to “application/xml”, nothing is done but passing the message to BizTalk. Only it the content type is set to “application/json”, it is then parsed to XML using JSON.Net. If you expect a message to match a BizTalk generated schema like this:&lt;/p&gt;&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;ns0:Tweet&lt;/span&gt; &lt;span class="attr"&gt;xmlns:ns0&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;http://yourns.Tweet&amp;quot;&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;Author&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;wmmihaa&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Author&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;Text&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;XML Rocks!&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Text&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;ns0:Tweet&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;…the JSON message needs to included the namespace as:&lt;/p&gt;
&lt;p&gt;&lt;b&gt;{&amp;quot;ns0:Tweet&amp;quot;:{&amp;quot;&lt;font style="BACKGROUND-COLOR:#ffff00;"&gt;@xmlns:ns0&amp;quot;:&amp;quot;http://yourns.Tweet&lt;/font&gt;&amp;quot;,&amp;quot;Author&amp;quot;:&amp;quot;wmmihaa&amp;quot;,&amp;quot;Text&amp;quot;:&amp;quot;XML Rocks!&amp;quot;}}&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;Also, all JSON properties will be parsed as Xml Elements, not Attributes!&lt;/p&gt;
&lt;h3&gt;Consuming REST services (Send Ports)&lt;/h3&gt;
&lt;p&gt;As I said before, I’ve “borrowed” the consuming part from &lt;a href="http://social.technet.microsoft.com/profile/nitin%20mehrotra_msft/" target="_blank"&gt;Nitin Mehrotra&amp;#39;s&lt;/a&gt; sample, and added support for POST and PUT. To consume a REST service from BizTalk, the experience is pretty much the same as when exposing a service using a Receive Location. Set the Send Port Transport to &lt;strong&gt;WCF-Custom &lt;/strong&gt;and the binding to &lt;strong&gt;WebHttpBinding&lt;/strong&gt;. As with the Receive Location, we also need to add a behavior, - this time the &lt;em&gt;BizTalkRESTTransmitHandler&lt;/em&gt;. This is a &lt;a href="http://msdn.microsoft.com/en-us/library/system.servicemodel.dispatcher.iclientmessageinspector.aspx" target="_blank"&gt;IClientMessageInspector&lt;/a&gt;. The actions of this behavior differs depending on the SOAP Action Header which you state in the WCF-Custom Transport Properties:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogical.se/blogs/mikael/image_16A9D0DA.png"&gt;&lt;img title="image" style="BORDER-TOP-WIDTH:0px;PADDING-RIGHT:0px;DISPLAY:inline;PADDING-LEFT:0px;BORDER-LEFT-WIDTH:0px;BACKGROUND-IMAGE:none;BORDER-BOTTOM-WIDTH:0px;PADDING-TOP:0px;BORDER-RIGHT-WIDTH:0px;" height="484" alt="image" src="http://blogical.se/blogs/mikael/image_thumb_43528AB3.png" width="352" border="0" /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/p&gt;
&lt;h4&gt;GET and DELETE&lt;/h4&gt;
&lt;p&gt;To consume a REST service you have to pass a BizTalkWebHttpRequest message to the adapter.&lt;/p&gt;&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;ns0:bizTalkWebHttpRequest&lt;/span&gt; 
  &lt;span class="attr"&gt;method&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;GET&amp;quot;&lt;/span&gt; 
  &lt;span class="attr"&gt;uriTemplate&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;/Events/{&lt;font style="BACKGROUND-COLOR:#ffff00;"&gt;id&lt;/font&gt;}&amp;quot;&lt;/span&gt; 
  &lt;span class="attr"&gt;xmlns:ns0&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;http://bLogical.RESTSchemas.BizTalkWebHttpRequest/1.0&amp;quot;&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;ns0:params&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;ns0:param&lt;/span&gt; &lt;span class="attr"&gt;name&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;&lt;font style="BACKGROUND-COLOR:#ffff00;"&gt;id&lt;/font&gt;&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;font style="BACKGROUND-COLOR:#ffff00;"&gt;123&lt;/font&gt;&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;ns0:param&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;ns0:params&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;ns0:headers&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;ns0:header&lt;/span&gt; &lt;span class="attr"&gt;name&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;Content-Type&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;application/xml&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;ns0:header&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;ns0:headers&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;ns0:bizTalkWebHttpRequest&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;The &lt;em&gt;UriTemplate&lt;/em&gt; together with your parameters and the Send Port URI, will make up the actual &lt;em&gt;To&lt;/em&gt; URI of the message. For instance, if the Send Port URI is set to &lt;strong&gt;http://somedomain.com &lt;/strong&gt;the message above would be sent to &lt;strong&gt;http://somedomain.com&lt;font style="BACKGROUND-COLOR:#ffff00;"&gt;/Events/123&lt;/font&gt;&lt;/strong&gt;. &lt;/p&gt;
&lt;p&gt;The response is at this moment never parsed, since most REST services does respond XML if asked to…&lt;/p&gt;
&lt;h4&gt;POST and PUT&lt;/h4&gt;
&lt;p&gt;Except for adding necessary headers, the POST and PUT request does very little. Keep in mind though, you will always post a message to the URI set on the Send Port. You may find it tempting to use the same Send Port for all calls to a particular REST service, and although this will work for GET and DELETE, it wont work for POST and PUT. This is because the behavior has no knowledge of your intentions other than the payload. I could have solved this using SOAP Action Headers or some promoted property, but I didn’t… (sorry).&amp;nbsp; &lt;/p&gt;
&lt;h2&gt;How to use it&lt;/h2&gt;
&lt;h3&gt;1. Download the bits from &lt;a href="http://biztalkrest.codeplex.com/" target="_blank"&gt;CodePlex&lt;/a&gt;.&lt;/h3&gt;
&lt;p&gt;The solution has four projects:&lt;/p&gt;
&lt;table class="" cellspacing="0" cellpadding="0"&gt;

&lt;tr&gt;
&lt;td class=""&gt;bLogical.BizTalk.RESTBehavior&lt;/td&gt;
&lt;td class=""&gt;Includes the three behaviors: &lt;br /&gt;- BizTalkRESTRequestHandler &lt;br /&gt;- BizTalkRESTResponseHandler &lt;br /&gt;- BizTalkRESTTransmitHandler&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td class=""&gt;bLogical.BizTalk.RESTBehavior.Setup&lt;/td&gt;
&lt;td class=""&gt;Installs the bLogical.BizTalk.RESTBehavior assembly to the Global Assembly Cache&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td class=""&gt;bLogical.RESTSchemas&lt;/td&gt;
&lt;td class=""&gt;Includes the BizTalkWebHttpRequest schema&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td class=""&gt;BizTalkSampleApplication&lt;/td&gt;
&lt;td class=""&gt;Includes six demo orchestrations and bindings.&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td class=""&gt;ExternalSampleApplication&lt;/td&gt;
&lt;td class=""&gt;This is a sample REST service used used in the Send Port of the BizTalkSampleApplication&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;h3&gt;2. Register the behavior&lt;/h3&gt;
&lt;p&gt;In order to see the behaviors in the Select Behavior Extension dialog you need to register the behaviors. This can be done in different places such as in the machine.config or the BTSNTSvc(64).exe.config file. However I find it more convenient to set it on the Receive- and Send handler in the BizTalk Administration Console, as you’d otherwise need to update the config files on all BizTalk machines (given you have more then one)&lt;/p&gt;
&lt;p&gt;To do this, select the WCF-Custom adapter under &lt;em&gt;Platform Settings –&amp;gt; Adapters&lt;/em&gt; in the BizTalk Administration Console. Double-click the Receive Handler and click the &lt;em&gt;Properties &lt;/em&gt;button. Then click the &lt;em&gt;Import&lt;/em&gt; button and browse to the &lt;em&gt;WCF-Custom.BindingsExtension-ReceiveHandler.config &lt;/em&gt;found in both the solution folder and the installation folder. Repeat the steps for the Send handler using the &lt;em&gt;WCF-Custom.BindingsExtension-SendHandler.config&lt;/em&gt; file.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogical.se/blogs/mikael/SNAGHTML16ea3c8b_0EC8273C.png"&gt;&lt;img title="SNAGHTML16ea3c8b" style="BORDER-TOP-WIDTH:0px;PADDING-RIGHT:0px;DISPLAY:inline;PADDING-LEFT:0px;BORDER-LEFT-WIDTH:0px;BACKGROUND-IMAGE:none;BORDER-BOTTOM-WIDTH:0px;PADDING-TOP:0px;BORDER-RIGHT-WIDTH:0px;" height="480" alt="SNAGHTML16ea3c8b" src="http://blogical.se/blogs/mikael/SNAGHTML16ea3c8b_thumb_139CC74F.png" width="537" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;If you want to register the behaviors in the machine.config file(s), just copy the behavior extensions to the &amp;lt;behaviorExtensions&amp;gt; element in the appropriate files.&lt;/p&gt;
&lt;h3&gt;&lt;/h3&gt;
&lt;h3&gt;3. Install the BizTalkWebHttpRequest schema&lt;/h3&gt;
&lt;p&gt;The BizTalkWebHttpRequest is part of the &lt;strong&gt;bLogical.RESTSchemas &lt;/strong&gt;project. Update the Application Name in the project properties, and deploy it to BizTalk.&lt;/p&gt;
&lt;h3&gt;4. Use the behaviors&lt;/h3&gt;
&lt;h4&gt;Receive&lt;/h4&gt;
&lt;ol&gt;
&lt;li&gt;Create a two-way Receive Port and Receive Location &lt;/li&gt;
&lt;li&gt;Set the Transport to WCF-Custom &lt;/li&gt;
&lt;li&gt;Set the URI to something like http://localhost:9090/MyService, and select the webHttpBinding in the Binding tab &lt;/li&gt;
&lt;li&gt;Select the Behavior tab, and right-click the EndpointBehavior node on the left, and select &lt;em&gt;Add extension&lt;/em&gt; &lt;/li&gt;
&lt;li&gt;Select the &lt;strong&gt;BizTalkRESTRequestHandler&lt;/strong&gt; &lt;/li&gt;&lt;/ol&gt;
&lt;p&gt;&lt;a href="http://blogical.se/blogs/mikael/SNAGHTML16fae3c2_38BA11BB.png"&gt;&lt;img title="SNAGHTML16fae3c2" style="BORDER-TOP-WIDTH:0px;PADDING-RIGHT:0px;DISPLAY:inline;PADDING-LEFT:0px;BORDER-LEFT-WIDTH:0px;BACKGROUND-IMAGE:none;BORDER-BOTTOM-WIDTH:0px;PADDING-TOP:0px;BORDER-RIGHT-WIDTH:0px;" height="480" alt="SNAGHTML16fae3c2" src="http://blogical.se/blogs/mikael/SNAGHTML16fae3c2_thumb_17C69F14.png" width="528" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;6.&amp;nbsp; Set the UriTemplate to match your expected incoming request. You can have multiple UriTemplates delimited using a pipe, eg &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;/Person/id={pId}| /Person/firstname={fname} | /Person/lastname={lname}&lt;/strong&gt;. &lt;/p&gt;
&lt;p&gt;This would make your service accept incoming GET or DELETE request like these:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;http://localhost:8080/myservice/Person/id=123 &lt;br /&gt;http://localhost:8080/myservice/Person/fistname=Caren &lt;br /&gt;http://localhost:8080/myservice/Person/lastname=Smith&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogical.se/blogs/mikael/SNAGHTML16ff5401_07D75A50.png"&gt;&lt;img title="SNAGHTML16ff5401" style="BORDER-TOP-WIDTH:0px;PADDING-RIGHT:0px;DISPLAY:inline;PADDING-LEFT:0px;BORDER-LEFT-WIDTH:0px;BACKGROUND-IMAGE:none;BORDER-BOTTOM-WIDTH:0px;PADDING-TOP:0px;BORDER-RIGHT-WIDTH:0px;" height="214" alt="SNAGHTML16ff5401" src="http://blogical.se/blogs/mikael/SNAGHTML16ff5401_thumb_6E6F5715.png" width="640" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h4&gt;Send&lt;/h4&gt;
&lt;ol&gt;
&lt;li&gt;Create a new Static Solicit-Response Send Port &lt;/li&gt;
&lt;li&gt;Set the Transport to WCF-Custom &lt;/li&gt;
&lt;li&gt;Click the Configure button and set the URI to the base URI of the service. Eg http://externalservice/service.svc. Select the webHttpBinding in the Binding tab &lt;/li&gt;
&lt;li&gt;Select the Behavior tab, and right-click the EndpointBehavior node on the left, and select &lt;em&gt;Add extension&lt;/em&gt; &lt;/li&gt;
&lt;li&gt;Select the BizTalkRESTTransmitHandler from the list of extensions &lt;/li&gt;&lt;/ol&gt;
&lt;h3&gt;5. Install and use the Sample Application&lt;/h3&gt;
&lt;p&gt;The &lt;strong&gt;BizTalkSampleApplication &lt;/strong&gt;project has six samples:&lt;/p&gt;
&lt;table class="" cellspacing="0" cellpadding="0"&gt;

&lt;tr&gt;
&lt;td class=""&gt;&lt;strong&gt;ConsumeDELETE&lt;/strong&gt;&lt;/td&gt;
&lt;td class=""&gt;Makes a DELETE request to an external REST service (ExternalSampleApplication)&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td class=""&gt;&lt;strong&gt;ConsumeGET&lt;/strong&gt;&lt;/td&gt;
&lt;td class=""&gt;Makes a GET request to an external REST service &lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td class=""&gt;&lt;strong&gt;ConsumePOST&lt;/strong&gt;&lt;/td&gt;
&lt;td class=""&gt;Makes a POST request to an external REST service &lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td class=""&gt;&lt;strong&gt;ExposeDELETE&lt;/strong&gt;&lt;/td&gt;
&lt;td class=""&gt;Receives an incoming DELETE request&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td class=""&gt;&lt;strong&gt;ExposeGET&lt;/strong&gt;&lt;/td&gt;
&lt;td class=""&gt;Receives an incoming GET request&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td class=""&gt;&lt;strong&gt;ExposePOST&lt;/strong&gt;&lt;/td&gt;
&lt;td class=""&gt;Receives an incoming POST request&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;p&gt;The BizTalkSampleApplication is deployed to an appplication with the same name. The bindings file are included in the project. Before you try out the Consume* scenarios, make sure you’ve started the ExternalSampleApplication (just right-click the RESTService.svc file and select &lt;em&gt;View in browser&lt;/em&gt;).&lt;/p&gt;
&lt;p&gt;After you’ve deployed the solution to BizTalk, you need to redirect all FILE ports to the FILEDROP folder (part of the zip file)&lt;/p&gt;
&lt;p&gt;All &lt;em&gt;Consume&lt;/em&gt;* samples uses the same Receive Location; &lt;strong&gt;ReceiveConsumeREST &lt;/strong&gt;and submits the message to the RESTService.svc in the ExternalSampleApplication.&lt;/p&gt;
&lt;p&gt;To test the &lt;strong&gt;ExposeGET&lt;/strong&gt; sample, you can use the browser and hit http:localhost:9999/Events/id=123 (any number will do)&lt;/p&gt;
&lt;p&gt;To test the &lt;strong&gt;ExposeDELETE&lt;/strong&gt; and &lt;strong&gt;ExposePOST &lt;/strong&gt;you’ll need to use some other tool like Fiddler.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogical.se/blogs/mikael/SNAGHTML171d0630_05BA5B87.png"&gt;&lt;img title="SNAGHTML171d0630" style="BORDER-TOP-WIDTH:0px;PADDING-RIGHT:0px;DISPLAY:inline;PADDING-LEFT:0px;BORDER-LEFT-WIDTH:0px;BACKGROUND-IMAGE:none;BORDER-BOTTOM-WIDTH:0px;PADDING-TOP:0px;BORDER-RIGHT-WIDTH:0px;" height="480" alt="SNAGHTML171d0630" src="http://blogical.se/blogs/mikael/SNAGHTML171d0630_thumb_398251D8.png" width="563" border="0" /&gt;&lt;/a&gt;&amp;nbsp; &lt;/p&gt;
&lt;p&gt;To use the sample with Fiddler:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Select the Composer tab &lt;/li&gt;
&lt;li&gt;Select the Verb and set the URI &lt;/li&gt;
&lt;li&gt;Set the Request Headers (sample file included in the solution) &lt;/li&gt;
&lt;li&gt;When testing POST, generate an instance of the Event schema in the BizTalkSampleApplication or copy the content from the Event_output.xml file in the FILEDROP folder. &lt;/li&gt;&lt;/ol&gt;
&lt;p&gt;That’s it. Let me know if you run into any issues. If you find it useful &lt;a href="https://twitter.com/intent/tweet?hashtags=biztalk%2CREST&amp;amp;original_referer=https%3A%2F%2Ftwitter.com%2Fabout%2Fresources%2Fbuttons&amp;amp;source=tweetbutton&amp;amp;text=Check%20out%20%22REST%20Start%20Kit%20for%20BizTalk%22&amp;amp;url=https%3A%2F%2Fbiztalkrest.codeplex.com%2F&amp;amp;via=wmmihaa" target="_blank"&gt;TWEET it&lt;/a&gt;&lt;strong&gt;&lt;/strong&gt;!&lt;/p&gt;
&lt;p&gt;HTH&lt;/p&gt;
&lt;p&gt;//Mikael&lt;/p&gt;&lt;img src="http://blogical.se/aggbug.aspx?PostID=29877" width="1" height="1"&gt;</description><category domain="http://blogical.se/blogs/mikael/archive/tags/BizTalk/default.aspx">BizTalk</category><category domain="http://blogical.se/blogs/mikael/archive/tags/WCF/default.aspx">WCF</category><category domain="http://blogical.se/blogs/mikael/archive/tags/REST/default.aspx">REST</category><category domain="http://blogical.se/blogs/mikael/archive/tags/BizTalk+2010/default.aspx">BizTalk 2010</category><category domain="http://blogical.se/blogs/mikael/archive/tags/JSON/default.aspx">JSON</category></item><item><title>Exposing JSON/REST endpoints from BizTalk</title><link>http://blogical.se/blogs/mikael/archive/2012/03/07/exposing-json-rest-endpoints-from-biztalk.aspx</link><pubDate>Wed, 07 Mar 2012 13:14:00 GMT</pubDate><guid isPermaLink="false">19a535f3-07d9-4378-9c5a-8d019d91e842:29757</guid><dc:creator>wmmihaa</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;&lt;font size="5"&gt;&lt;font color="#FF0000"&gt;This ports is no longer valid. An update can be found &lt;/font&gt;&lt;b&gt;&lt;a href="http://blogical.se/blogs/mikael/archive/2012/05/28/rest-start-kit-for-biztalk-server.aspx"&gt;here&lt;/a&gt;:&lt;/b&gt;&lt;/font&gt;&lt;/p&gt;&amp;nbsp;&lt;p&gt;Solutions for &lt;u&gt;consuming&lt;/u&gt; REST services from BizTalk has been around for a while, and &lt;a href="http://www.masteringbiztalk.com/blogs/jon"&gt;Jon Flanders&lt;/a&gt; has an excellent &lt;a href="http://www.masteringbiztalk.com/blogs/jon/PermaLink,guid,90f1db62-b42f-4be3-b9d7-36cd4319c97c.aspx"&gt;post about it&lt;/a&gt;.&amp;nbsp; However, very little has been told about &lt;u&gt;exposing&lt;/u&gt; REST endpoints, and even less using &lt;a href="http://www.json.org/"&gt;JSON&lt;/a&gt;. If you don’t know about JSON, it’s a lightweight data format, commonly used by JavaScript and JQuery. Part from being less verbose then XML, it can be parsed to a object on the client which makes it easier to navigate (as oppose to using XPath). This can come to good rescue for UI devs who apparently don’t understand XPath ;)&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogical.se/blogs/mikael/SNAGHTML3e7893f_223E6675.png"&gt;&lt;img src="http://blogical.se/blogs/mikael/SNAGHTML3e7893f_thumb_08D6633B.png" style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="SNAGHTML3e7893f" alt="SNAGHTML3e7893f" border="0" height="112" width="640" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogical.se/blogs/mikael/SNAGHTML3e6150a_28853D03.png"&gt;&lt;img src="http://blogical.se/blogs/mikael/SNAGHTML3e6150a_thumb_483416CB.png" style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="SNAGHTML3e6150a" alt="SNAGHTML3e6150a" border="0" height="110" width="640" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogical.se/blogs/mikael/SNAGHTML3da61a3_6BED3E65.png"&gt;&lt;img src="http://blogical.se/blogs/mikael/SNAGHTML3da61a3_thumb_6776BD9E.png" style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="SNAGHTML3da61a3" alt="SNAGHTML3da61a3" border="0" height="107" width="640" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;I haven’t yet been in a situation where I’ve had to expose REST/JSON endpoints from BizTalk, but as &lt;a href="http://kentweare.blogspot.com/"&gt;Kent Weare&lt;/a&gt; was being hackled by &lt;a href="http://weblogs.asp.net/bsimser"&gt;Bil Simser&lt;/a&gt; (MS Word MVP), I was eager to help out.&lt;/p&gt;  &lt;p&gt;&amp;nbsp;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogical.se/blogs/mikael/channelstack_0B2FE539.jpg"&gt;&lt;img src="http://blogical.se/blogs/mikael/channelstack_thumb_2ADEBF01.jpg" style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="channelstack" alt="channelstack" border="0" height="164" width="640" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;I begun by creating a custom &lt;a href="http://msdn.microsoft.com/en-us/library/aa717047.aspx"&gt;WCF MessageInspector&lt;/a&gt;. My plan was to parse the incoming JSON message to an XML message, and also to change the HTTP verb from GET to POST if the client sent a GET request (BizTalk requires POST). As it turns out, the HTTP verb/Method, can not be changed in the &lt;a href="http://msdn.microsoft.com/en-us/library/system.servicemodel.dispatcher.idispatchmessageinspector.aspx"&gt;IDispatchMessageInspector&lt;/a&gt;. If it was to be changed it would have to be earlier in the channel stack.&lt;/p&gt;  &lt;p&gt;Prior to the MessageInspector is the OperationSelector, so I went on creating one implementing the &lt;a href="http://msdn.microsoft.com/en-us/library/system.servicemodel.dispatcher.idispatchoperationselector.aspx"&gt;IDispatchOperationSelector&lt;/a&gt; interface. After moving the logic from the inspector to the SelectOperation method in the OperationSelector, I ran into a new problem. The method was never called. It seems BizTalk is adding it’s own OperationSelector through its HostFactory. As I wanted to host the Receive Location in a In-Process host (no IIS), making my own HosFactorythis wouldn’t work either…&lt;/p&gt;  &lt;p&gt;I was forced to dig even deeper in the WCF channel stack. Next step was a custom Encoder. Luckily I found a sample in the &lt;a href="http://msdn.microsoft.com/en-us/library/ms751486.aspx"&gt;SDK&lt;/a&gt; which was pretty easy to use. The only problem was I couldn’t access the HTTP verb. However after all this, I was willing to accept this trade-off.&lt;/p&gt;  &lt;p&gt;Next up was the serialization and deserialization of JSON. Bil Simser pointed me to the &lt;a href="http://json.codeplex.com/"&gt;JSON.Net&lt;/a&gt; project on codeplex, which made it very easy:&lt;/p&gt;  &lt;pre class="csharpcode"&gt;XmlDocument doc = &lt;span class="kwrd"&gt;new&lt;/span&gt; XmlDocument();
doc.LoadXml(xmlString);

&lt;span class="kwrd"&gt;string&lt;/span&gt; jsonString = JsonConvert.SerializeXmlNode(doc, Newtonsoft.Json.Formatting.None, &lt;span class="kwrd"&gt;true&lt;/span&gt;);&lt;/pre&gt;

&lt;h3&gt;How to use the sample:&lt;/h3&gt;

&lt;ol&gt;
  &lt;li&gt;Download the sample &lt;a href="http://blogical.se/files/folders/downloads/entry29758.aspx"&gt;here&lt;/a&gt; &lt;/li&gt;

  &lt;li&gt;Either run the bLogical.JsonXmlMessageEncoder.Setup.msi or build and add the bLogical.JsonXmlMessageEncoder to the global assembly cache (GAC). &lt;/li&gt;

  &lt;li&gt;Open BizTalk Administration Console. Browse to Adapters and right-click the WCF-Custom Receive Handler. Select Properties. &lt;/li&gt;

  &lt;li&gt;Click the Import button, and select the WcfExtensions.config file found in the project. &lt;/li&gt;

  &lt;li&gt;Deploy the FortisAlberta project to BizTalk. &lt;/li&gt;

  &lt;li&gt;Import the FortisAlberta.BindingInfo.xml to the FortisAlberta Application &lt;/li&gt;

  &lt;li&gt;Start the FortisAlberta Application. &lt;/li&gt;

  &lt;li&gt;Run the WebApplication1 project, and submit an OutageReport. &lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;How to configure a Receive Location manually&lt;/h3&gt;

&lt;ol&gt;
  &lt;li&gt;Add a Request/Response Receive Port and Location. &lt;/li&gt;

  &lt;li&gt;Set the transport to WCF-Custom (no need to host it in IIS). &lt;/li&gt;

  &lt;li&gt;Set the binding to &lt;b&gt;customBinding&lt;/b&gt;, and remove the existing binding elements. &lt;/li&gt;

  &lt;li&gt;Add the &amp;quot;jsonXmlMessageEncoder&amp;quot; and the &amp;quot;http transport&amp;quot; extensions. &lt;/li&gt;

  &lt;li&gt;Enable the port. &lt;/li&gt;

  &lt;li&gt;You can use the XmlToJSONConverter that comes with the project to generate the expected JSON format from an XML instance, or use any of the online conversion sites like &lt;a href="http://jsontoxml.utilities-online.info/"&gt;this one&lt;/a&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="http://blogical.se/blogs/mikael/SNAGHTML3d49ea3_4A8D98C9.png"&gt;&lt;img src="http://blogical.se/blogs/mikael/SNAGHTML3d49ea3_thumb_1829C54A.png" style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="SNAGHTML3d49ea3" alt="SNAGHTML3d49ea3" border="0" height="480" width="351" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;How to call the service&lt;/h3&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;script&lt;/span&gt; &lt;span class="attr"&gt;type&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;text/javascript&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;

    jQuery.support.cors = &lt;span class="kwrd"&gt;true&lt;/span&gt;;
    &lt;span class="kwrd"&gt;var&lt;/span&gt; jsonRequest = &lt;span class="str"&gt;&amp;#39;{&amp;quot;Tweet&amp;quot;:{&amp;quot;Author&amp;quot;:&amp;quot;wmmihaa&amp;quot;,&amp;quot;Text&amp;quot;:&amp;quot;BizTalk Rock!&amp;quot;}}&amp;#39;&lt;/span&gt;;

    &lt;span class="kwrd"&gt;function&lt;/span&gt; ReportOutage() {
        $.ajax({
            type: &lt;span class="str"&gt;&amp;#39;POST&amp;#39;&lt;/span&gt;,
            url: &lt;span class="str"&gt;&lt;a href="http://yourdomain.com/submitTweet"&gt;http://yourdomain.com/submitTweet&lt;/a&gt;&lt;/span&gt;,
            data: jsonRequest,
            contentType: &lt;span class="str"&gt;&amp;quot;application/json; charset=utf-8&amp;quot;&lt;/span&gt;,
            dataType: &lt;span class="str"&gt;&amp;quot;json&amp;quot;&lt;/span&gt;,
            success: &lt;span class="kwrd"&gt;function&lt;/span&gt; (msg) {
                alert(msg);
            },
            error: &lt;span class="kwrd"&gt;function&lt;/span&gt; (xhr, ajaxOptions, thrownError) {
                alert(&lt;span class="str"&gt;&amp;#39;error: &amp;#39;&lt;/span&gt; + thrownError);
            }
        });
    }
&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;script&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;Please not the JSON above: &lt;/p&gt;

&lt;p&gt;“&lt;b&gt;{&amp;quot;Tweet&amp;quot;:{&amp;quot;Author&amp;quot;:&amp;quot;wmmihaa&amp;quot;,&amp;quot;Text&amp;quot;:&amp;quot;XML Rocks!&amp;quot;}}&lt;/b&gt;”. This is going to be translated to: &lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Tweet&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Author&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;wmmihaa&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Author&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Text&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;XML Rocks!&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Text&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Tweet&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;As there are no namespace, you’d need to add one in the receive pipeline. Alternatively, you could add the namespace in JSON: &lt;/p&gt;

&lt;p&gt;&lt;b&gt;{&amp;quot;ns0:Tweet&amp;quot;:{&amp;quot;@xmlns:ns0&amp;quot;:&amp;quot;http://yourns.Tweet&amp;quot;,&amp;quot;Author&amp;quot;:&amp;quot;wmmihaa&amp;quot;,&amp;quot;Text&amp;quot;:&amp;quot;XML Rocks!&amp;quot;}}&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;Which would come out as:&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;ns0:Tweet&lt;/span&gt; &lt;span class="attr"&gt;xmlns:ns0&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;http://yourns.Tweet&amp;quot;&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;Author&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;wmmihaa&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Author&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;Text&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;XML Rocks!&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Text&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;ns0:Tweet&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

&lt;h3&gt;How to call the service without using parameters&lt;/h3&gt;

&lt;pre class="csharpcode"&gt;function ReportOutage() {
    $.ajax({
        type: &amp;#39;POST&amp;#39;,
        url: &amp;quot;http://yourdomain.com/submitTweet&amp;quot;,
        data: &amp;#39;{}&amp;#39;, // empty parameter
        contentType: &amp;quot;application/json; charset=utf-8&amp;quot;,
        dataType: &amp;quot;json&amp;quot;,
        success: function (msg) {
            alert(msg);
        },
        error: function (xhr, ajaxOptions, thrownError) {
            alert(&amp;#39;error: &amp;#39; + thrownError);
        }
    });&lt;/pre&gt;



&lt;p&gt;Empty parameters are casted to a message that looks like this: &lt;b&gt;&amp;lt;EmptyJsonMessage/&amp;gt;. &lt;/b&gt;As you won’t have an equivalent schema in BizTalk, you can’t parse it using an XmlReceive pipeline. If you want to process the message in an orchestration, you’d need to set the message type of the incoming message to System.Xml.XmlDocument.&lt;/p&gt;

&lt;h3&gt;Restrictions&lt;/h3&gt;

&lt;ol&gt;
  &lt;li&gt;Does not support HTTP GET. &lt;/li&gt;

  &lt;li&gt;Does not support Uri parameters, Eg. http://server/Customers&lt;b&gt;&lt;font style="background-color:#ffff00;"&gt;?id=16&lt;/font&gt;&lt;/b&gt;. &lt;/li&gt;

  &lt;li&gt;The encoder supports both XML and JSON, &lt;u&gt;but not both&lt;/u&gt;. It will be restricted to the media type set on the encoder. &lt;/li&gt;

  &lt;li&gt;In this sample the response can not be handled in a streaming manner. If the size of the response message is bigger then what is read from the client, this is likely to cause a problem. I haven’t experienced this myself, but if you get into this problem, contact me and I’ll look into it. &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;HTH&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/p&gt;&lt;img src="http://blogical.se/aggbug.aspx?PostID=29757" width="1" height="1"&gt;</description><category domain="http://blogical.se/blogs/mikael/archive/tags/BizTalk/default.aspx">BizTalk</category><category domain="http://blogical.se/blogs/mikael/archive/tags/WCF/default.aspx">WCF</category><category domain="http://blogical.se/blogs/mikael/archive/tags/REST/default.aspx">REST</category><category domain="http://blogical.se/blogs/mikael/archive/tags/JSON/default.aspx">JSON</category></item><item><title>Azure Service Bus EAI/EDI December 2011 CTP – Content Based Routing</title><link>http://blogical.se/blogs/mikael/archive/2011/12/18/azure-service-bus-eai-edi-december-2011-ctp-content-based-routing.aspx</link><pubDate>Sun, 18 Dec 2011 14:11:00 GMT</pubDate><guid isPermaLink="false">19a535f3-07d9-4378-9c5a-8d019d91e842:28750</guid><dc:creator>wmmihaa</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;In this blog post we are going look at how to manage routing in the new Azure ServiceBus EAI CTP. &lt;/p&gt;  &lt;p&gt;As a scenario, I’m going to send a request for information (RFI) to some of my fellow MVP’s. To do that, I’m going to create a One-Way Xml Bridge, to receive the messages. After receiving the RFI message I tend to route it to one of three queues.&lt;/p&gt;  &lt;h3&gt;1. Create a ServiceBus project&lt;/h3&gt;  &lt;p&gt;If you haven’t already downloaded the SDK, you can do this &lt;a href="http://www.microsoft.com/download/en/details.aspx?displaylang=en&amp;amp;id=17691"&gt;here&lt;/a&gt;. After you’ve installed the SDK, you can sign in to the &lt;a href="https://portal.appfabriclabs.com/"&gt;labs environment&lt;/a&gt; using a Windows Live ID.&lt;/p&gt;  &lt;p&gt;Open Visual Studio 2010, and select Create Project. In the list of project templates, select &lt;i&gt;ServiceBus&lt;/i&gt;, and &lt;i&gt;Enterprise Application Integration&lt;/i&gt;. Give it a name and click Ok.&lt;/p&gt;  &lt;h3&gt;&lt;/h3&gt;  &lt;p&gt;&lt;a href="http://blogical.se/blogs/mikael/1_53EBBDFE.png"&gt;&lt;img src="http://blogical.se/blogs/mikael/1_thumb_60E59E0F.png" style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="1" alt="1" width="640" border="0" height="443" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;h3&gt;2. Create a Message Type&lt;/h3&gt;  &lt;p&gt;Right-click the project and select &lt;i&gt;Add-&amp;gt;New Item. &lt;/i&gt;At this time there are two types of artifacts you can add; Schemas and Maps. Select &lt;i&gt;Schema&lt;/i&gt; and sett an appropriate name. In my case I set the name to RFI.xsd. Continue building up your schema. Notice, you don’t have to promote any nodes as you’d have to do in BizTalk.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogical.se/blogs/mikael/2a_4D583E6E.png"&gt;&lt;img src="http://blogical.se/blogs/mikael/2a_thumb_6AEA196D.png" style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="2a" alt="2a" width="640" border="0" height="445" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;h3&gt;3. Designing the Bridge&lt;/h3&gt;  &lt;p&gt;Double-click the BridgeConfiguration.bcs and drag a &lt;i&gt;Xml One-Way Bridge&lt;/i&gt; from the toolbox to the canvas. This is going to be your entry point to your process, similar to a Receive Location in BizTalk. Set the name appropriately, and notice the Router Address which is going to be your endpoint in Azure ServiceBus.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogical.se/blogs/mikael/4_4D288EAE.png"&gt;&lt;img src="http://blogical.se/blogs/mikael/4_thumb_4B679D0D.png" style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="4" alt="4" width="640" border="0" height="378" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;h3&gt;4. Add Queues&lt;/h3&gt;  &lt;p&gt;As stated before, the incoming RFI message is going to be routed to any of the three queues. You might not your message relayed to a queue, and could there for use any of the other Destinations such as &lt;i&gt;Relay&lt;/i&gt;- or &lt;i&gt;External Service EndPoints. &lt;/i&gt;Either way, the principle of routing is the same.&lt;/p&gt;  &lt;p&gt;Connect the &lt;i&gt;Bridge&lt;/i&gt; with all &lt;i&gt;Destinations&lt;/i&gt;.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogical.se/blogs/mikael/5_62466E89.png"&gt;&lt;img src="http://blogical.se/blogs/mikael/5_thumb_56447E55.png" style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="5" alt="5" width="624" border="0" height="480" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;h3&gt;5. Configure the Bridge&lt;/h3&gt;  &lt;p&gt;Next we’ll define the incoming message type(s). Double-click your Bridge (ReceiveRFI in my case). Click the plus button in the Message Types stage. Select the Message Type you created earlier, and click the arrow button on the right.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogical.se/blogs/mikael/6_5493B281.png"&gt;&lt;img src="http://blogical.se/blogs/mikael/6_thumb_13F16612.png" style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="6" alt="6" width="640" border="0" height="439" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;h3&gt;6. Enrich the Message&lt;/h3&gt;  &lt;p&gt;This is the interesting step, where we are going to promote some fields in the payload so that we can route on these in the next step.&lt;/p&gt;  &lt;p&gt;First open your schema and select the node you care to use for routing (in my case &lt;i&gt;Receive&lt;/i&gt;). Copy the &lt;i&gt;Instance XPath&lt;/i&gt; from the Property window.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogical.se/blogs/mikael/8_12ACCD33.png"&gt;&lt;img src="http://blogical.se/blogs/mikael/8_thumb_714D2796.png" style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="8" alt="8" width="640" border="0" height="475" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Then double-click the Bridge, select either of the Enrich stages, and then click the &lt;i&gt;Property Definition&lt;/i&gt; button in the Property window. There are two Enrich stages, as you might be using a Transformation, in which case you might want to promote fields from either the original message or the transformed message.&lt;/p&gt;  &lt;p&gt;For more information about transformations, have a look at Kent’s &lt;a href="http://middlewareinthecloud.com/2011/12/17/azure-service-bus-eaiedi-december-2011-ctp-new-mapper/"&gt;post&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogical.se/blogs/mikael/7_5A3EA65A.png"&gt;&lt;img src="http://blogical.se/blogs/mikael/7_thumb_750ACC66.png" style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="7" alt="7" width="566" border="0" height="480" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Set the Type to XPath, and paste the XPath expression in the Identifier text box. Select the Message Type and set the name of the property. Finish be setting the data type and click the Add button (+). Close the dialog by clicking the Ok button. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogical.se/blogs/mikael/9_6587BA97.png"&gt;&lt;img src="http://blogical.se/blogs/mikael/9_thumb_3DE13E6D.png" style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="9" alt="9" width="494" border="0" height="480" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;h3&gt;7. Set the routing conditions&lt;/h3&gt;  &lt;p&gt;As you have promoted your property (or properties), you’re now ready to set the Filter Conditions on each of the Connectors. Select one of the selectors and type the Filter in the Property window. Eg. receiver=’SteefJan’ or customerId=1234. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogical.se/blogs/mikael/10_15CE8F4E.png"&gt;&lt;img src="http://blogical.se/blogs/mikael/10_thumb_5BDF4C61.png" style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="10" alt="10" width="640" border="0" height="299" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;h3&gt;8. Create the Queues&lt;/h3&gt;  &lt;p&gt;Before we deploy the solution, you need to create the queues. There are several tools for this, but with the &lt;a href="http://www.microsoft.com/download/en/details.aspx?displaylang=en&amp;amp;id=17691"&gt;samples&lt;/a&gt; comes a MessageReceiver project you can use. &lt;/p&gt;  &lt;p&gt;Type &lt;font face="Courier New"&gt;MessageReceiver.exe &amp;lt;Your namespace&amp;gt; owner &amp;lt;Your issuer key&amp;gt; &amp;lt;Queue name&amp;gt; Create&lt;/font&gt;&amp;nbsp;&lt;/p&gt;  &lt;p&gt;After creating the queues verify they are created in the &lt;a href="https://portal.appfabriclabs.com/"&gt;portal&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogical.se/blogs/mikael/11_28A312F8.png"&gt;&lt;img src="http://blogical.se/blogs/mikael/11_thumb_1F66D7B7.png" style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="11" alt="11" width="640" border="0" height="265" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;h3&gt;9. Deploy your solution&lt;/h3&gt;  &lt;p&gt;Right-click the project and select &lt;i&gt;Deploy&lt;/i&gt;. Supply the secret.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogical.se/blogs/mikael/12_3E3D4B95.png"&gt;&lt;img src="http://blogical.se/blogs/mikael/12_thumb_6B523863.png" style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="12" alt="12" width="640" border="0" height="314" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;h3&gt;10. Test the solution&lt;/h3&gt;  &lt;p&gt;Along with the MessageReceiver tool, you’ll find a MessageSender project as well. Just type:&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;MessageSender.exe &amp;lt;Your namespace&amp;gt; &amp;lt;Your issuer key&amp;gt; &amp;lt;Your endpoint&amp;gt; &amp;lt;Path to sample file&amp;gt; application/xml&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;Use the MessgeReceiver to get the messages from the queues: &lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogical.se/blogs/mikael/14_29D7860A.png"&gt;&lt;img src="http://blogical.se/blogs/mikael/14_thumb_3494DD5F.png" style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="14" alt="14" width="640" border="0" height="317" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;HTH&lt;/p&gt;&lt;img src="http://blogical.se/aggbug.aspx?PostID=28750" width="1" height="1"&gt;</description><category domain="http://blogical.se/blogs/mikael/archive/tags/Azure/default.aspx">Azure</category><category domain="http://blogical.se/blogs/mikael/archive/tags/EAI/default.aspx">EAI</category><category domain="http://blogical.se/blogs/mikael/archive/tags/ServiceBus/default.aspx">ServiceBus</category></item><item><title>Using User-defined tables as stored procedure parameter</title><link>http://blogical.se/blogs/mikael/archive/2011/12/15/using-user-defined-tables-as-stored-procedure-parameter.aspx</link><pubDate>Thu, 15 Dec 2011 12:47:00 GMT</pubDate><guid isPermaLink="false">19a535f3-07d9-4378-9c5a-8d019d91e842:28599</guid><dc:creator>wmmihaa</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;The WCF-SQL adapter provides support for multiple inserts through the &lt;i&gt;Consume Adapter Service &lt;/i&gt;feature:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogical.se/blogs/mikael/image_06EBD8F2.png"&gt;&lt;img src="http://blogical.se/blogs/mikael/image_thumb_269AB2BA.png" style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="image" alt="image" width="541" border="0" height="484" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;However, sometimes you might want to validate the data on the SQL side before before making the insert. For instance, if you have a collection of Customers, where some of them might already exist in the database, and should only be updated. In such a case, you’d have to first make a database lookup, to determine the state of the Customer and then make either an insert or update.&lt;/p&gt;  &lt;p&gt;In such a case, using &lt;a href="http://msdn.microsoft.com/en-us/library/bb522526.aspx"&gt;user-defined table types&lt;/a&gt; might be your solution. User-defined tables are similar to ordinary tables, but can be passed in as a parameter.&lt;/p&gt;  &lt;p&gt;In my sample, I have a &lt;i&gt;Contacts&lt;/i&gt; table, and I’m receiving a collection of &lt;i&gt;Persons&lt;/i&gt; where some entities are new and some are to be updated. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogical.se/blogs/mikael/image_2D4DBC3D.png"&gt;&lt;img src="http://blogical.se/blogs/mikael/image_thumb_78412D0C.png" style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="image" alt="image" width="644" border="0" height="159" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;h3&gt;Create the User-Defined Table Type&lt;/h3&gt;  &lt;p&gt;The user-defied table type will serve as our contract. &lt;/p&gt;  &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;CREATE&lt;/span&gt; TYPE [dbo].[InsertContactRequest] &lt;span class="kwrd"&gt;AS&lt;/span&gt; &lt;span class="kwrd"&gt;TABLE&lt;/span&gt;
(
    [PersonNo] [&lt;span class="kwrd"&gt;varchar&lt;/span&gt;](50) &lt;span class="kwrd"&gt;NOT&lt;/span&gt; &lt;span class="kwrd"&gt;NULL&lt;/span&gt;,
    [FirstName] [&lt;span class="kwrd"&gt;varchar&lt;/span&gt;](50) &lt;span class="kwrd"&gt;NOT&lt;/span&gt; &lt;span class="kwrd"&gt;NULL&lt;/span&gt;,
    [LastName] [&lt;span class="kwrd"&gt;varchar&lt;/span&gt;](50) &lt;span class="kwrd"&gt;NOT&lt;/span&gt; &lt;span class="kwrd"&gt;NULL&lt;/span&gt;,
    [Phone] [&lt;span class="kwrd"&gt;varchar&lt;/span&gt;](50) &lt;span class="kwrd"&gt;NOT&lt;/span&gt; &lt;span class="kwrd"&gt;NULL&lt;/span&gt;,
    &lt;span class="kwrd"&gt;PRIMARY&lt;/span&gt; &lt;span class="kwrd"&gt;KEY&lt;/span&gt; &lt;span class="kwrd"&gt;CLUSTERED&lt;/span&gt; ([PersonNo] &lt;span class="kwrd"&gt;ASC&lt;/span&gt;)&lt;span class="kwrd"&gt;WITH&lt;/span&gt; (IGNORE_DUP_KEY = &lt;span class="kwrd"&gt;OFF&lt;/span&gt;)
)&lt;/pre&gt;

&lt;h3&gt;Create the Stored Procedure&lt;/h3&gt;

&lt;p&gt;The stored procedure takes the user-defined table type as a parameter (@insertContactRequest), then updates all existing rows and inserting all new once.&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;CREATE&lt;/span&gt; &lt;span class="kwrd"&gt;PROCEDURE&lt;/span&gt; [dbo].[sp_InsertContacts] @insertContactRequest InsertContactRequest READONLY
&lt;span class="kwrd"&gt;AS&lt;/span&gt;
&lt;span class="kwrd"&gt;BEGIN&lt;/span&gt;
    
    &lt;span class="kwrd"&gt;UPDATE&lt;/span&gt; dbo.Contacts 
    &lt;span class="kwrd"&gt;SET&lt;/span&gt; Phone = r.Phone
    &lt;span class="kwrd"&gt;FROM&lt;/span&gt; dbo.Contacts c
    &lt;span class="kwrd"&gt;JOIN&lt;/span&gt; @insertContactRequest r &lt;span class="kwrd"&gt;on&lt;/span&gt; r.PersonNo = c.PersonNo

    &lt;span class="kwrd"&gt;INSERT&lt;/span&gt; &lt;span class="kwrd"&gt;INTO&lt;/span&gt; dbo.Contacts (PersonNo, FirstName, LastName, Phone)
    &lt;span class="kwrd"&gt;SELECT&lt;/span&gt; r.PersonNo, r.FirstName, r.LastName, r.Phone
    &lt;span class="kwrd"&gt;FROM&lt;/span&gt;    @insertContactRequest r
    &lt;span class="kwrd"&gt;WHERE&lt;/span&gt;    r.PersonNo &lt;span class="kwrd"&gt;not&lt;/span&gt; &lt;span class="kwrd"&gt;in&lt;/span&gt;(&lt;span class="kwrd"&gt;SELECT&lt;/span&gt; PersonNo &lt;span class="kwrd"&gt;FROM&lt;/span&gt; dbo.Contacts)
       
END&lt;/pre&gt;

&lt;h3&gt;Generate BizTalk artefacs&lt;/h3&gt;

&lt;p&gt;1. In you Visual Studio, right-click the BizTalk project and select &lt;i&gt;Add-&amp;gt;Add Generated Items&lt;/i&gt;. Select &lt;i&gt;Consume Adapter Service.&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="http://blogical.se/blogs/mikael/image_5B0F7334.png"&gt;&lt;img src="http://blogical.se/blogs/mikael/image_thumb_2FCADC2D.png" style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" alt="image" width="644" border="0" height="446" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;2. In the &lt;i&gt;Consume Adapter Service &lt;/i&gt;dialog, click the configure button to set the credentials. Click Ok, and then &lt;i&gt;Connect&lt;/i&gt;. &lt;/p&gt;

&lt;p&gt;&lt;a href="http://blogical.se/blogs/mikael/image_089092F8.png"&gt;&lt;img src="http://blogical.se/blogs/mikael/image_thumb_134DEA4D.png" style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" alt="image" width="542" border="0" height="484" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;3. In the tree-view, select &lt;i&gt;Strongly Typed Procedures&lt;/i&gt;, and select your stored procedure in the right pane. Click &lt;i&gt;Add&lt;/i&gt; and Ok to generate the schemas.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://blogical.se/blogs/mikael/image_79E5E712.png"&gt;&lt;img src="http://blogical.se/blogs/mikael/image_thumb_1994C0DB.png" style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" alt="image" width="644" border="0" height="456" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;4. Make your transformation, and complete your solution.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://blogical.se/blogs/mikael/image_6011B0E3.png"&gt;&lt;img src="http://blogical.se/blogs/mikael/image_thumb_5FA57DEE.png" style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" alt="image" width="644" border="0" height="456" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&amp;nbsp;&lt;/p&gt;

&lt;p&gt;&lt;a href="http://blogical.se/files/folders/downloads/entry28598.aspx"&gt;Here is the sample source.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;HTH&lt;/p&gt;

&lt;p&gt;(Kudos Daniel Östberg)&lt;/p&gt;&lt;img src="http://blogical.se/aggbug.aspx?PostID=28599" width="1" height="1"&gt;</description><category domain="http://blogical.se/blogs/mikael/archive/tags/WCF/default.aspx">WCF</category><category domain="http://blogical.se/blogs/mikael/archive/tags/SQL/default.aspx">SQL</category><category domain="http://blogical.se/blogs/mikael/archive/tags/BizTalk+2010/default.aspx">BizTalk 2010</category></item><item><title>I did it so you don't have to: Connecting to Dynamics CRM Online from BizTalk Server</title><link>http://blogical.se/blogs/mikael/archive/2011/12/11/i-did-it-so-you-don-t-have-to-connecting-to-dynamics-crm-online-from-biztalk-server.aspx</link><pubDate>Sun, 11 Dec 2011 13:31:00 GMT</pubDate><guid isPermaLink="false">19a535f3-07d9-4378-9c5a-8d019d91e842:28410</guid><dc:creator>wmmihaa</dc:creator><slash:comments>0</slash:comments><description>&lt;b&gt;&lt;/b&gt;  &lt;p&gt;If you’re a consultant like me, you’ve probably got similar calls from some key account manager, as I did yesterday:&lt;/p&gt;  &lt;p&gt;&lt;b&gt;KAM&lt;/b&gt;: &lt;i&gt;Hi Mikael. I’m just about to close this super big deal, with this super important Customer.&lt;/i&gt;     &lt;br /&gt;&lt;b&gt;Me&lt;/b&gt;: &lt;i&gt;Really! Good for you.      &lt;br /&gt;&lt;/i&gt;&lt;b&gt;KAM&lt;/b&gt;: &lt;i&gt;Yeah, we’re really close. But to rap it up, I was wondering if you could help me out a bit…      &lt;br /&gt;&lt;/i&gt;&lt;b&gt;Me&lt;/b&gt;: &lt;i&gt;Sure. What do you have in mind?&lt;/i&gt;     &lt;br /&gt;&lt;b&gt;KAM&lt;/b&gt;: &lt;i&gt;Could you come with me to meeting with the customer on Monday? (this happens on Thursday 6PM)      &lt;br /&gt;&lt;/i&gt;&lt;b&gt;Me&lt;/b&gt; (getting suspicious): &lt;i&gt;mmm…What do you want me to do?      &lt;br /&gt;&lt;/i&gt;&lt;b&gt;KAM&lt;/b&gt;: &lt;i&gt;A demo!      &lt;br /&gt;&lt;/i&gt;&lt;b&gt;Me&lt;/b&gt;: &lt;i&gt;Demo of what?      &lt;br /&gt;&lt;/i&gt;&lt;b&gt;KAM&lt;/b&gt;: &lt;i&gt;The customer want us to show how to integrate Dynamics CRM Online with SAP using BizTalk.      &lt;br /&gt;&lt;/i&gt;&lt;b&gt;Me&lt;/b&gt;: &lt;i&gt;What?      &lt;br /&gt;&lt;/i&gt;&lt;b&gt;KAM&lt;/b&gt;: &lt;i&gt;Yes, yes. The customer wants us to show it live!&lt;/i&gt; &lt;i&gt;You know, they want to see you do it…&lt;/i&gt;     &lt;br /&gt;&lt;b&gt;Me&lt;/b&gt;: &lt;i&gt;ARE YOU HIGH? (I didn’t actually say that, but I was thinking it)      &lt;br /&gt;&lt;/i&gt;&lt;b&gt;Me&lt;/b&gt;: &lt;i&gt;It will not happen! I haven&amp;#39;t worked with SAP since 3-4 year ago. I’ve never worked with CRM Online (or off-line for that matter). I’m fully booked tomorrow, and I want to spend the weekend with my family as X-mas is coming up.      &lt;br /&gt;&lt;/i&gt;&lt;b&gt;KAM&lt;/b&gt;: &lt;i&gt;But we need to close this deal…&lt;/i&gt;     &lt;br /&gt;&lt;b&gt;Me&lt;/b&gt;: &lt;i&gt;NO!      &lt;br /&gt;&lt;/i&gt;&lt;b&gt;KAM&lt;/b&gt;: &lt;i&gt;Please…      &lt;br /&gt;&lt;/i&gt;&lt;b&gt;Me&lt;/b&gt;: &lt;i&gt;No way!      &lt;br /&gt;&lt;/i&gt;(Yada, yada, yada)     &lt;br /&gt;&lt;b&gt;Me&lt;/b&gt;: &lt;i&gt;Ok, I’ll give it a try (&lt;b&gt;I’M SUCH AN IDIOT!!!!!&lt;/b&gt;)       &lt;br /&gt;&lt;/i&gt;&lt;/p&gt;  &lt;h3&gt;So here it is: How to connect to Dynamics CRM Online from BizTalk Server&lt;/h3&gt;  &lt;p&gt;To begin with, if you want to integrate with CRM Online, you have two options. Either use an un-typed web-service API or use a tool called &lt;a href="http://blog.abodit.com/2011/03/crmsvcutil-exe-with-microsoft-dynamics-crm-2011-online-problem/"&gt;CrmSvcUtil.exe&lt;/a&gt; to create a proxy class for you. Each of these comes with some challenges and limitations:&lt;/p&gt;  &lt;p&gt;Using an un-typed web service, can of course be somewhat messy, but the SDK provides you with the schemas you need (more on that later). The biggest challenge, however, is to authenticate to the service as it assumes you’re using Windows Live Id. Authenticating against the service would require an additional four calls to the service to finally get the authentication tokens needed to create the security header. An then figure out a way to to add the headers in a pipeline. The steps needed are described by Girish Raja &lt;a href="http://code.msdn.microsoft.com/CRM-Online-2011-WebServices-14913a16"&gt;here&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;The proxy created using the CrmSvcUtil is quite nice, since it’s typed, but of course I can’t use it in a send port. I would&amp;nbsp; have to make the call using the inline-send approach from within an expression shape in an orchestration. And thereby loose the built in re-send functionality and more, that ships with BizTalk.&lt;/p&gt;  &lt;p&gt;As none of these approaches was acceptable, I begun looking for other alternatives. What I really wanted was an authentication behavior, that I could add to my WCF-Custom send port adapter.&amp;nbsp; &lt;/p&gt;  &lt;h3&gt;Building the Custom WCF Behavior&lt;/h3&gt;  &lt;p&gt;What I needed was a Message Inspector that would build up the security header as Girish Raja did in his sample, and then add that header to the SOAP envelope. This class is called &lt;i&gt;LiveIdAuthenticationMessageInspector&lt;/i&gt; and inherits from &lt;a href="http://msdn.microsoft.com/en-us/library/system.servicemodel.dispatcher.iclientmessageinspector.aspx"&gt;IClientMessageInspector&lt;/a&gt;&lt;i&gt;&lt;/i&gt;. This gives two methods to my class: &lt;a href="http://msdn.microsoft.com/en-us/library/system.servicemodel.dispatcher.iclientmessageinspector.beforesendrequest.aspx"&gt;BeforeSendRequest&lt;/a&gt; and &lt;a href="http://msdn.microsoft.com/en-us/library/system.servicemodel.dispatcher.iclientmessageinspector.afterreceivereply.aspx"&gt;AfterReceiveReply&lt;/a&gt;.&lt;/p&gt;  &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;object&lt;/span&gt; BeforeSendRequest(&lt;span class="kwrd"&gt;ref&lt;/span&gt; System.ServiceModel.Channels.Message request, 
    System.ServiceModel.IClientChannel channel)
{
    &lt;span class="kwrd"&gt;string&lt;/span&gt; securityHeader = HeaderHelper.GetSecurityHeader(&lt;span class="kwrd"&gt;this&lt;/span&gt;._username, &lt;span class="kwrd"&gt;this&lt;/span&gt;._password, &lt;span class="kwrd"&gt;this&lt;/span&gt;._crmUri);
            
    request.Headers.Add(MessageHeader.CreateHeader(&lt;span class="str"&gt;&amp;quot;Security&amp;quot;&lt;/span&gt;,
        WSSecurityUsernameTokenProfileNamespace,
        &lt;span class="kwrd"&gt;string&lt;/span&gt;.Empty,
        &lt;span class="kwrd"&gt;new&lt;/span&gt; SecurityHeaderSerializer(securityHeader),&lt;span class="kwrd"&gt;true&lt;/span&gt;));

    &lt;span class="kwrd"&gt;return&lt;/span&gt; &lt;span class="kwrd"&gt;null&lt;/span&gt;;
}&lt;/pre&gt;

&lt;p&gt;In the BeforeSendRequest method is where I can add the security header to the message before the message is sent out. The the BeforeSendRequest method I call a helper class returning the actual header. The GetSecurityHeader method is going through four steps to build up the header:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Get Windows Live Device Credentials &lt;/li&gt;

  &lt;li&gt;Register Device Credentials and get binaryDAToken &lt;/li&gt;

  &lt;li&gt;Get Security Token by sending WLID username, password and device binaryDAToken &lt;/li&gt;

  &lt;li&gt;Build up the security header with the token from previous step. &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;b&gt;(This sample does not cache the tokens! I strongly suggest you add some caching logic before you run this in production)&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;After the header is created it is added to the request, using a custom serializer, as it would otherwise be HTML encoded. &lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; AfterReceiveReply(&lt;span class="kwrd"&gt;ref&lt;/span&gt; System.ServiceModel.Channels.Message reply, &lt;span class="kwrd"&gt;object&lt;/span&gt; correlationState)
{
    Trace.WriteLine(&lt;span class="str"&gt;&amp;quot;[bLogical] LiveIdAuthenticationMessageInspector:AfterReceiveReply called&amp;quot;&lt;/span&gt;);
    &lt;span class="kwrd"&gt;int&lt;/span&gt; index = reply.Headers.FindHeader(&lt;span class="str"&gt;&amp;quot;Security&amp;quot;&lt;/span&gt;, WSSecurityUsernameTokenProfileNamespace);
    reply.Headers.RemoveAt(index);
}&lt;/pre&gt;

&lt;p&gt;When BizTalk (or any other WCF client) receives the response it will throw an exception, as it doesn’t understand the Security header. I might have gone away with adding the http:&lt;a href="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" title="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"&gt;http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd&lt;/a&gt; schema to BizTalk, but as I don’t need it, I just removed it from the header on the way back.&lt;/p&gt;

&lt;p&gt;Part from the Message Inspector, I also added an EndpointBehavior and a BehaviorExtensionElement. The LiveIdAuthenticationBehaviorExtensionElement needs to be registered in the configuration using the behavior in BizTalk&lt;/p&gt;

&lt;p&gt;After you have registered the behavior, you can focus on the normal BizTalk tasks like building orchestrations and mappings. To get started with consuming the CRM Services, have a look at Richards &lt;a href="http://seroter.wordpress.com/2011/02/10/the-good-bad-and-ugly-of-integrating-dynamics-crm-2011-and-biztalk-server-2010/"&gt;post&lt;/a&gt;. The only thing I’d like to emphasis is that the correct schemas are part of the SDK (sdk\schemas). After you run the &lt;i&gt;Consume WCF Service &lt;/i&gt;Wizard, remove all schemas and replace them with the the once in the SDK. Better yet, put all those schemas in a separate schema project, and reference that project from other projects where you’re using them. &lt;/p&gt;

&lt;h4&gt;1. Add the behavior to the Global Assembly Cache&lt;/h4&gt;

&lt;p&gt;Open up the &lt;i&gt;LiveIdAuthentication&lt;/i&gt; project, build and add it to the global assembly cache.&lt;/p&gt;

&lt;h4&gt;2. Register the behavior in the configuration&lt;/h4&gt;

&lt;p&gt;(sorry about the formatting). &lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;extensions&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;behaviorExtensions&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;name&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;liveIdAuthentication&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;type&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;LiveIdAuthentication.LiveIdAuthenticationBehaviorExtensionElement, LiveIdAuthentication, Version=1.0.0.0, Culture=neutral, PublicKeyToken=698ceec8cebc73ae&amp;quot;&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;behaviorExtensions&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;extensions&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;You can do this either in a config file (machine.config or BTSNTSvc[64].exe.config) or in BizTalk (WCF-Custom Send handler):&lt;/p&gt;

&lt;p&gt;&lt;a href="http://blogical.se/blogs/mikael/image_167D68DB.png"&gt;&lt;img src="http://blogical.se/blogs/mikael/image_thumb_03C86F24.png" style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" alt="image" height="484" width="376" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I prefer the later as I would otherwise need to make the changes to all the servers in the group. Just copy the extension element above, into a config file, and import the file from the Transport Properties dialog above. Or you can point to the app.config file in the sample.&lt;/p&gt;

&lt;h4&gt;3. Add the Endpoint Behavior&lt;/h4&gt;

&lt;p&gt;Open the send port and click the &lt;i&gt;Configure &lt;/i&gt;button to open the WCF Transport Porperties. Select the &lt;i&gt;Behavior&lt;/i&gt; tab and right-click the Endpoint behavior node, and select &lt;i&gt;Add extension. &lt;/i&gt;Select the &lt;i&gt;&lt;b&gt;liveAuthentication&lt;/b&gt;&lt;/i&gt; extensions. Select the extension and set the properties.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://blogical.se/blogs/mikael/image_49D92C37.png"&gt;&lt;img src="http://blogical.se/blogs/mikael/image_thumb_2951EC85.png" style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" alt="image" height="484" width="348" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&amp;nbsp;&lt;/p&gt;

&lt;p&gt;You’re done.&lt;/p&gt;

&lt;p&gt;Use this code as you like, and on your own risk. If you make improvements, I’d appreciate if you notify me. One thing I know could be done better, would be to cache the tokens and re-use them for the next call.&lt;/p&gt;

&lt;p&gt;&amp;nbsp;&lt;/p&gt;

&lt;p&gt;&lt;a href="http://blogical.se/files/folders/downloads/entry28440.aspx"&gt;Download the Dynamics CRM LiveId Authentication Behavior sample here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;HTH&lt;/p&gt;&lt;img src="http://blogical.se/aggbug.aspx?PostID=28410" width="1" height="1"&gt;</description><category domain="http://blogical.se/blogs/mikael/archive/tags/BizTalk/default.aspx">BizTalk</category><category domain="http://blogical.se/blogs/mikael/archive/tags/WCF/default.aspx">WCF</category><category domain="http://blogical.se/blogs/mikael/archive/tags/Adapters/default.aspx">Adapters</category><category domain="http://blogical.se/blogs/mikael/archive/tags/Dynamics+CRM+Online/default.aspx">Dynamics CRM Online</category></item><item><title>Recordings from Enfo Integration Days are available</title><link>http://blogical.se/blogs/mikael/archive/2011/11/28/recordings-from-enfo-integration-days-are-available.aspx</link><pubDate>Mon, 28 Nov 2011 18:00:36 GMT</pubDate><guid isPermaLink="false">19a535f3-07d9-4378-9c5a-8d019d91e842:28222</guid><dc:creator>wmmihaa</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;Every year my employer hosts a two day event all related to integration or service orientation. Around 450 people attended this year, which I assumes makes it the biggest event of the year in the integration space, with more then 25 sessions on four different tracks. All Microsoft related session were recorded and are now available. &lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://www.youtube.com/watch?v=5cLQBMeS-aU"&gt;Microsoft BizTalk Server and Microsoft’s Middleware vision&lt;/a&gt; (Marcus Gullberg, Microsoft) –SWEDISH&lt;/li&gt;    &lt;li&gt;&lt;a href="http://www.youtube.com/watch?v=IqDPmW2Fdts"&gt;Microsoft BizTalk Server &amp;amp; Windows Azure AppFabric&lt;/a&gt; (Mikael Håkansson, Enfo Zystems) –SWEDISH&lt;/li&gt;    &lt;li&gt;&lt;a href="http://www.youtube.com/watch?v=cPK4rr8HsYY"&gt;Windows Azure AppFabric Platform futures&lt;/a&gt; (Johan Hedberg, Enfo Zystems) –SWEDISH&lt;/li&gt;    &lt;li&gt;&lt;a href="http://www.youtube.com/watch?v=RyAQ-9JQtl0"&gt;BaseLine for BizTalk Hands On&lt;/a&gt; (Martin Rydman &amp;amp; Mikael Håkansson, Enfo Zystems ) –SWEDISH&lt;/li&gt;    &lt;li&gt;&lt;a href="http://www.youtube.com/watch?v=Q-ONkEVD-tw"&gt;Using AppFabric Cache to Maximize the Performance of Your Windows Azure and On Premises WCF Applications&lt;/a&gt; (Paolo Salvatori, Microsoft) –ENGLISH&lt;/li&gt;    &lt;li&gt;&lt;a href="http://www.youtube.com/watch?v=PymrPY9jdqQ"&gt;How to integrate BizTalk Server with Windows Azure Service Bus Messaging. &lt;/a&gt;(Paolo Salvatori, Microsoft) –ENGLISH&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Enjoy, an we hope you join us next year.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;img src="http://blogical.se/blogs/mikael/image_7BDB1DF6.png" alt="" /&gt;&lt;/p&gt;&lt;img src="http://blogical.se/aggbug.aspx?PostID=28222" width="1" height="1"&gt;</description></item><item><title>Enfo Zystems is sponsoring a two day event focusing all on integration.</title><link>http://blogical.se/blogs/mikael/archive/2011/09/14/enfo-zystems-is-sponsoring-a-two-day-event-focusing-all-on-integration.aspx</link><pubDate>Wed, 14 Sep 2011 19:59:00 GMT</pubDate><guid isPermaLink="false">19a535f3-07d9-4378-9c5a-8d019d91e842:27553</guid><dc:creator>wmmihaa</dc:creator><slash:comments>0</slash:comments><description>&lt;h2&gt;Welcome to Integration days 2011!&lt;/h2&gt;  &lt;p&gt;If you are in the integration space, you’ll find all kinds of interesting and valuable sessions in any of the four tracks; &lt;i&gt;Strategy, Public, Microsoft&lt;/i&gt; and &lt;i&gt;IBM&lt;/i&gt;. Each track has six sessions with speakers from both &lt;a href="http://zystems.se"&gt;Enfo Zystems&lt;/a&gt; and other partner organizations such as Microsoft.&lt;/p&gt;  &lt;p&gt;At Thursday evening, you’re invited for dinner with entertainment, which of course will be a great time to meet up with other integration geeks (such as myself…)&lt;/p&gt;  &lt;p&gt;And the best of all…&lt;b&gt; –It’s all free, so &lt;/b&gt;&lt;a href="http://integrationdays.com"&gt;&lt;b&gt;sign up now!&lt;/b&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://integrationdays.com"&gt;&lt;img src="http://blogical.se/blogs/mikael/image_7BDB1DF6.png" style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" alt="image" border="0" height="85" width="323" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;   &lt;br /&gt;The event starts on the 13&lt;sup&gt;th&lt;/sup&gt;of October and covers four tracks, each with six sessions. The Microsoft platform track will cover the following six sessions: &lt;/p&gt;  &lt;h3&gt;Microsoft BizTalk Server and Microsoft’s Middleware vision&lt;/h3&gt;  &lt;h3&gt;&lt;/h3&gt;  &lt;h4&gt;&lt;/h4&gt;  &lt;p&gt;&lt;i&gt;BizTalk Server has been at the center of Microsoft’s Middleware platform for a number of years, to provide a rich set of capabilities for services and integration. AppFabric, both on-premise and on Windows Azure provides additional capabilities as well as some overlapping ones. So what is the strategy here, what is Microsoft up to long term and short term? How will this affect solutions you create and what opportunities will it create for your company? In this session, you will get the answers to these questions.&lt;/i&gt;     &lt;br /&gt;&lt;b&gt;Presenter: Marcus Gullberg, PM Microsoft Sweden&lt;/b&gt;     &lt;br /&gt;&lt;/p&gt;  &lt;h3&gt;Microsoft BizTalk Server &amp;amp; Windows Azure AppFabric&lt;/h3&gt;  &lt;p&gt;&lt;i&gt;Microsoft’s Middleware platform is currently undergoing a change, which in turn offers different solutions with unique capabilities. What is available today, and how can we today make these solutions work together? This session will cover Microsoft BizTalk Server, Windows Server AppFabric and Azure AppFabric, to show how you can extend the reach of your integration platform outside your own domain.&lt;/i&gt;     &lt;br /&gt;&lt;b&gt;Presenter: Mikael Håkansson, Solution Architect, Enfo Zystems&lt;/b&gt;     &lt;br /&gt;&lt;/p&gt;  &lt;h3&gt;Windows Azure AppFabric Platform futures &lt;/h3&gt;  &lt;p&gt;&lt;i&gt;Where is the future of Microsoft’s Middleware platform going? How will we design, build and monitor our solutions in the future? What capabilities will we have in our tool box? These and many other questions will be addressed in this session, which will focus on Microsoft Azure AppFabric Platform and emerging capabilities such as Composite Application, Access Control Center, Caching, ServiceBus Topics &amp;amp; Queues and other enhancements, and Integration. &lt;/i&gt;    &lt;br /&gt;&lt;b&gt;Presenter: Johan Hedberg, Solution Architect, Enfo Zystems&lt;/b&gt;     &lt;br /&gt;&lt;/p&gt;  &lt;h3&gt;Using AppFabric Cache to Maximize the Performance of Your Windows Azure and On Premises WCF Applications&lt;/h3&gt;  &lt;p&gt;&lt;i&gt;Caching is an integral part of an overall scaling strategy. By properly utilizing caching you can radically increase the number of concurrent users your application can service. Much of the caching information available to users today only focuses on server side caching. Server side caching is important, we will cover it in this session, and we will show concrete techniques to maximize its effectiveness . However, this session will also cover client side caching techniques. Client side techniques are often overlooked in spite of the fact that in order to truly hit extreme scale those techniques are nearly always necessary and often end up being bolted on after the fact. After attending this session, the attendees will walk away with the concrete knowledge and code necessary to immediately improve their WCF application performance.&lt;/i&gt;     &lt;br /&gt;&lt;b&gt;Presenter: Paolo Salvatori and Mikael Håkansson      &lt;br /&gt;&lt;/b&gt;&lt;/p&gt;  &lt;h3&gt;Deep dive: How to integrate BizTalk Server with Windows Azure Service Bus Messaging&lt;/h3&gt;  &lt;p&gt;&lt;i&gt;The Windows Azure AppFabric Service Bus and Windows Azure Connect are the foundation for building a new class of distributed and hybrid applications that span the cloud and on premises environments. The Service Bus is an Internet-scale Service Bus that offers secure, scalable and highly available connectivity and messaging capabilities. Windows Azure Connect provides a network-level bridge between applications and services running in the cloud and on-premises data centers. Windows Azure Connect makes it easier for an organization to migrate their existing applications to the cloud by enabling direct IP-based network connectivity with their existing on-premises infrastructure. In this session you will see how to integrate these technologies with BizTalk Server to create solid and cloud-ready solutions.&lt;/i&gt;     &lt;br /&gt;&lt;b&gt;Presenter: Paolo Salvatori, &lt;i&gt;Senior Program Manager Microsoft&lt;/i&gt;&lt;/b&gt;     &lt;br /&gt;&lt;/p&gt;  &lt;h3&gt;Baseline for BizTalk Hands-on&lt;/h3&gt;  &lt;p&gt;&lt;i&gt;Baseline provides a comprehensive framework that supports the design, development and maintenance of systems integration solutions. In this session we will provide a practical example of how to use the Baseline methodology and tools to refine project requirements into a working BizTalk solution – tested, documented and packaged, ready for deployment in BizTalk Server 2010. In the process we will use Baseline documents and the Baseline Portal to highlight the main strengths of Baseline.&lt;/i&gt;     &lt;br /&gt;&lt;b&gt;Presenter: Martin Rydman and Mikael Håkansson&lt;/b&gt;&lt;/p&gt;&lt;img src="http://blogical.se/aggbug.aspx?PostID=27553" width="1" height="1"&gt;</description><category domain="http://blogical.se/blogs/mikael/archive/tags/BizTalk/default.aspx">BizTalk</category><category domain="http://blogical.se/blogs/mikael/archive/tags/Fun/default.aspx">Fun</category><category domain="http://blogical.se/blogs/mikael/archive/tags/Azure/default.aspx">Azure</category><category domain="http://blogical.se/blogs/mikael/archive/tags/BizTalk+2010/default.aspx">BizTalk 2010</category><category domain="http://blogical.se/blogs/mikael/archive/tags/AppFabric/default.aspx">AppFabric</category><category domain="http://blogical.se/blogs/mikael/archive/tags/AppFabic+Cache/default.aspx">AppFabic Cache</category><category domain="http://blogical.se/blogs/mikael/archive/tags/Event/default.aspx">Event</category></item><item><title>Scripts used at my TechEd session (MID309 | Configuring Microsoft BizTalk Server for Performance)</title><link>http://blogical.se/blogs/mikael/archive/2011/05/22/scripts-used-at-my-teched-session-mid309-configuring-microsoft-biztalk-server-for-performance.aspx</link><pubDate>Sun, 22 May 2011 18:52:00 GMT</pubDate><guid isPermaLink="false">19a535f3-07d9-4378-9c5a-8d019d91e842:25309</guid><dc:creator>wmmihaa</dc:creator><slash:comments>1</slash:comments><description>&lt;p&gt;Thanks to everyone attending my TechEd session on Thursday. You can find the scripts I was running &lt;a href="http://blogical.se/files/folders/downloads/entry25306.aspx" target="_blank"&gt;here&lt;/a&gt; (sorry I didn’t put them up earlier). Let me know if you have any trouble.&lt;/p&gt;
&lt;p&gt;If you didn’t attend, you can view the session online &lt;a href="http://channel9.msdn.com/Events/TechEd/NorthAmerica/2011/MID309" target="_blank"&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogical.se/blogs/mikael/image_65E4E344.png"&gt;&lt;img style="BACKGROUND-IMAGE:none;BORDER-BOTTOM:0px;BORDER-LEFT:0px;PADDING-LEFT:0px;PADDING-RIGHT:0px;DISPLAY:inline;BORDER-TOP:0px;BORDER-RIGHT:0px;PADDING-TOP:0px;" title="image" border="0" alt="image" src="http://blogical.se/blogs/mikael/image_thumb_400EBCE1.png" width="644" height="155" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Good luck&lt;/p&gt;
&lt;p&gt;//Mikael&lt;/p&gt;&lt;img src="http://blogical.se/aggbug.aspx?PostID=25309" width="1" height="1"&gt;</description><category domain="http://blogical.se/blogs/mikael/archive/tags/BizTalk/default.aspx">BizTalk</category><category domain="http://blogical.se/blogs/mikael/archive/tags/BizTalk+2010/default.aspx">BizTalk 2010</category><category domain="http://blogical.se/blogs/mikael/archive/tags/Performance/default.aspx">Performance</category></item><item><title>Demos from the How to do integration with Office365 and On-Premise Applications at TechEd (MID372-INT)</title><link>http://blogical.se/blogs/mikael/archive/2011/05/18/demos-from-the-how-to-do-integration-with-office365-and-on-premise-applications-at-teched-mid372-int.aspx</link><pubDate>Wed, 18 May 2011 16:51:00 GMT</pubDate><guid isPermaLink="false">19a535f3-07d9-4378-9c5a-8d019d91e842:25154</guid><dc:creator>wmmihaa</dc:creator><slash:comments>2</slash:comments><description>&lt;font size="3" face="Times New Roman"&gt;

&lt;/font&gt;&lt;p style="margin:0cm 0cm 10pt;" class="MsoNormal"&gt;&lt;font size="3"&gt;&lt;font face="Calibri"&gt;Thanks to everyone attending my session on integration with
Office365 and on-prem applications.&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;&lt;font size="3" face="Times New Roman"&gt;

&lt;/font&gt;&lt;p style="margin:0cm 0cm 10pt;" class="MsoNormal"&gt;&lt;font size="3" face="Calibri"&gt;All demos can be downloaded from here: &lt;/font&gt;&lt;a href="http://blogical.se/files/folders/downloads/entry25152.aspx"&gt;&lt;font color="#0000ff" size="3" face="Calibri"&gt;http://blogical.se/files/folders/downloads/entry25152.aspx&lt;/font&gt;&lt;/a&gt;&lt;/p&gt;&lt;font size="3" face="Times New Roman"&gt;

&lt;/font&gt;&lt;p style="margin:0cm 0cm 10pt;" class="MsoNormal"&gt;&lt;font size="3"&gt;&lt;font face="Calibri"&gt;I recommended you to start downloading the AppFabric SDK CTP,
in which you’ll find the ClientAccessPolicyPublisher sample I was running in
the last sample: &lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;a href="http://www.microsoft.com/downloads/en/details.aspx?FamilyID=d89640fc-c552-446e-aead-b1e0d940f31b"&gt;&lt;font color="#0000ff" size="3" face="Calibri"&gt;http://www.microsoft.com/downloads/en/details.aspx?FamilyID=d89640fc-c552-446e-aead-b1e0d940f31b&lt;/font&gt;&lt;/a&gt;&lt;/p&gt;&lt;font size="3" face="Times New Roman"&gt;

&lt;/font&gt;&lt;span style="line-height:115%;font-size:11pt;mso-ascii-theme-font:minor-latin;mso-fareast-font-family:Calibri;mso-fareast-theme-font:minor-latin;mso-hansi-theme-font:minor-latin;mso-bidi-theme-font:minor-bidi;mso-ansi-language:EN-US;mso-fareast-language:EN-US;mso-bidi-language:AR-SA;"&gt;Good luck and let me know if you need any
additional help.&lt;/span&gt;&lt;img src="http://blogical.se/aggbug.aspx?PostID=25154" width="1" height="1"&gt;</description><category domain="http://blogical.se/blogs/mikael/archive/tags/BizTalk/default.aspx">BizTalk</category><category domain="http://blogical.se/blogs/mikael/archive/tags/Azure/default.aspx">Azure</category><category domain="http://blogical.se/blogs/mikael/archive/tags/BizTalk+2010/default.aspx">BizTalk 2010</category><category domain="http://blogical.se/blogs/mikael/archive/tags/AppFabric/default.aspx">AppFabric</category><category domain="http://blogical.se/blogs/mikael/archive/tags/Workflow/default.aspx">Workflow</category><category domain="http://blogical.se/blogs/mikael/archive/tags/Office365/default.aspx">Office365</category></item></channel></rss>