<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-3696827856353448753</id><updated>2011-07-28T22:33:40.559-07:00</updated><title type='text'>Connecting Systems</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://connectingsystems.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3696827856353448753/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://connectingsystems.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Grant Samuels</name><uri>http://www.blogger.com/profile/07008298142913353091</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>10</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-3696827856353448753.post-7215946992857854568</id><published>2009-12-17T01:45:00.001-08:00</published><updated>2009-12-17T01:51:45.983-08:00</updated><title type='text'>WCF Behavior To Remove Whitespace</title><content type='html'>&lt;p&gt;After finding a bug in the way BizTalk executes body xpath expressions in WCF ports (&lt;a href="http://social.msdn.microsoft.com/Forums/en-US/biztalkesb/thread/9751bb57-6d86-4cc8-ba01-7cc77e95c4dc/"&gt;details here&lt;/a&gt;) I came up with a custom behavior to remove the leading and trailing whitespace in an inbound xml message.&lt;/p&gt;  &lt;p&gt;First the WCF behavior needs to be implemented, it looks like:&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:c414cf11-41a2-493b-a794-84c8ffe06c4a" class="wlWriterEditableSmartContent"&gt;&lt;pre style="background-color:#FFFFFF;overflow: auto;;font-family:Courier New;font-size:8.25"&gt;&lt;span style="color: #0000FF;"&gt;using&lt;/span&gt;&lt;span style="color: #000000;"&gt; System;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;using&lt;/span&gt;&lt;span style="color: #000000;"&gt; System.Collections.Generic;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;using&lt;/span&gt;&lt;span style="color: #000000;"&gt; System.IO;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;using&lt;/span&gt;&lt;span style="color: #000000;"&gt; System.Linq;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;using&lt;/span&gt;&lt;span style="color: #000000;"&gt; System.ServiceModel;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;using&lt;/span&gt;&lt;span style="color: #000000;"&gt; System.ServiceModel.Channels;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;using&lt;/span&gt;&lt;span style="color: #000000;"&gt; System.ServiceModel.Configuration;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;using&lt;/span&gt;&lt;span style="color: #000000;"&gt; System.ServiceModel.Dispatcher;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;using&lt;/span&gt;&lt;span style="color: #000000;"&gt; System.Text;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;using&lt;/span&gt;&lt;span style="color: #000000;"&gt; System.ServiceModel.Description;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;using&lt;/span&gt;&lt;span style="color: #000000;"&gt; System.Xml;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;using&lt;/span&gt;&lt;span style="color: #000000;"&gt; System.Xml.Linq;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;using&lt;/span&gt;&lt;span style="color: #000000;"&gt; System.Xml.XPath;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;using&lt;/span&gt;&lt;span style="color: #000000;"&gt; My.Helpers.Xml;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;namespace&lt;/span&gt;&lt;span style="color: #000000;"&gt; My.Helpers.WcfBehaviors&lt;br /&gt;{&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;public&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;class&lt;/span&gt;&lt;span style="color: #000000;"&gt; NormalizeMessageBehaviorExtension : BehaviorExtensionElement&lt;br /&gt;    {&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;public&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;override&lt;/span&gt;&lt;span style="color: #000000;"&gt; Type BehaviorType&lt;br /&gt;        {&lt;br /&gt;            &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;get&lt;/span&gt;&lt;span style="color: #000000;"&gt; { &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;return&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;typeof&lt;/span&gt;&lt;span style="color: #000000;"&gt;(NormalizeMessageEndpointBehavior); }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;protected&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;override&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;object&lt;/span&gt;&lt;span style="color: #000000;"&gt; CreateBehavior()&lt;br /&gt;        {&lt;br /&gt;            &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;return&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;new&lt;/span&gt;&lt;span style="color: #000000;"&gt; NormalizeMessageEndpointBehavior();&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;public&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;class&lt;/span&gt;&lt;span style="color: #000000;"&gt; NormalizeMessageEndpointBehavior : IEndpointBehavior&lt;br /&gt;    {&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;#region&lt;/span&gt;&lt;span style="color: #000000;"&gt; IEndpointBehavior Members&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;public&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;void&lt;/span&gt;&lt;span style="color: #000000;"&gt; AddBindingParameters(ServiceEndpoint endpoint, System.ServiceModel.Channels.BindingParameterCollection bindingParameters)&lt;br /&gt;        { }&lt;br /&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;public&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;void&lt;/span&gt;&lt;span style="color: #000000;"&gt; ApplyClientBehavior(ServiceEndpoint endpoint, System.ServiceModel.Dispatcher.ClientRuntime clientRuntime)&lt;br /&gt;        { }&lt;br /&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;public&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;void&lt;/span&gt;&lt;span style="color: #000000;"&gt; ApplyDispatchBehavior(ServiceEndpoint endpoint, System.ServiceModel.Dispatcher.EndpointDispatcher endpointDispatcher)&lt;br /&gt;        {&lt;br /&gt;            endpointDispatcher.DispatchRuntime.MessageInspectors.Add(&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;new&lt;/span&gt;&lt;span style="color: #000000;"&gt; NormalizeMessageInspector());&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;public&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;void&lt;/span&gt;&lt;span style="color: #000000;"&gt; Validate(ServiceEndpoint endpoint)&lt;br /&gt;        { }&lt;br /&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;#endregion&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;public&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;class&lt;/span&gt;&lt;span style="color: #000000;"&gt; NormalizeMessageInspector : IDispatchMessageInspector&lt;br /&gt;    {&lt;br /&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;#region&lt;/span&gt;&lt;span style="color: #000000;"&gt; IDispatchMessageInspector Members&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;public&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;object&lt;/span&gt;&lt;span style="color: #000000;"&gt; AfterReceiveRequest(&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;ref&lt;/span&gt;&lt;span style="color: #000000;"&gt; Message request, IClientChannel channel, InstanceContext instanceContext)&lt;br /&gt;        {&lt;br /&gt;            request &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; NormalizeMessage(request);&lt;br /&gt;            &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;return&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;null&lt;/span&gt;&lt;span style="color: #000000;"&gt;;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;public&lt;/span&gt;&lt;span style="color: #000000;"&gt; Message NormalizeMessage(Message inboundMessage)&lt;br /&gt;        {&lt;br /&gt;            Message normalizedMessage &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;null&lt;/span&gt;&lt;span style="color: #000000;"&gt;;&lt;br /&gt;            MessageBuffer buffer &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; inboundMessage.CreateBufferedCopy(Int32.MaxValue);&lt;br /&gt;            Message tempMessage &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; buffer.CreateMessage();&lt;br /&gt;&lt;br /&gt;            &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;using&lt;/span&gt;&lt;span style="color: #000000;"&gt; (var inputStream &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;new&lt;/span&gt;&lt;span style="color: #000000;"&gt; MemoryStream())&lt;br /&gt;            {&lt;br /&gt;                &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;using&lt;/span&gt;&lt;span style="color: #000000;"&gt; (var writer &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; XmlDictionaryWriter.CreateTextWriter(inputStream, Encoding.UTF8))&lt;br /&gt;                {&lt;br /&gt;                    tempMessage.WriteBodyContents(writer);&lt;br /&gt;                    writer.Flush();&lt;br /&gt;&lt;br /&gt;                    inputStream.Position &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #800080;"&gt;0&lt;/span&gt;&lt;span style="color: #000000;"&gt;;&lt;br /&gt;&lt;br /&gt;                    &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;using&lt;/span&gt;&lt;span style="color: #000000;"&gt; (MemoryStream outputStream &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;new&lt;/span&gt;&lt;span style="color: #000000;"&gt; MemoryStream())&lt;br /&gt;                    {&lt;br /&gt;                        XmlParser.Normalize(inputStream, outputStream);&lt;br /&gt;&lt;br /&gt;                        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;using&lt;/span&gt;&lt;span style="color: #000000;"&gt; (var reader &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; XmlReader.Create(outputStream))&lt;br /&gt;                        {&lt;br /&gt;                            normalizedMessage &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; Message.CreateMessage(inboundMessage.Version, &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;null&lt;/span&gt;&lt;span style="color: #000000;"&gt;, reader);&lt;br /&gt;                            normalizedMessage.Headers.CopyHeadersFrom(inboundMessage);&lt;br /&gt;                            normalizedMessage.Properties.CopyProperties(inboundMessage.Properties);&lt;br /&gt;                            buffer &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; normalizedMessage.CreateBufferedCopy(Int32.MaxValue);&lt;br /&gt;                        }&lt;br /&gt;                    }&lt;br /&gt;                }&lt;br /&gt;            }&lt;br /&gt;            &lt;br /&gt;            &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;return&lt;/span&gt;&lt;span style="color: #000000;"&gt; buffer.CreateMessage();&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;public&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;void&lt;/span&gt;&lt;span style="color: #000000;"&gt; BeforeSendReply(&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;ref&lt;/span&gt;&lt;span style="color: #000000;"&gt; Message reply, &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;object&lt;/span&gt;&lt;span style="color: #000000;"&gt; correlationState)&lt;br /&gt;        { }&lt;br /&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;#endregion&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Then the code for the normalize looks like this:&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:9ea707d2-3bd2-45e2-8405-556858bce191" class="wlWriterEditableSmartContent"&gt;&lt;pre style="background-color:#FFFFFF;overflow: auto;;font-family:Courier New;font-size:8.25"&gt;&lt;span style="color: #0000FF;"&gt;using&lt;/span&gt;&lt;span style="color: #000000;"&gt; System;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;using&lt;/span&gt;&lt;span style="color: #000000;"&gt; System.Diagnostics;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;using&lt;/span&gt;&lt;span style="color: #000000;"&gt; System.IO;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;using&lt;/span&gt;&lt;span style="color: #000000;"&gt; System.Linq;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;using&lt;/span&gt;&lt;span style="color: #000000;"&gt; System.Reflection;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;using&lt;/span&gt;&lt;span style="color: #000000;"&gt; System.Text;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;using&lt;/span&gt;&lt;span style="color: #000000;"&gt; System.Xml.Linq;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;using&lt;/span&gt;&lt;span style="color: #000000;"&gt; System.Xml;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;using&lt;/span&gt;&lt;span style="color: #000000;"&gt; My.Helpers.Utility;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;namespace&lt;/span&gt;&lt;span style="color: #000000;"&gt; My.Helpers.Xml&lt;br /&gt;{&lt;br /&gt;    [Serializable]&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;public&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;class&lt;/span&gt;&lt;span style="color: #000000;"&gt; XmlParser&lt;br /&gt;    {&lt;br /&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;public&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;static&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;void&lt;/span&gt;&lt;span style="color: #000000;"&gt; Normalize(Stream inputStream, Stream outputStream)&lt;br /&gt;        {&lt;br /&gt;            &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;try&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;            {&lt;br /&gt;                XmlReaderSettings readerSettings &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;new&lt;/span&gt;&lt;span style="color: #000000;"&gt; XmlReaderSettings() { ValidationType &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; ValidationType.None };&lt;br /&gt;&lt;br /&gt;                StreamReader tempReader &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;new&lt;/span&gt;&lt;span style="color: #000000;"&gt; StreamReader(inputStream);&lt;br /&gt;                Encoding encoding &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; tempReader.CurrentEncoding &lt;/span&gt;&lt;span style="color: #000000;"&gt;??&lt;/span&gt;&lt;span style="color: #000000;"&gt; Encoding.UTF8;&lt;br /&gt;&lt;br /&gt;                XmlReader reader &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; XmlReader.Create(inputStream, readerSettings);&lt;br /&gt;&lt;br /&gt;                XmlWriterSettings writerSettings &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;new&lt;/span&gt;&lt;span style="color: #000000;"&gt; XmlWriterSettings() { ConformanceLevel &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; ConformanceLevel.Auto, Encoding &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; encoding };&lt;br /&gt;                XmlWriter writer &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; XmlWriter.Create(outputStream, writerSettings);&lt;br /&gt;&lt;br /&gt;                &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;while&lt;/span&gt;&lt;span style="color: #000000;"&gt; (reader.Read())&lt;br /&gt;                {&lt;br /&gt;                    &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;switch&lt;/span&gt;&lt;span style="color: #000000;"&gt; (reader.NodeType)&lt;br /&gt;                    {&lt;br /&gt;                        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;case&lt;/span&gt;&lt;span style="color: #000000;"&gt; XmlNodeType.Element:&lt;br /&gt;                            writer.WriteStartElement(reader.Prefix, reader.LocalName, reader.NamespaceURI);&lt;br /&gt;                            &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;if&lt;/span&gt;&lt;span style="color: #000000;"&gt; (reader.IsEmptyElement)&lt;br /&gt;                                writer.WriteEndElement();&lt;br /&gt;                            &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;else&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;                            {&lt;br /&gt;                                &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;while&lt;/span&gt;&lt;span style="color: #000000;"&gt; (reader.MoveToNextAttribute())&lt;br /&gt;                                {&lt;br /&gt;                                    &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;if&lt;/span&gt;&lt;span style="color: #000000;"&gt; (reader.Value.Length &lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #800080;"&gt;0&lt;/span&gt;&lt;span style="color: #000000;"&gt;)&lt;br /&gt;                                    {&lt;br /&gt;                                        writer.WriteStartAttribute(reader.Prefix, reader.LocalName, reader.NamespaceURI);&lt;br /&gt;                                        writer.WriteString(NormalizeString(reader.Value));&lt;br /&gt;                                        writer.WriteEndAttribute();&lt;br /&gt;                                    }&lt;br /&gt;                                    &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;else&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;                                    {&lt;br /&gt;                                        writer.WriteStartAttribute(reader.Prefix, reader.LocalName, reader.NamespaceURI);&lt;br /&gt;                                        writer.WriteString(reader.Value);&lt;br /&gt;                                        writer.WriteEndAttribute();&lt;br /&gt;                                    }&lt;br /&gt;                                }&lt;br /&gt;                            }&lt;br /&gt;                            &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;break&lt;/span&gt;&lt;span style="color: #000000;"&gt;;&lt;br /&gt;                        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;case&lt;/span&gt;&lt;span style="color: #000000;"&gt; XmlNodeType.Text:&lt;br /&gt;                            &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;string&lt;/span&gt;&lt;span style="color: #000000;"&gt; text &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; reader.Value;&lt;br /&gt;                            &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;if&lt;/span&gt;&lt;span style="color: #000000;"&gt; (text.Length &lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #800080;"&gt;0&lt;/span&gt;&lt;span style="color: #000000;"&gt;)&lt;br /&gt;                            {&lt;br /&gt;                                writer.WriteString(NormalizeString(reader.Value));&lt;br /&gt;                            }&lt;br /&gt;                            &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;else&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;                                writer.WriteString(text);&lt;br /&gt;                            &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;break&lt;/span&gt;&lt;span style="color: #000000;"&gt;;&lt;br /&gt;&lt;br /&gt;                        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;case&lt;/span&gt;&lt;span style="color: #000000;"&gt; XmlNodeType.CDATA:&lt;br /&gt;                            writer.WriteCData(reader.Value);&lt;br /&gt;                            &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;break&lt;/span&gt;&lt;span style="color: #000000;"&gt;;&lt;br /&gt;                        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;case&lt;/span&gt;&lt;span style="color: #000000;"&gt; XmlNodeType.EntityReference:&lt;br /&gt;                            writer.WriteEntityRef(reader.Name);&lt;br /&gt;                            &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;break&lt;/span&gt;&lt;span style="color: #000000;"&gt;;&lt;br /&gt;                        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;case&lt;/span&gt;&lt;span style="color: #000000;"&gt; XmlNodeType.XmlDeclaration:&lt;br /&gt;                        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;case&lt;/span&gt;&lt;span style="color: #000000;"&gt; XmlNodeType.ProcessingInstruction:&lt;br /&gt;                            writer.WriteProcessingInstruction(reader.Name, reader.Value);&lt;br /&gt;                            &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;break&lt;/span&gt;&lt;span style="color: #000000;"&gt;;&lt;br /&gt;                        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;case&lt;/span&gt;&lt;span style="color: #000000;"&gt; XmlNodeType.Comment:&lt;br /&gt;                            writer.WriteComment(reader.Value);&lt;br /&gt;                            &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;break&lt;/span&gt;&lt;span style="color: #000000;"&gt;;&lt;br /&gt;                        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;case&lt;/span&gt;&lt;span style="color: #000000;"&gt; XmlNodeType.DocumentType:&lt;br /&gt;                            writer.WriteDocType(&lt;br /&gt;                                reader.Name,&lt;br /&gt;                                reader.GetAttribute(Constants.XmlAttribute.Public),&lt;br /&gt;                                reader.GetAttribute(Constants.XmlAttribute.System),&lt;br /&gt;                                reader.Value);&lt;br /&gt;                            &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;break&lt;/span&gt;&lt;span style="color: #000000;"&gt;;&lt;br /&gt;                        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;case&lt;/span&gt;&lt;span style="color: #000000;"&gt; XmlNodeType.Whitespace:&lt;br /&gt;                        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;case&lt;/span&gt;&lt;span style="color: #000000;"&gt; XmlNodeType.SignificantWhitespace:&lt;br /&gt;                            writer.WriteWhitespace(reader.Value);&lt;br /&gt;                            &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;break&lt;/span&gt;&lt;span style="color: #000000;"&gt;;&lt;br /&gt;                        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;case&lt;/span&gt;&lt;span style="color: #000000;"&gt; XmlNodeType.EndElement:&lt;br /&gt;                            writer.WriteFullEndElement();&lt;br /&gt;                            &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;break&lt;/span&gt;&lt;span style="color: #000000;"&gt;;&lt;br /&gt;                    }&lt;br /&gt;                }&lt;br /&gt;&lt;br /&gt;                writer.Flush();&lt;br /&gt;                outputStream.Position &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #800080;"&gt;0&lt;/span&gt;&lt;span style="color: #000000;"&gt;;&lt;br /&gt;&lt;br /&gt;            }&lt;br /&gt;            &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;catch&lt;/span&gt;&lt;span style="color: #000000;"&gt; (Exception ex)&lt;br /&gt;            {&lt;br /&gt;                &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;throw&lt;/span&gt;&lt;span style="color: #000000;"&gt; ex;&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;#region&lt;/span&gt;&lt;span style="color: #000000;"&gt; Normalize Helper Methods&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;private&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;static&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;string&lt;/span&gt;&lt;span style="color: #000000;"&gt; NormalizeString(&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;string&lt;/span&gt;&lt;span style="color: #000000;"&gt; input)&lt;br /&gt;        {&lt;br /&gt;            StringBuilder sb &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;new&lt;/span&gt;&lt;span style="color: #000000;"&gt; StringBuilder();&lt;br /&gt;            &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;string&lt;/span&gt;&lt;span style="color: #000000;"&gt;[] parts &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; input.Split(&lt;br /&gt;                &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;new&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;char&lt;/span&gt;&lt;span style="color: #000000;"&gt;[] {&lt;br /&gt;                               Constants.Char.Space,&lt;br /&gt;                               Constants.Char.NewLine,&lt;br /&gt;                               Constants.Char.Tab,&lt;br /&gt;                               Constants.Char.CarriageReturn,&lt;br /&gt;                               Constants.Char.FormFeed,&lt;br /&gt;                               Constants.Char.VerticalTab&lt;br /&gt;                           },&lt;br /&gt;                StringSplitOptions.RemoveEmptyEntries);&lt;br /&gt;            &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;for&lt;/span&gt;&lt;span style="color: #000000;"&gt; (&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;int&lt;/span&gt;&lt;span style="color: #000000;"&gt; i &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #800080;"&gt;0&lt;/span&gt;&lt;span style="color: #000000;"&gt;; i &lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #000000;"&gt; parts.Length; i&lt;/span&gt;&lt;span style="color: #000000;"&gt;++&lt;/span&gt;&lt;span style="color: #000000;"&gt;)&lt;br /&gt;                sb.AppendFormat(Constants.GeneralFormat.AppendSpace, parts[i]);&lt;br /&gt;            &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;return&lt;/span&gt;&lt;span style="color: #000000;"&gt; sb.ToString().Trim();&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;#endregion&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;internal&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;class&lt;/span&gt;&lt;span style="color: #000000;"&gt; Constants&lt;br /&gt;    {&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;internal&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;class&lt;/span&gt;&lt;span style="color: #000000;"&gt; Char&lt;br /&gt;        {&lt;br /&gt;            &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;internal&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;const&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;char&lt;/span&gt;&lt;span style="color: #000000;"&gt; CarriageReturn &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #800000;"&gt;'&lt;/span&gt;&lt;span style="color: #800000;"&gt;\r&lt;/span&gt;&lt;span style="color: #800000;"&gt;'&lt;/span&gt;&lt;span style="color: #000000;"&gt;;&lt;br /&gt;            &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;internal&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;const&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;char&lt;/span&gt;&lt;span style="color: #000000;"&gt; Comma &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #800000;"&gt;'&lt;/span&gt;&lt;span style="color: #800000;"&gt;,&lt;/span&gt;&lt;span style="color: #800000;"&gt;'&lt;/span&gt;&lt;span style="color: #000000;"&gt;;&lt;br /&gt;            &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;internal&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;const&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;char&lt;/span&gt;&lt;span style="color: #000000;"&gt; FormFeed &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #800000;"&gt;'&lt;/span&gt;&lt;span style="color: #800000;"&gt;\f&lt;/span&gt;&lt;span style="color: #800000;"&gt;'&lt;/span&gt;&lt;span style="color: #000000;"&gt;;&lt;br /&gt;            &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;internal&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;const&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;char&lt;/span&gt;&lt;span style="color: #000000;"&gt; NewLine &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #800000;"&gt;'&lt;/span&gt;&lt;span style="color: #800000;"&gt;\n&lt;/span&gt;&lt;span style="color: #800000;"&gt;'&lt;/span&gt;&lt;span style="color: #000000;"&gt;;&lt;br /&gt;            &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;internal&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;const&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;char&lt;/span&gt;&lt;span style="color: #000000;"&gt; Pipe &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #800000;"&gt;'&lt;/span&gt;&lt;span style="color: #800000;"&gt;|&lt;/span&gt;&lt;span style="color: #800000;"&gt;'&lt;/span&gt;&lt;span style="color: #000000;"&gt;;&lt;br /&gt;            &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;internal&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;const&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;char&lt;/span&gt;&lt;span style="color: #000000;"&gt; Space &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #800000;"&gt;'&lt;/span&gt;&lt;span style="color: #800000;"&gt; &lt;/span&gt;&lt;span style="color: #800000;"&gt;'&lt;/span&gt;&lt;span style="color: #000000;"&gt;;&lt;br /&gt;            &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;internal&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;const&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;char&lt;/span&gt;&lt;span style="color: #000000;"&gt; Tab &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #800000;"&gt;'&lt;/span&gt;&lt;span style="color: #800000;"&gt;\t&lt;/span&gt;&lt;span style="color: #800000;"&gt;'&lt;/span&gt;&lt;span style="color: #000000;"&gt;;&lt;br /&gt;            &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;internal&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;const&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;char&lt;/span&gt;&lt;span style="color: #000000;"&gt; VerticalTab &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #800000;"&gt;'&lt;/span&gt;&lt;span style="color: #800000;"&gt;\v&lt;/span&gt;&lt;span style="color: #800000;"&gt;'&lt;/span&gt;&lt;span style="color: #000000;"&gt;;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;internal&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;class&lt;/span&gt;&lt;span style="color: #000000;"&gt; ContextProperty&lt;br /&gt;        {&lt;br /&gt;            &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;internal&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;const&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;string&lt;/span&gt;&lt;span style="color: #000000;"&gt; SchemaStrongName &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #800000;"&gt;"&lt;/span&gt;&lt;span style="color: #800000;"&gt;SchemaStrongName&lt;/span&gt;&lt;span style="color: #800000;"&gt;"&lt;/span&gt;&lt;span style="color: #000000;"&gt;;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;internal&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;class&lt;/span&gt;&lt;span style="color: #000000;"&gt; ErrorMessageFormat&lt;br /&gt;        {&lt;br /&gt;            &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;internal&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;const&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;string&lt;/span&gt;&lt;span style="color: #000000;"&gt; LeadingWhiteSpaceInString &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #800000;"&gt;"&lt;/span&gt;&lt;span style="color: #800000;"&gt;Leading whitespace in string field {0}.&lt;/span&gt;&lt;span style="color: #800000;"&gt;"&lt;/span&gt;&lt;span style="color: #000000;"&gt;;&lt;br /&gt;            &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;internal&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;const&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;string&lt;/span&gt;&lt;span style="color: #000000;"&gt; TrailingWhiteSpaceInString &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #800000;"&gt;"&lt;/span&gt;&lt;span style="color: #800000;"&gt;Trailing whitespace in string field {0}.&lt;/span&gt;&lt;span style="color: #800000;"&gt;"&lt;/span&gt;&lt;span style="color: #000000;"&gt;;&lt;br /&gt;            &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;internal&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;const&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;string&lt;/span&gt;&lt;span style="color: #000000;"&gt; ConsecutiveSpacesInString &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #800000;"&gt;"&lt;/span&gt;&lt;span style="color: #800000;"&gt;Consecutive spaces in string field {0}.&lt;/span&gt;&lt;span style="color: #800000;"&gt;"&lt;/span&gt;&lt;span style="color: #000000;"&gt;;&lt;br /&gt;            &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;internal&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;const&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;string&lt;/span&gt;&lt;span style="color: #000000;"&gt; CRLFOrTabInString &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #800000;"&gt;"&lt;/span&gt;&lt;span style="color: #800000;"&gt;Carriage return, line feed or tab in string field {0}.&lt;/span&gt;&lt;span style="color: #800000;"&gt;"&lt;/span&gt;&lt;span style="color: #000000;"&gt;;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;internal&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;class&lt;/span&gt;&lt;span style="color: #000000;"&gt; GeneralFormat&lt;br /&gt;        {&lt;br /&gt;            &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;internal&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;const&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;string&lt;/span&gt;&lt;span style="color: #000000;"&gt; AppendSpace &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #800000;"&gt;"&lt;/span&gt;&lt;span style="color: #800000;"&gt;{0} &lt;/span&gt;&lt;span style="color: #800000;"&gt;"&lt;/span&gt;&lt;span style="color: #000000;"&gt;;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;internal&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;class&lt;/span&gt;&lt;span style="color: #000000;"&gt; GuidString&lt;br /&gt;        {&lt;br /&gt;            &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;internal&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;const&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;string&lt;/span&gt;&lt;span style="color: #000000;"&gt; StringNormalizerClassId &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #800000;"&gt;"&lt;/span&gt;&lt;span style="color: #800000;"&gt;233553fa-b648-40ad-af26-d749d06ce443&lt;/span&gt;&lt;span style="color: #800000;"&gt;"&lt;/span&gt;&lt;span style="color: #000000;"&gt;;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;internal&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;class&lt;/span&gt;&lt;span style="color: #000000;"&gt; PropertyName&lt;br /&gt;        {&lt;br /&gt;            &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;internal&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;const&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;string&lt;/span&gt;&lt;span style="color: #000000;"&gt; ErrorOnNonNormalString &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #800000;"&gt;"&lt;/span&gt;&lt;span style="color: #800000;"&gt;ErrorOnNonNormalString&lt;/span&gt;&lt;span style="color: #800000;"&gt;"&lt;/span&gt;&lt;span style="color: #000000;"&gt;;&lt;br /&gt;            &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;internal&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;const&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;string&lt;/span&gt;&lt;span style="color: #000000;"&gt; NormalizeStrings &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #800000;"&gt;"&lt;/span&gt;&lt;span style="color: #800000;"&gt;NormalizeStrings&lt;/span&gt;&lt;span style="color: #800000;"&gt;"&lt;/span&gt;&lt;span style="color: #000000;"&gt;;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;internal&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;class&lt;/span&gt;&lt;span style="color: #000000;"&gt; ResourceNames&lt;br /&gt;        {&lt;br /&gt;            &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;internal&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;const&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;string&lt;/span&gt;&lt;span style="color: #000000;"&gt; StringNormalizer &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #800000;"&gt;"&lt;/span&gt;&lt;span style="color: #800000;"&gt;My.BizTalk.PipelineComponents.StringNormalizer&lt;/span&gt;&lt;span style="color: #800000;"&gt;"&lt;/span&gt;&lt;span style="color: #000000;"&gt;;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;internal&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;class&lt;/span&gt;&lt;span style="color: #000000;"&gt; ResourceStrings&lt;br /&gt;        {&lt;br /&gt;            &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;internal&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;const&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;string&lt;/span&gt;&lt;span style="color: #000000;"&gt; ComponentDescription &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #800000;"&gt;"&lt;/span&gt;&lt;span style="color: #800000;"&gt;COMPONENTDESCRIPTION&lt;/span&gt;&lt;span style="color: #800000;"&gt;"&lt;/span&gt;&lt;span style="color: #000000;"&gt;;&lt;br /&gt;            &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;internal&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;const&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;string&lt;/span&gt;&lt;span style="color: #000000;"&gt; ComponentIcon &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #800000;"&gt;"&lt;/span&gt;&lt;span style="color: #800000;"&gt;COMPONENTICON&lt;/span&gt;&lt;span style="color: #800000;"&gt;"&lt;/span&gt;&lt;span style="color: #000000;"&gt;;&lt;br /&gt;            &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;internal&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;const&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;string&lt;/span&gt;&lt;span style="color: #000000;"&gt; ComponentName &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #800000;"&gt;"&lt;/span&gt;&lt;span style="color: #800000;"&gt;COMPONENTNAME&lt;/span&gt;&lt;span style="color: #800000;"&gt;"&lt;/span&gt;&lt;span style="color: #000000;"&gt;;&lt;br /&gt;            &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;internal&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;const&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;string&lt;/span&gt;&lt;span style="color: #000000;"&gt; ComponentVersion &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #800000;"&gt;"&lt;/span&gt;&lt;span style="color: #800000;"&gt;COMPONENTVERSION&lt;/span&gt;&lt;span style="color: #800000;"&gt;"&lt;/span&gt;&lt;span style="color: #000000;"&gt;;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;internal&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;class&lt;/span&gt;&lt;span style="color: #000000;"&gt; XmlAttribute&lt;br /&gt;        {&lt;br /&gt;            &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;internal&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;const&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;string&lt;/span&gt;&lt;span style="color: #000000;"&gt; Public &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #800000;"&gt;"&lt;/span&gt;&lt;span style="color: #800000;"&gt;PUBLIC&lt;/span&gt;&lt;span style="color: #800000;"&gt;"&lt;/span&gt;&lt;span style="color: #000000;"&gt;;&lt;br /&gt;            &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;internal&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;const&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;string&lt;/span&gt;&lt;span style="color: #000000;"&gt; System &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #800000;"&gt;"&lt;/span&gt;&lt;span style="color: #800000;"&gt;SYSTEM&lt;/span&gt;&lt;span style="color: #800000;"&gt;"&lt;/span&gt;&lt;span style="color: #000000;"&gt;;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;internal&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;class&lt;/span&gt;&lt;span style="color: #000000;"&gt; XmlNamespace&lt;br /&gt;        {&lt;br /&gt;            &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;internal&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;const&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;string&lt;/span&gt;&lt;span style="color: #000000;"&gt; BizTalkSystemProperties &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #800000;"&gt;"&lt;/span&gt;&lt;span style="color: #800000;"&gt;http://schemas.microsoft.com/BizTalk/2003/system-properties&lt;/span&gt;&lt;span style="color: #800000;"&gt;"&lt;/span&gt;&lt;span style="color: #000000;"&gt;;&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;/span&gt;&lt;/pre&gt;&lt;!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;To use the behavior in BizTalk just add the assembly to the GAC, and register it in the machine.config file with the rest of the behaviors that ship with .net. Then add the behavior in your WCF port configuration, and the issues with whitespace are solved!&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3696827856353448753-7215946992857854568?l=connectingsystems.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://connectingsystems.blogspot.com/feeds/7215946992857854568/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://connectingsystems.blogspot.com/2009/12/wcf-behavior-to-remove-whitespace.html#comment-form' title='40 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3696827856353448753/posts/default/7215946992857854568'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3696827856353448753/posts/default/7215946992857854568'/><link rel='alternate' type='text/html' href='http://connectingsystems.blogspot.com/2009/12/wcf-behavior-to-remove-whitespace.html' title='WCF Behavior To Remove Whitespace'/><author><name>Grant Samuels</name><uri>http://www.blogger.com/profile/07008298142913353091</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>40</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3696827856353448753.post-9000189455283505786</id><published>2009-09-16T15:52:00.001-07:00</published><updated>2009-09-16T15:52:08.120-07:00</updated><title type='text'>DebugView Hangs BizTalk 2009 Deployment</title><content type='html'>&lt;p&gt;Had a very strange issue with Windows Server 2008/BTS 2009 and &lt;a href="http://technet.microsoft.com/en-us/sysinternals/bb896647.aspx" target="_blank"&gt;DebugView&lt;/a&gt; recently, thought I might mention it in the hope it would save someone else some time diagnosing the issue. &lt;/p&gt;  &lt;p&gt;During an ESB project I was working on recently, I started to get issues with my virtual machine locking up while deploying a BizTalk solution locally. The only solution was to reboot the virtual, and then deploy again. However the issue would keep occurring again and again, meaning I would be rebooting my machine every hour or so. Very frustrating!&lt;/p&gt;  &lt;p&gt;I decided that there must be some issue with my virtual so I built another image, but the problem came back again. I started digging around to see what could be cause of the issue, checking resource monitor (cpu/disk/memory), monitoring the local SQL instance, and using &lt;a href="http://technet.microsoft.com/en-us/sysinternals/bb896645.aspx" target="_blank"&gt;Process Monitor&lt;/a&gt;. Still no luck.&lt;/p&gt;  &lt;p&gt;Eventually I noticed that the issue only seemed to occur when I had DebugView open (I use it monitor ESB trace statements and other trace calls from orchestrations). After shutting it down the virtual started running properly again after a few seconds…. hmmmm. &lt;/p&gt;  &lt;p&gt;I successfully reproduced the issue several times – something that DebugView is doing interferes with the deployment process into BizTalk, and then the flow-on effect freezes the entire machine. It only seems to affect the deployment part so just shut down DebugView before you deploy. Hope this helps!&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3696827856353448753-9000189455283505786?l=connectingsystems.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://connectingsystems.blogspot.com/feeds/9000189455283505786/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://connectingsystems.blogspot.com/2009/09/debugview-hangs-biztalk-2009-deployment.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3696827856353448753/posts/default/9000189455283505786'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3696827856353448753/posts/default/9000189455283505786'/><link rel='alternate' type='text/html' href='http://connectingsystems.blogspot.com/2009/09/debugview-hangs-biztalk-2009-deployment.html' title='DebugView Hangs BizTalk 2009 Deployment'/><author><name>Grant Samuels</name><uri>http://www.blogger.com/profile/07008298142913353091</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3696827856353448753.post-1762544801363004096</id><published>2009-08-31T21:57:00.001-07:00</published><updated>2009-08-31T22:01:47.984-07:00</updated><title type='text'>Dynamically Sending Email Attachments Using The BizTalk SMTP Adapter</title><content type='html'>&lt;p&gt;Recently we had a requirement to send email from BizTalk with a number of attachments. This sounds like an easy thing to do, until we realised the number of attachments required would vary at runtime. It could be anywhere from zero, to lots. &lt;/p&gt;  &lt;p&gt;In trying to work out the best method to achieve this, I first tried manually creating a multipart MIME message that contained explicit boundaries, and the appropriate content types. It didn’t seem to work reliably so after a bit of searching I found &lt;a href="http://geekswithblogs.net/gwiele/archive/2009/07/13/133454.aspx" target="_blank"&gt;this article&lt;/a&gt; which used the idea of directly adding XLANGPart to the main XLANG email message.&lt;br/&gt;&lt;br/&gt;One quick helper class later and it was all working:&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:dc7abf93-2ffd-46fc-bbbe-0eb20ae52dfa" class="wlWriterEditableSmartContent"&gt;&lt;pre style="background-color:#FFFFFF;white-space:-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; white-space: pre-wrap; word-wrap: break-word;overflow: auto;"&gt;&lt;span style="color: #000000;"&gt;        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;public&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;void&lt;/span&gt;&lt;span style="color: #000000;"&gt; AttachPartToMessage(XLANGMessage message, &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;string&lt;/span&gt;&lt;span style="color: #000000;"&gt; partContent, &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;string&lt;/span&gt;&lt;span style="color: #000000;"&gt; partFileName)&lt;br /&gt;        {&lt;br /&gt;            &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;byte&lt;/span&gt;&lt;span style="color: #000000;"&gt;[] contentBuffer &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; UTF8Encoding.Default.GetBytes(partContent);&lt;br /&gt;            MemoryStream partStream &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;new&lt;/span&gt;&lt;span style="color: #000000;"&gt; MemoryStream(contentBuffer, &lt;/span&gt;&lt;span style="color: #800080;"&gt;0&lt;/span&gt;&lt;span style="color: #000000;"&gt;, contentBuffer.Length, &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;true&lt;/span&gt;&lt;span style="color: #000000;"&gt;, &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;true&lt;/span&gt;&lt;span style="color: #000000;"&gt;);&lt;br /&gt;&lt;br /&gt;            &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;string&lt;/span&gt;&lt;span style="color: #000000;"&gt; partName &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; Guid.NewGuid().ToString().Substring(&lt;/span&gt;&lt;span style="color: #800080;"&gt;0&lt;/span&gt;&lt;span style="color: #000000;"&gt;, &lt;/span&gt;&lt;span style="color: #800080;"&gt;5&lt;/span&gt;&lt;span style="color: #000000;"&gt;);&lt;br /&gt;            message.AddPart(partStream, partName);&lt;br /&gt;            &lt;br /&gt;            &lt;/span&gt;&lt;span style="color: #008000;"&gt;//&lt;/span&gt;&lt;span style="color: #008000;"&gt;derive the content type from the filename extension&lt;/span&gt;&lt;span style="color: #008000;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;            &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;string&lt;/span&gt;&lt;span style="color: #000000;"&gt; contentType &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; GetContentType(Path.GetExtension(partFileName).Replace(&lt;/span&gt;&lt;span style="color: #800000;"&gt;"&lt;/span&gt;&lt;span style="color: #800000;"&gt;.&lt;/span&gt;&lt;span style="color: #800000;"&gt;"&lt;/span&gt;&lt;span style="color: #000000;"&gt;, &lt;/span&gt;&lt;span style="color: #800000;"&gt;""&lt;/span&gt;&lt;span style="color: #000000;"&gt;));&lt;br /&gt;&lt;br /&gt;            &lt;/span&gt;&lt;span style="color: #008000;"&gt;//&lt;/span&gt;&lt;span style="color: #008000;"&gt;set filename and content type for attachment&lt;/span&gt;&lt;span style="color: #008000;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;            XLANGPart part &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; message[partName];&lt;br /&gt;            part.SetPartProperty(&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;typeof&lt;/span&gt;&lt;span style="color: #000000;"&gt;(MIME.FileName), partFileName);&lt;br /&gt;            part.SetPartProperty(&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;typeof&lt;/span&gt;&lt;span style="color: #000000;"&gt;(ContentType), contentType);&lt;br /&gt;        }&lt;/span&gt;&lt;/pre&gt;&lt;!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --&gt;&lt;/div&gt;&lt;p&gt;This can be used from the orchestration as follows (note the main XLANG message to which you are adding the parts, must be multipart)&lt;/p&gt;&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:2e035c89-cea8-45bb-aed8-d94c70811556" class="wlWriterEditableSmartContent"&gt;&lt;pre style="background-color:#FFFFFF;white-space:-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; white-space: pre-wrap; word-wrap: break-word;overflow: auto;"&gt;&lt;span style="color: #000000;"&gt;MessageHelper.AttachPartToMessage(EmailMsg, &lt;/span&gt;&lt;span style="color: #800000;"&gt;"&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;lt;test&amp;gt;this is attachment one&amp;lt;/test&amp;gt;&lt;/span&gt;&lt;span style="color: #800000;"&gt;"&lt;/span&gt;&lt;span style="color: #000000;"&gt;,&lt;/span&gt;&lt;span style="color: #800000;"&gt;"&lt;/span&gt;&lt;span style="color: #800000;"&gt;Sample.xml&lt;/span&gt;&lt;span style="color: #800000;"&gt;"&lt;/span&gt;&lt;span style="color: #000000;"&gt;);&lt;br /&gt;MessageHelper.AttachPartToMessage(EmailMsg, &lt;/span&gt;&lt;span style="color: #800000;"&gt;"&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;lt;html&amp;gt;&amp;lt;body&amp;gt;&amp;lt;i&amp;gt;Hello World&amp;lt;i&amp;gt;&amp;lt;/body&amp;gt;&amp;lt;/html&amp;gt;&lt;/span&gt;&lt;span style="color: #800000;"&gt;"&lt;/span&gt;&lt;span style="color: #000000;"&gt;, &lt;/span&gt;&lt;span style="color: #800000;"&gt;"&lt;/span&gt;&lt;span style="color: #800000;"&gt;Test.html&lt;/span&gt;&lt;span style="color: #800000;"&gt;"&lt;/span&gt;&lt;span style="color: #000000;"&gt;);&lt;br /&gt;MessageHelper.AttachPartToMessage(EmailMsg, InboundMsg.OuterXml, &lt;/span&gt;&lt;span style="color: #800000;"&gt;"&lt;/span&gt;&lt;span style="color: #800000;"&gt;InboundMsg.xml&lt;/span&gt;&lt;span style="color: #800000;"&gt;"&lt;/span&gt;&lt;span style="color: #000000;"&gt;);&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --&gt;&lt;/div&gt;&lt;p&gt;The resulting message shows up properly in Outlook :-)&lt;/p&gt;&lt;p&gt;&lt;a href="http://lh3.ggpht.com/_EiREDyJGw8Y/SpypuVTtUVI/AAAAAAAAADI/iqkDORf7KMg/s1600-h/emailmultipart%5B3%5D.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="emailmultipart" border="0" alt="emailmultipart" src="http://lh5.ggpht.com/_EiREDyJGw8Y/SpypvoAG13I/AAAAAAAAADM/mOXiXF4xpi8/emailmultipart_thumb%5B1%5D.png?imgmax=800" width="709" height="436" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;Cheers!&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3696827856353448753-1762544801363004096?l=connectingsystems.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://connectingsystems.blogspot.com/feeds/1762544801363004096/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://connectingsystems.blogspot.com/2009/08/dynamically-sending-email-attachments.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3696827856353448753/posts/default/1762544801363004096'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3696827856353448753/posts/default/1762544801363004096'/><link rel='alternate' type='text/html' href='http://connectingsystems.blogspot.com/2009/08/dynamically-sending-email-attachments.html' title='Dynamically Sending Email Attachments Using The BizTalk SMTP Adapter'/><author><name>Grant Samuels</name><uri>http://www.blogger.com/profile/07008298142913353091</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh5.ggpht.com/_EiREDyJGw8Y/SpypvoAG13I/AAAAAAAAADM/mOXiXF4xpi8/s72-c/emailmultipart_thumb%5B1%5D.png?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3696827856353448753.post-6303794779509085975</id><published>2009-08-04T15:57:00.001-07:00</published><updated>2009-08-05T14:48:37.685-07:00</updated><title type='text'>Esb Toolkit 2.0 With Custom Adapter Provider</title><content type='html'>&lt;p&gt;One of my favourite features of the new esb toolkit is that it is incredibly easy to extend. Already in an internal implementation I have written a custom messaging service, and implemented a custom adapter provider. Extending a messaging service is comprehensively covered &lt;a href="http://msdn.microsoft.com/en-us/library/ee250158%28BTS.10%29.aspx" target="_blank"&gt;here&lt;/a&gt;, but the &lt;a href="http://msdn.microsoft.com/en-us/library/ee236702%28BTS.10%29.aspx" target="_blank"&gt;documentation on the adapter provider&lt;/a&gt; is pretty inadequate. &lt;/p&gt;  &lt;p&gt;Here are a couple of points that may make it easier for anyone else going down this path…&lt;/p&gt;  &lt;p&gt;The adapter provider entry that you create in the esb config file &lt;strong&gt;must&lt;/strong&gt; contain the adapterassembly attribute (unless it references an adapter that ships with BizTalk) or it will not work. The type attribute points to the actual adapter implementation, and the adapterassembly attribute points to the property schema assembly – the documentation is incorrect on this point. An example is below. &lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:15ff45ab-191b-4ecb-88cc-7004646c6dd3" class="wlWriterEditableSmartContent"&gt;&lt;pre style="background-color:#FFFFFF;white-space:-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; white-space: pre-wrap; word-wrap: break-word;overflow: auto;;font-family:Courier New;font-size:11.25"&gt;&lt;span style="color: #0000FF;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000;"&gt;adapterProvider &lt;/span&gt;&lt;span style="color: #FF0000;"&gt;name&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;="SFTP"&lt;/span&gt;&lt;span style="color: #FF0000;"&gt; type&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;="MyTestProvider.SftpProvider, MyTestProvider, Version=1.0.0.0, Culture=neutral, PublicKeyToken=354cb85f9213cd3b"&lt;/span&gt;&lt;span style="color: #FF0000;"&gt; moniker&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;="SFTP"&lt;/span&gt;&lt;span style="color: #FF0000;"&gt; adapterAssembly&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;="MyTestProvider.Schemas, Version=1.0.0.0, Culture=neutral, PublicKeyToken=354cb85f9213cd3b"&lt;/span&gt;&lt;span style="color: #FF0000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;/&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --&gt;&lt;/div&gt;&lt;br /&gt;Consider the above example of creating an&amp;#160; custom adapter provider for secure FTP (SFTP): &lt;br /&gt;&lt;br /&gt;-the adapter name in BizTalk must be SFTP &lt;br /&gt;&lt;br /&gt;&lt;a href="http://lh5.ggpht.com/_EiREDyJGw8Y/Sni8uibyoVI/AAAAAAAAAC4/y2MzrxWzQzA/s1600-h/adminconsole%5B4%5D.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="adminconsole" border="0" alt="adminconsole" src="http://lh4.ggpht.com/_EiREDyJGw8Y/Sni8vR-6iLI/AAAAAAAAAC8/t05gv_0LR2I/adminconsole_thumb%5B2%5D.png?imgmax=800" width="351" height="507" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;- the adapter property schema namespace must be SFTP &lt;br /&gt;&lt;br /&gt;&lt;a href="http://lh5.ggpht.com/_EiREDyJGw8Y/Sni8wnJG9WI/AAAAAAAAADA/PauhqB_GEMc/s1600-h/propertyschema%5B3%5D.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="propertyschema" border="0" alt="propertyschema" src="http://lh4.ggpht.com/_EiREDyJGw8Y/Sni8xc3eDoI/AAAAAAAAADE/r1r8xCO5kE0/propertyschema_thumb%5B1%5D.png?imgmax=800" width="455" height="441" /&gt;&lt;/a&gt;&amp;#160; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;- the adapter provider name and moniker in the esb config file must be SFTP &lt;br /&gt;&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:cfaadfa2-b564-4597-ae64-9a0637557885" class="wlWriterEditableSmartContent"&gt;&lt;pre style="background-color:#FFFFFF;white-space:-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; white-space: pre-wrap; word-wrap: break-word;overflow: auto;;font-family:Courier New;font-size:11.25"&gt;&lt;span style="color: #0000FF;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000;"&gt;adapterProvider &lt;/span&gt;&lt;span style="color: #FF0000;"&gt;name&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;="SFTP"&lt;/span&gt;&lt;span style="color: #FF0000;"&gt; type&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;="MyTestProvider.SftpProvider, MyTestProvider, Version=1.0.0.0, Culture=neutral, PublicKeyToken=354cb85f9213cd3b"&lt;/span&gt;&lt;span style="color: #FF0000;"&gt; moniker&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;="SFTP"&lt;/span&gt;&lt;span style="color: #FF0000;"&gt; adapterAssembly&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;="MyTestProvider.Schemas, Version=1.0.0.0, Culture=neutral, PublicKeyToken=354cb85f9213cd3b"&lt;/span&gt;&lt;span style="color: #FF0000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;/&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --&gt;&lt;/div&gt;&lt;br /&gt;If all these things correctly align, the ESB adapter manager should correctly promote the SFTP-related context properties from your itineraries :-)&lt;br /&gt;&lt;br /&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3696827856353448753-6303794779509085975?l=connectingsystems.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://connectingsystems.blogspot.com/feeds/6303794779509085975/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://connectingsystems.blogspot.com/2009/08/esb-toolkit-20-with-custom-adapter.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3696827856353448753/posts/default/6303794779509085975'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3696827856353448753/posts/default/6303794779509085975'/><link rel='alternate' type='text/html' href='http://connectingsystems.blogspot.com/2009/08/esb-toolkit-20-with-custom-adapter.html' title='Esb Toolkit 2.0 With Custom Adapter Provider'/><author><name>Grant Samuels</name><uri>http://www.blogger.com/profile/07008298142913353091</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh4.ggpht.com/_EiREDyJGw8Y/Sni8vR-6iLI/AAAAAAAAAC8/t05gv_0LR2I/s72-c/adminconsole_thumb%5B2%5D.png?imgmax=800' height='72' width='72'/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3696827856353448753.post-186585413976253369</id><published>2009-06-15T04:20:00.001-07:00</published><updated>2009-06-15T04:20:17.500-07:00</updated><title type='text'>MSBuild Extension Pack 3.5.3 Released!</title><content type='html'>&lt;p&gt;Get it now at &lt;a title="http://msbuildextensionpack.codeplex.com/" href="http://msbuildextensionpack.codeplex.com/"&gt;http://msbuildextensionpack.codeplex.com/&lt;/a&gt; :-)&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3696827856353448753-186585413976253369?l=connectingsystems.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://connectingsystems.blogspot.com/feeds/186585413976253369/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://connectingsystems.blogspot.com/2009/06/msbuild-extension-pack-353-released.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3696827856353448753/posts/default/186585413976253369'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3696827856353448753/posts/default/186585413976253369'/><link rel='alternate' type='text/html' href='http://connectingsystems.blogspot.com/2009/06/msbuild-extension-pack-353-released.html' title='MSBuild Extension Pack 3.5.3 Released!'/><author><name>Grant Samuels</name><uri>http://www.blogger.com/profile/07008298142913353091</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3696827856353448753.post-7716211718382092043</id><published>2009-04-22T23:55:00.001-07:00</published><updated>2009-04-28T16:30:12.478-07:00</updated><title type='text'>Guidance In Configuring Default BizTalk SQL Agent Jobs</title><content type='html'>&lt;p&gt;Having done some work recently setting up a number of BizTalk Hyper-V machines, I have put some guidance together on configuring the SQL Server Agent jobs that are created as part of the BizTalk install process. It’s pretty simple, but important to get these right as they can create performance issues, and run your server out of disk space!    &lt;br /&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;1. Backup BizTalk Server (BizTalkMgmtDb)      &lt;br /&gt;&lt;/strong&gt;There are three steps to this job: BackupFull, MarkAndBackupLog and ClearBackupHistory.&lt;/p&gt;  &lt;p&gt;The &lt;strong&gt;BackupFull&lt;/strong&gt; step contains this sql statement to configure:     &lt;br /&gt;    &lt;br /&gt;&lt;span style="color: blue"&gt;exec &lt;/span&gt;[dbo]&lt;span style="color: gray"&gt;.&lt;/span&gt;[sp_BackupAllFull_Schedule] ‘d’ &lt;span style="color: green"&gt;/* Frequency */&lt;/span&gt;&lt;span style="color: gray"&gt;,&lt;/span&gt;‘BTS’ &lt;span style="color: green"&gt;/* Name */&lt;/span&gt;&lt;span style="color: gray"&gt;,&lt;/span&gt;‘&lt;span style="color: gray"&gt;&amp;lt;&lt;/span&gt;destination &lt;span style="color: blue"&gt;path&lt;/span&gt;&lt;span style="color: gray"&gt;&amp;gt;&lt;/span&gt;’ &lt;span style="color: green"&gt;/* location of backup files */      &lt;br /&gt;      &lt;br /&gt;&lt;/span&gt;Generally most installations will keep the frequency daily and the name the same but you need to provide a full destination patch for the backup files to be stored in. Also, there are two important extra parameters that should be applied to this procedure. The first is a flag that controls if the job forces a full backup if a partial backup fails. The second extra parameter controls the time of day to run the full backup. Adding this will stop the backups occurring at midnight UTC time, which is the default. After configuration, to run at 2300 hours this step should look like:     &lt;br /&gt;    &lt;br /&gt;&lt;span style="color: blue"&gt;exec &lt;/span&gt;[dbo]&lt;span style="color: gray"&gt;.&lt;/span&gt;[sp_BackupAllFull_Schedule] &lt;span style="color: red"&gt;'d'&lt;/span&gt;&lt;span style="color: green"&gt;/* Frequency */&lt;/span&gt;&lt;span style="color: gray"&gt;,&lt;/span&gt;&lt;span style="color: red"&gt;'BTS'&lt;/span&gt;&lt;span style="color: green"&gt;/* Name */&lt;/span&gt;&lt;span style="color: gray"&gt;,&lt;/span&gt;&lt;span style="color: red"&gt;'C:\BizTalkSqlBackups\'&lt;/span&gt;&lt;span style="color: green"&gt;/* location of backup files */&lt;/span&gt;&lt;span style="color: gray"&gt;, 0, &lt;/span&gt;23 &lt;/p&gt;  &lt;p&gt;   &lt;br /&gt;The &lt;strong&gt;MarkAndBackUpLog&lt;/strong&gt;&amp;#160; step has the following statement to configure:     &lt;br /&gt;    &lt;br /&gt;&lt;span style="color: blue"&gt;exec &lt;/span&gt;[dbo]&lt;span style="color: gray"&gt;.&lt;/span&gt;[sp_MarkAll] ‘BTS’ &lt;span style="color: green"&gt;/* Log mark name */&lt;/span&gt;&lt;span style="color: gray"&gt;,&lt;/span&gt;’&lt;span style="color: gray"&gt;&amp;lt;&lt;/span&gt;destination &lt;span style="color: blue"&gt;path&lt;/span&gt;&lt;span style="color: gray"&gt;&amp;gt;&lt;/span&gt;’&amp;#160; &lt;span style="color: green"&gt;/*location of backup files */      &lt;br /&gt;      &lt;br /&gt;&lt;/span&gt;Simply add in your destination path for the log backups, and a extra bit parameter that tells the procedure to use local time:     &lt;br /&gt;    &lt;br /&gt;&lt;span style="color: blue"&gt;exec &lt;/span&gt;[dbo]&lt;span style="color: gray"&gt;.&lt;/span&gt;[sp_MarkAll] &lt;span style="color: red"&gt;'BTS'&lt;/span&gt;&lt;span style="color: green"&gt;/*&amp;#160; Log mark name */&lt;/span&gt;&lt;span style="color: gray"&gt;,&lt;/span&gt;&lt;span style="color: red"&gt;'C:\BizTalkSqlBackups\'&lt;/span&gt;&lt;span style="color: green"&gt;/* location of backup files */&lt;/span&gt;&lt;span style="color: gray"&gt;,&lt;/span&gt;1     &lt;br /&gt;    &lt;br /&gt;    &lt;br /&gt;The final step, &lt;strong&gt;Clear Backup History&lt;/strong&gt; is configured like this by default:     &lt;br /&gt;    &lt;br /&gt;&lt;span style="color: blue"&gt;exec &lt;/span&gt;[dbo]&lt;span style="color: gray"&gt;.&lt;/span&gt;[sp_DeleteBackupHistory] @DaysToKeep&lt;span style="color: gray"&gt;=&lt;/span&gt;14     &lt;br /&gt;    &lt;br /&gt;This procedure clears out the instances in the MarkLog table older than the days specified. Generally it can be left as is, but a enhancement to this procedure has been designed by &lt;a href="http://www.biztalkbill.com/" target="_blank"&gt;Bill&lt;/a&gt;, to solve the issue of accumulating backups in the file system. You can download the &lt;a href="http://www.biztalkbill.com/Downloads/tabid/54/grm2id/4/language/en-US/Default.aspx" target="_blank"&gt;updated stored procedure&lt;/a&gt; from his blog (called ‘BizTalk 2004 Stored Procedure to delete backups’), and it will take care of deleting the backup files as well.&lt;/p&gt;  &lt;p&gt;After configuring all the steps, make sure the job is enabled in SQL Agent, and do a test run to verify everything is working correctly. &lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;2.&amp;#160; DTA Purge and Archive (BizTalkDTADb)&lt;/strong&gt;     &lt;br /&gt;This job only contains one step requiring configuration: &lt;strong&gt;Archive and Purge&lt;/strong&gt;.&lt;/p&gt;  &lt;p&gt;The step contains this sql statement to modify:&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:3d1f0e37-126a-479a-ac58-444b34fb4571" class="wlWriterEditableSmartContent"&gt;&lt;pre style="background-color:#FFFFFF;overflow: auto;"&gt;&lt;span style="color: #0000FF;"&gt;exec&lt;/span&gt;&lt;span style="color: #000000;"&gt; dtasp_BackupAndPurgeTrackingDatabase&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #800000; font-weight: bold;"&gt;0&lt;/span&gt;&lt;span style="color: #000000;"&gt;, &lt;/span&gt;&lt;span style="color: #008080;"&gt;--&lt;/span&gt;&lt;span style="color: #008080;"&gt;@nLiveHours tinyint, --Any completed instance older than the live hours +live days&lt;/span&gt;&lt;span style="color: #008080;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #800000; font-weight: bold;"&gt;1&lt;/span&gt;&lt;span style="color: #000000;"&gt;, &lt;/span&gt;&lt;span style="color: #008080;"&gt;--&lt;/span&gt;&lt;span style="color: #008080;"&gt;@nLiveDays tinyint = 0, --will be deleted along with all associated data&lt;/span&gt;&lt;span style="color: #008080;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #800000; font-weight: bold;"&gt;30&lt;/span&gt;&lt;span style="color: #000000;"&gt;, &lt;/span&gt;&lt;span style="color: #008080;"&gt;--&lt;/span&gt;&lt;span style="color: #008080;"&gt;@nHardDeleteDays tinyint = 0, --all data older than this will be deleted.&lt;/span&gt;&lt;span style="color: #008080;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;null&lt;/span&gt;&lt;span style="color: #000000;"&gt;, &lt;/span&gt;&lt;span style="color: #008080;"&gt;--&lt;/span&gt;&lt;span style="color: #008080;"&gt;@nvcFolder nvarchar(1024) = null, --folder for backup files&lt;/span&gt;&lt;span style="color: #008080;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;null&lt;/span&gt;&lt;span style="color: #000000;"&gt;, &lt;/span&gt;&lt;span style="color: #008080;"&gt;--&lt;/span&gt;&lt;span style="color: #008080;"&gt;@nvcValidatingServer sysname = null,&lt;/span&gt;&lt;span style="color: #008080;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #800000; font-weight: bold;"&gt;0&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #008080;"&gt;--&lt;/span&gt;&lt;span style="color: #008080;"&gt;@fForceBackup int = 0 --&lt;/span&gt;&lt;/pre&gt;&lt;!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --&gt;&lt;/div&gt;&lt;br /&gt;The window for keeping instances in the Tracking Database is really dependent on your needs. The most important parameter to set is the folder path for backup files, but note there is also an interesting parameter called @nHardDeleteDays. According to the the &lt;a href="http://www.amazon.com/Professional-BizTalk-Server-Darren-Jefford/dp/0470046422/ref=sr_1_1?ie=UTF8&amp;amp;s=books&amp;amp;qid=1240468683&amp;amp;sr=1-1" target="_blank"&gt;Professional BizTalk Server 2006&lt;/a&gt; book: &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;em&gt;“This deals with incomplete instances that are in the Tracking database. This is useful in many situations, including when you have looping orchestrations that run indefinitely over a long period of time. Left unaddressed, this could result in the DTA database growing and these instances never being purged. Hard purging allows all data older than the specified value of the parameter @nHardDeleteDays to be purged, with the exception of that data that indicates the existence of an instance. The value of this parameter should always be greater than your soft purge window.”&amp;#160; &lt;/em&gt;Once this procedure is configured it should look like this: &lt;br /&gt;&lt;br /&gt;&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:00c2ebfd-4dc5-4bcc-8ea6-510dd948de46" class="wlWriterEditableSmartContent"&gt;&lt;pre style="background-color:#FFFFFF;overflow: auto;"&gt;&lt;span style="color: #0000FF;"&gt;exec&lt;/span&gt;&lt;span style="color: #000000;"&gt; dtasp_BackupAndPurgeTrackingDatabase&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #800000; font-weight: bold;"&gt;0&lt;/span&gt;&lt;span style="color: #000000;"&gt;, &lt;/span&gt;&lt;span style="color: #008080;"&gt;--&lt;/span&gt;&lt;span style="color: #008080;"&gt;@nLiveHours tinyint, --Any completed instance older than the live hours +live days&lt;/span&gt;&lt;span style="color: #008080;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #800000; font-weight: bold;"&gt;15&lt;/span&gt;&lt;span style="color: #000000;"&gt;, &lt;/span&gt;&lt;span style="color: #008080;"&gt;--&lt;/span&gt;&lt;span style="color: #008080;"&gt;@nLiveDays tinyint = 0, --will be deleted along with all associated data&lt;/span&gt;&lt;span style="color: #008080;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #800000; font-weight: bold;"&gt;16&lt;/span&gt;&lt;span style="color: #000000;"&gt;, &lt;/span&gt;&lt;span style="color: #008080;"&gt;--&lt;/span&gt;&lt;span style="color: #008080;"&gt;@nHardDeleteDays tinyint = 0, --all data older than this will be deleted.&lt;/span&gt;&lt;span style="color: #008080;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #FF0000;"&gt;'&lt;/span&gt;&lt;span style="color: #FF0000;"&gt;C:\BizTalkSqlBackups\&lt;/span&gt;&lt;span style="color: #FF0000;"&gt;'&lt;/span&gt;&lt;span style="color: #000000;"&gt;, &lt;/span&gt;&lt;span style="color: #008080;"&gt;--&lt;/span&gt;&lt;span style="color: #008080;"&gt;@nvcFolder nvarchar(1024) = null, --folder for backup files&lt;/span&gt;&lt;span style="color: #008080;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;null&lt;/span&gt;&lt;span style="color: #000000;"&gt;, &lt;/span&gt;&lt;span style="color: #008080;"&gt;--&lt;/span&gt;&lt;span style="color: #008080;"&gt;@nvcValidatingServer sysname = null,&lt;/span&gt;&lt;span style="color: #008080;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #800000; font-weight: bold;"&gt;0&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #008080;"&gt;--&lt;/span&gt;&lt;span style="color: #008080;"&gt;@fForceBackup int = 0 --&lt;/span&gt;&lt;/pre&gt;&lt;!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --&gt;&lt;/div&gt;&lt;br /&gt;Again, make sure this job is enabled and run it to ensure everything is working correctly. Configuring these jobs will go a long to ensure your BizTalk installation runs smoothly. Cheers! &lt;br /&gt;&lt;br /&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3696827856353448753-7716211718382092043?l=connectingsystems.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://connectingsystems.blogspot.com/feeds/7716211718382092043/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://connectingsystems.blogspot.com/2009/04/guidance-in-configuring-default-biztalk.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3696827856353448753/posts/default/7716211718382092043'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3696827856353448753/posts/default/7716211718382092043'/><link rel='alternate' type='text/html' href='http://connectingsystems.blogspot.com/2009/04/guidance-in-configuring-default-biztalk.html' title='Guidance In Configuring Default BizTalk SQL Agent Jobs'/><author><name>Grant Samuels</name><uri>http://www.blogger.com/profile/07008298142913353091</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3696827856353448753.post-1085243354597026348</id><published>2009-04-21T15:20:00.001-07:00</published><updated>2009-04-21T15:20:47.026-07:00</updated><title type='text'>Using TFS Assemblies on Vista 64-bit</title><content type='html'>&lt;p&gt;Just spent some time figuring out an issue in a Windows Forms application I am writing. It is designed to be a simple UI for generating TFS builds for BizTalk, using the &lt;a href="http://www.codeplex.com/MSBuildExtensionPack" target="_blank"&gt;MSBuild Extension Pack&lt;/a&gt; tasks. &lt;/p&gt;  &lt;p&gt;In order to generate builds through the TFS API, I needed to reference some of the following assemblies:&lt;/p&gt;  &lt;p&gt;- Microsoft.TeamFoundation    &lt;br /&gt;- Microsoft.TeamFoundation.Build.Client     &lt;br /&gt;- Microsoft.TeamFoundation.Client&lt;/p&gt;  &lt;p&gt;After referencing these assemblies I ran the application and kept getting a runtime exception:&lt;/p&gt;  &lt;p&gt;&lt;em&gt;Could not load file or assembly 'Microsoft.TeamFoundation, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;After trying a number of steps to fix the issue it turns out that under Vista 64-bit,&amp;#160; the application referencing these assemblies must be compiled in in ‘x86’ mode, not ‘Any CPU’. Changing the solution configuration mode to ‘Debug | x86’ solves the issue.&amp;#160; &lt;/p&gt;  &lt;p&gt;The error message isnt particularly helpful in this case so I am blogging it in case someone else strikes the same issue. Apparently TFS 2010 will be fully 64-bit compatible (at last!).&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3696827856353448753-1085243354597026348?l=connectingsystems.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://connectingsystems.blogspot.com/feeds/1085243354597026348/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://connectingsystems.blogspot.com/2009/04/using-tfs-assemblies-on-vista-64-bit.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3696827856353448753/posts/default/1085243354597026348'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3696827856353448753/posts/default/1085243354597026348'/><link rel='alternate' type='text/html' href='http://connectingsystems.blogspot.com/2009/04/using-tfs-assemblies-on-vista-64-bit.html' title='Using TFS Assemblies on Vista 64-bit'/><author><name>Grant Samuels</name><uri>http://www.blogger.com/profile/07008298142913353091</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3696827856353448753.post-3845207979158936753</id><published>2009-04-16T14:57:00.001-07:00</published><updated>2009-04-16T14:57:22.080-07:00</updated><title type='text'>MSBuild Extension Pack And BizTalk</title><content type='html'>&lt;p&gt;I have started to contribute on the CodePlex project &lt;a href="http://www.codeplex.com/MSBuildExtensionPack"&gt;http://www.codeplex.com/MSBuildExtensionPack&lt;/a&gt;, helping out on the BizTalk tasks included in the library. The next release (3.5.3) is shaping up really well and should have great support for most of the tasks needed for deploying and administering BizTalk (including deploying to remote machines).&lt;/p&gt;  &lt;p&gt;The 3.5.3 release should be out some time in early May, look out for it – using MSBuild and BizTalk together is about to become a lot easier :-)&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3696827856353448753-3845207979158936753?l=connectingsystems.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://connectingsystems.blogspot.com/feeds/3845207979158936753/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://connectingsystems.blogspot.com/2009/04/msbuild-extension-pack-and-biztalk.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3696827856353448753/posts/default/3845207979158936753'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3696827856353448753/posts/default/3845207979158936753'/><link rel='alternate' type='text/html' href='http://connectingsystems.blogspot.com/2009/04/msbuild-extension-pack-and-biztalk.html' title='MSBuild Extension Pack And BizTalk'/><author><name>Grant Samuels</name><uri>http://www.blogger.com/profile/07008298142913353091</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3696827856353448753.post-8015216165185976095</id><published>2009-03-01T21:41:00.001-08:00</published><updated>2009-03-01T21:41:26.381-08:00</updated><title type='text'>BizTalk WCF Misbehaviors [Part 2]</title><content type='html'>&lt;p&gt;In part 1 of this posting, I showed how the default behavior of BizTalk WCF adapters were causing a problem with a specific messaging scenario, with strict addressing and security header requirements.&lt;/p&gt; &lt;p&gt;The good news is that BizTalk provides the ability to configure WCF Behavior Extensions directly on your send port configuration. &lt;/p&gt; &lt;p&gt;From the &lt;a href="http://msdn.microsoft.com/en-us/library/cc952299.aspx"&gt;MSDN article on the subject&lt;/a&gt;, emphasis mine:&lt;/p&gt; &lt;p&gt;“One of the advantages of using Windows Communication Foundation (WCF) as a message communication mechanism is the opportunity to extend the functionality of its services by using custom code. There are different points within the flow of a WCF message to intercept the message and execute custom processing before the message reaches its final destination. &lt;em&gt;WCF custom behavior extensions are one such type of interception mechanism, and can be used to extend WCF service or client functionality at different levels of granularity&lt;/em&gt;. In this paper we will discuss the different types of WCF behaviors and where you can interject their processing within the WCF architecture. We will discuss how the BizTalk WCF-Custom and WCF-CustomIsolated adapters enable you to use a WCF custom behavior extension.”&lt;/p&gt; &lt;p&gt;Sounds perfect for our requirements, namely the ability to completely control the WS-Addressing and WS-Security headers in our BizTalk send port. In order to create our custom behavior extension, we need to do five things:&lt;/p&gt; &lt;p&gt;1. Write a class inheriting from &lt;strong&gt;BehaviorExtensionElement&lt;/strong&gt;, which holds our configuration properties and instantiates the actual endpoint behavior in the CreateBehavior method: &lt;/p&gt;&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;public sealed class &lt;/span&gt;&lt;span style="color: #2b91af"&gt;MyBehaviorExtension &lt;/span&gt;: &lt;span style="color: #2b91af"&gt;BehaviorExtensionElement&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;    &lt;br /&gt;    [&lt;span style="color: #2b91af"&gt;ConfigurationProperty&lt;/span&gt;(&lt;span style="color: #a31515"&gt;"ServiceUsername"&lt;/span&gt;, DefaultValue=&lt;span style="color: #a31515"&gt;""&lt;/span&gt;, IsRequired = &lt;span style="color: blue"&gt;true&lt;/span&gt;)]&lt;br /&gt;    &lt;span style="color: blue"&gt;public string &lt;/span&gt;ServiceUsername&lt;br /&gt;    {&lt;br /&gt;        &lt;span style="color: blue"&gt;get &lt;/span&gt;{ &lt;span style="color: blue"&gt;return &lt;/span&gt;(&lt;span style="color: blue"&gt;string&lt;/span&gt;)&lt;span style="color: blue"&gt;base&lt;/span&gt;[&lt;span style="color: #a31515"&gt;"ServiceUsername"&lt;/span&gt;]; }&lt;br /&gt;        &lt;span style="color: blue"&gt;set &lt;/span&gt;{ &lt;span style="color: blue"&gt;base&lt;/span&gt;[&lt;span style="color: #a31515"&gt;"ServiceUsername"&lt;/span&gt;] = &lt;span style="color: blue"&gt;value&lt;/span&gt;; }&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    [&lt;span style="color: #2b91af"&gt;ConfigurationProperty&lt;/span&gt;(&lt;span style="color: #a31515"&gt;"ServicePassword"&lt;/span&gt;, DefaultValue = &lt;span style="color: #a31515"&gt;""&lt;/span&gt;, IsRequired = &lt;span style="color: blue"&gt;true&lt;/span&gt;)]&lt;br /&gt;    &lt;span style="color: blue"&gt;public string &lt;/span&gt;ServicePassword&lt;br /&gt;    {&lt;br /&gt;        &lt;span style="color: blue"&gt;get &lt;/span&gt;{ &lt;span style="color: blue"&gt;return &lt;/span&gt;(&lt;span style="color: blue"&gt;string&lt;/span&gt;)&lt;span style="color: blue"&gt;base&lt;/span&gt;[&lt;span style="color: #a31515"&gt;"ServicePassword"&lt;/span&gt;]; }&lt;br /&gt;        &lt;span style="color: blue"&gt;set &lt;/span&gt;{ &lt;span style="color: blue"&gt;base&lt;/span&gt;[&lt;span style="color: #a31515"&gt;"ServicePassword"&lt;/span&gt;] = &lt;span style="color: blue"&gt;value&lt;/span&gt;; }&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    [&lt;span style="color: #2b91af"&gt;ConfigurationProperty&lt;/span&gt;(&lt;span style="color: #a31515"&gt;"ServiceAction"&lt;/span&gt;, DefaultValue = &lt;span style="color: #a31515"&gt;"urn:#AuthenticateUser"&lt;/span&gt;, IsRequired = &lt;span style="color: blue"&gt;true&lt;/span&gt;)]&lt;br /&gt;    &lt;span style="color: blue"&gt;public string &lt;/span&gt;ServiceAction&lt;br /&gt;    {&lt;br /&gt;        &lt;span style="color: blue"&gt;get &lt;/span&gt;{ &lt;span style="color: blue"&gt;return &lt;/span&gt;(&lt;span style="color: blue"&gt;string&lt;/span&gt;)&lt;span style="color: blue"&gt;base&lt;/span&gt;[&lt;span style="color: #a31515"&gt;"ServiceAction"&lt;/span&gt;]; }&lt;br /&gt;        &lt;span style="color: blue"&gt;set &lt;/span&gt;{ &lt;span style="color: blue"&gt;base&lt;/span&gt;[&lt;span style="color: #a31515"&gt;"ServiceAction"&lt;/span&gt;] = &lt;span style="color: blue"&gt;value&lt;/span&gt;; }&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    [&lt;span style="color: #2b91af"&gt;ConfigurationProperty&lt;/span&gt;(&lt;span style="color: #a31515"&gt;"ServiceToAddress"&lt;/span&gt;, DefaultValue = &lt;span style="color: #a31515"&gt;""&lt;/span&gt;, IsRequired = &lt;span style="color: blue"&gt;true&lt;/span&gt;)]&lt;br /&gt;    &lt;span style="color: blue"&gt;public string &lt;/span&gt;ServiceToAddress&lt;br /&gt;    {&lt;br /&gt;        &lt;span style="color: blue"&gt;get &lt;/span&gt;{ &lt;span style="color: blue"&gt;return &lt;/span&gt;(&lt;span style="color: blue"&gt;string&lt;/span&gt;)&lt;span style="color: blue"&gt;base&lt;/span&gt;[&lt;span style="color: #a31515"&gt;"ServiceToAddress"&lt;/span&gt;]; }&lt;br /&gt;        &lt;span style="color: blue"&gt;set &lt;/span&gt;{ &lt;span style="color: blue"&gt;base&lt;/span&gt;[&lt;span style="color: #a31515"&gt;"ServiceToAddress"&lt;/span&gt;] = &lt;span style="color: blue"&gt;value&lt;/span&gt;; }&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    [&lt;span style="color: #2b91af"&gt;ConfigurationProperty&lt;/span&gt;(&lt;span style="color: #a31515"&gt;"ServiceFromAddress"&lt;/span&gt;, DefaultValue = &lt;span style="color: #a31515"&gt;""&lt;/span&gt;, IsRequired = &lt;span style="color: blue"&gt;true&lt;/span&gt;)]&lt;br /&gt;    &lt;span style="color: blue"&gt;public string &lt;/span&gt;ServiceFromAddress&lt;br /&gt;    {&lt;br /&gt;        &lt;span style="color: blue"&gt;get &lt;/span&gt;{ &lt;span style="color: blue"&gt;return &lt;/span&gt;(&lt;span style="color: blue"&gt;string&lt;/span&gt;)&lt;span style="color: blue"&gt;base&lt;/span&gt;[&lt;span style="color: #a31515"&gt;"ServiceFromAddress"&lt;/span&gt;]; }&lt;br /&gt;        &lt;span style="color: blue"&gt;set &lt;/span&gt;{ &lt;span style="color: blue"&gt;base&lt;/span&gt;[&lt;span style="color: #a31515"&gt;"ServiceFromAddress"&lt;/span&gt;] = &lt;span style="color: blue"&gt;value&lt;/span&gt;; }&lt;br /&gt;    }&lt;br /&gt;    &lt;br /&gt;    &lt;span style="color: blue"&gt;protected override object &lt;/span&gt;CreateBehavior()&lt;br /&gt;    {&lt;br /&gt;        &lt;span style="color: #2b91af"&gt;MyBehaviorConfiguration &lt;/span&gt;behaviorConfiguration = &lt;br /&gt;            &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;MyBehaviorConfiguration&lt;/span&gt;(&lt;br /&gt;                &lt;span style="color: blue"&gt;this&lt;/span&gt;.ServiceUsername, &lt;br /&gt;                &lt;span style="color: blue"&gt;this&lt;/span&gt;.ServicePassword, &lt;br /&gt;                &lt;span style="color: blue"&gt;this&lt;/span&gt;.ServiceAction, &lt;br /&gt;                &lt;span style="color: blue"&gt;this&lt;/span&gt;.ServiceToAddress, &lt;br /&gt;                &lt;span style="color: blue"&gt;this&lt;/span&gt;.ServiceFromAddress);&lt;br /&gt;&lt;br /&gt;        &lt;span style="color: blue"&gt;return new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;MyEndpointBehavior&lt;/span&gt;(behaviorConfiguration);&lt;br /&gt;    }&lt;br /&gt;    &lt;br /&gt;    &lt;span style="color: blue"&gt;public override &lt;/span&gt;&lt;span style="color: #2b91af"&gt;Type &lt;/span&gt;BehaviorType&lt;br /&gt;    {&lt;br /&gt;        &lt;span style="color: blue"&gt;get&lt;br /&gt;        &lt;/span&gt;{&lt;br /&gt;            &lt;span style="color: blue"&gt;return typeof&lt;/span&gt;(&lt;span style="color: #2b91af"&gt;MyEndpointBehavior&lt;/span&gt;);&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: blue"&gt;private &lt;/span&gt;&lt;span style="color: #2b91af"&gt;ConfigurationPropertyCollection &lt;/span&gt;_prop = &lt;span style="color: blue"&gt;null&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: blue"&gt;protected override &lt;/span&gt;&lt;span style="color: #2b91af"&gt;ConfigurationPropertyCollection &lt;/span&gt;Properties&lt;br /&gt;    {&lt;br /&gt;        &lt;span style="color: blue"&gt;get&lt;br /&gt;        &lt;/span&gt;{&lt;br /&gt;            &lt;span style="color: blue"&gt;if &lt;/span&gt;(&lt;span style="color: blue"&gt;this&lt;/span&gt;._prop == &lt;span style="color: blue"&gt;null&lt;/span&gt;)&lt;br /&gt;            {&lt;br /&gt;                &lt;span style="color: blue"&gt;this&lt;/span&gt;._prop = &lt;span style="color: blue"&gt;new &lt;/span&gt;System.Configuration.&lt;span style="color: #2b91af"&gt;ConfigurationPropertyCollection&lt;/span&gt;();&lt;br /&gt;                &lt;span style="color: blue"&gt;this&lt;/span&gt;._prop.Add(&lt;span style="color: blue"&gt;new &lt;/span&gt;System.Configuration.&lt;span style="color: #2b91af"&gt;ConfigurationProperty&lt;/span&gt;(&lt;span style="color: #a31515"&gt;"ServiceUsername"&lt;/span&gt;, &lt;span style="color: blue"&gt;typeof&lt;/span&gt;(&lt;span style="color: blue"&gt;string&lt;/span&gt;), &lt;span style="color: #a31515"&gt;""&lt;/span&gt;, System.Configuration.&lt;span style="color: #2b91af"&gt;ConfigurationPropertyOptions&lt;/span&gt;.IsRequired));&lt;br /&gt;                &lt;span style="color: blue"&gt;this&lt;/span&gt;._prop.Add(&lt;span style="color: blue"&gt;new &lt;/span&gt;System.Configuration.&lt;span style="color: #2b91af"&gt;ConfigurationProperty&lt;/span&gt;(&lt;span style="color: #a31515"&gt;"ServicePassword"&lt;/span&gt;, &lt;span style="color: blue"&gt;typeof&lt;/span&gt;(&lt;span style="color: blue"&gt;string&lt;/span&gt;), &lt;span style="color: #a31515"&gt;""&lt;/span&gt;, System.Configuration.&lt;span style="color: #2b91af"&gt;ConfigurationPropertyOptions&lt;/span&gt;.IsRequired));&lt;br /&gt;                &lt;span style="color: blue"&gt;this&lt;/span&gt;._prop.Add(&lt;span style="color: blue"&gt;new &lt;/span&gt;System.Configuration.&lt;span style="color: #2b91af"&gt;ConfigurationProperty&lt;/span&gt;(&lt;span style="color: #a31515"&gt;"ServiceAction"&lt;/span&gt;, &lt;span style="color: blue"&gt;typeof&lt;/span&gt;(&lt;span style="color: blue"&gt;string&lt;/span&gt;), &lt;span style="color: #a31515"&gt;""&lt;/span&gt;, System.Configuration.&lt;span style="color: #2b91af"&gt;ConfigurationPropertyOptions&lt;/span&gt;.IsRequired));&lt;br /&gt;                &lt;span style="color: blue"&gt;this&lt;/span&gt;._prop.Add(&lt;span style="color: blue"&gt;new &lt;/span&gt;System.Configuration.&lt;span style="color: #2b91af"&gt;ConfigurationProperty&lt;/span&gt;(&lt;span style="color: #a31515"&gt;"ServiceToAddress"&lt;/span&gt;, &lt;span style="color: blue"&gt;typeof&lt;/span&gt;(&lt;span style="color: blue"&gt;string&lt;/span&gt;), &lt;span style="color: #a31515"&gt;""&lt;/span&gt;, System.Configuration.&lt;span style="color: #2b91af"&gt;ConfigurationPropertyOptions&lt;/span&gt;.IsRequired));&lt;br /&gt;                &lt;span style="color: blue"&gt;this&lt;/span&gt;._prop.Add(&lt;span style="color: blue"&gt;new &lt;/span&gt;System.Configuration.&lt;span style="color: #2b91af"&gt;ConfigurationProperty&lt;/span&gt;(&lt;span style="color: #a31515"&gt;"ServiceFromAddress"&lt;/span&gt;, &lt;span style="color: blue"&gt;typeof&lt;/span&gt;(&lt;span style="color: blue"&gt;string&lt;/span&gt;), &lt;span style="color: #a31515"&gt;""&lt;/span&gt;, System.Configuration.&lt;span style="color: #2b91af"&gt;ConfigurationPropertyOptions&lt;/span&gt;.IsRequired));&lt;br /&gt;            }&lt;br /&gt;            &lt;span style="color: blue"&gt;return this&lt;/span&gt;._prop;&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    &lt;br /&gt;}&lt;/pre&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;br /&gt;&lt;p&gt;2. Create the endpoint behavior implementing &lt;strong&gt;IEndpointBehavior&lt;/strong&gt;, in order to apply our desired client behavior, via a custom client message inspector:&lt;/p&gt;&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;public class &lt;/span&gt;&lt;span style="color: #2b91af"&gt;MyEndpointBehavior &lt;/span&gt;: &lt;span style="color: #2b91af"&gt;IEndpointBehavior&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;    &lt;span style="color: blue"&gt;public &lt;/span&gt;MyEndpointBehavior(&lt;span style="color: #2b91af"&gt;MyBehaviorConfiguration &lt;/span&gt;behaviorConfiguration)&lt;br /&gt;    {&lt;br /&gt;        &lt;span style="color: blue"&gt;this&lt;/span&gt;.BehaviorConfiguration = behaviorConfiguration;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: blue"&gt;public &lt;/span&gt;&lt;span style="color: #2b91af"&gt;MyBehaviorConfiguration &lt;/span&gt;BehaviorConfiguration { &lt;span style="color: blue"&gt;get&lt;/span&gt;; &lt;span style="color: blue"&gt;set&lt;/span&gt;; }&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: blue"&gt;#region &lt;/span&gt;IEndpointBehavior Members&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: blue"&gt;public void &lt;/span&gt;AddBindingParameters(&lt;span style="color: #2b91af"&gt;ServiceEndpoint &lt;/span&gt;endpoint, System.ServiceModel.Channels.&lt;span style="color: #2b91af"&gt;BindingParameterCollection &lt;/span&gt;bindingParameters)&lt;br /&gt;    { }&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: blue"&gt;public void &lt;/span&gt;ApplyClientBehavior(&lt;span style="color: #2b91af"&gt;ServiceEndpoint &lt;/span&gt;endpoint, System.ServiceModel.Dispatcher.&lt;span style="color: #2b91af"&gt;ClientRuntime &lt;/span&gt;clientRuntime)&lt;br /&gt;    {&lt;br /&gt;        clientRuntime.MessageInspectors.Add(&lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;CustomHeadersMessageInspector&lt;/span&gt;(&lt;span style="color: blue"&gt;this&lt;/span&gt;.BehaviorConfiguration));&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: blue"&gt;public void &lt;/span&gt;ApplyDispatchBehavior(&lt;span style="color: #2b91af"&gt;ServiceEndpoint &lt;/span&gt;endpoint, System.ServiceModel.Dispatcher.&lt;span style="color: #2b91af"&gt;EndpointDispatcher &lt;/span&gt;endpointDispatcher)&lt;br /&gt;    { }&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: blue"&gt;public void &lt;/span&gt;Validate(&lt;span style="color: #2b91af"&gt;ServiceEndpoint &lt;/span&gt;endpoint)&lt;br /&gt;    { }&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: blue"&gt;#endregion&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;}&lt;/pre&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;br /&gt;&lt;p&gt;3. Create the custom message inspector, implementing &lt;strong&gt;IClientMessageInspector&lt;/strong&gt;: &lt;/p&gt;&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;public class &lt;/span&gt;&lt;span style="color: #2b91af"&gt;CustomHeadersMessageInspector &lt;/span&gt;: &lt;span style="color: #2b91af"&gt;IClientMessageInspector&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;    &lt;span style="color: blue"&gt;public &lt;/span&gt;CustomHeadersMessageInspector(&lt;span style="color: #2b91af"&gt;MyBehaviorConfiguration &lt;/span&gt;behaviorConfiguration)&lt;br /&gt;    {&lt;br /&gt;        &lt;span style="color: blue"&gt;this&lt;/span&gt;.BehaviorConfiguration = behaviorConfiguration;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: blue"&gt;public &lt;/span&gt;&lt;span style="color: #2b91af"&gt;MyBehaviorConfiguration &lt;/span&gt;BehaviorConfiguration { &lt;span style="color: blue"&gt;get&lt;/span&gt;; &lt;span style="color: blue"&gt;set&lt;/span&gt;; }&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: blue"&gt;#region &lt;/span&gt;IClientMessageInspector Members&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: blue"&gt;public void &lt;/span&gt;AfterReceiveReply(&lt;span style="color: blue"&gt;ref &lt;/span&gt;&lt;span style="color: #2b91af"&gt;Message &lt;/span&gt;reply, &lt;span style="color: blue"&gt;object &lt;/span&gt;correlationState)&lt;br /&gt;    { }&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: blue"&gt;public object &lt;/span&gt;BeforeSendRequest(&lt;span style="color: blue"&gt;ref &lt;/span&gt;&lt;span style="color: #2b91af"&gt;Message &lt;/span&gt;request, &lt;span style="color: #2b91af"&gt;IClientChannel &lt;/span&gt;channel)&lt;br /&gt;    {&lt;br /&gt;        request.Headers.Action = BehaviorConfiguration.ServiceAction;&lt;br /&gt;        request.Headers.From = BehaviorConfiguration.ServiceFromAddress;&lt;br /&gt;        request.Headers.To = BehaviorConfiguration.ServiceToAddress;&lt;br /&gt;        request.Headers.Add(BuildSecurityHeaders());&lt;br /&gt;        &lt;span style="color: blue"&gt;return null&lt;/span&gt;;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: blue"&gt;#endregion&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;}&lt;/pre&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;br /&gt;&lt;p&gt;4. Add the extension element into the machine.config file on your BizTalk server under the &lt;strong&gt;System.ServiceModel&lt;/strong&gt; | &lt;strong&gt;Extensions&lt;/strong&gt; | &lt;strong&gt;BehaviorExtensions&lt;/strong&gt; element:&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;system.serviceModel&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;extensions&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;behaviorExtensions&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;add &lt;/span&gt;&lt;span style="color: red"&gt;name&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;NextGenBehaviorExtension&lt;/span&gt;" &lt;span style="color: red"&gt;type&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;SGC.Helpers.MyWcf.MyBehaviorExtension, SGC.Helpers.MyWcf, Version=1.0.0.0, Culture=neutral,PublicKeyToken=354cb85f9213cd3b&lt;/span&gt;" &lt;span style="color: blue"&gt;/&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;br /&gt;&lt;p&gt;5. GAC the behavior extension assembly you created, and restart BizTalk server.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;Installation complete!&lt;/p&gt;&lt;br /&gt;&lt;p&gt;If you have correctly configured everything, you should see see the extension listed when you ‘Add Extension’ on the &lt;strong&gt;Behavior&lt;/strong&gt; tab of your WCF-Custom port. &lt;/p&gt;&lt;br /&gt;&lt;p&gt;Here is what the extension I built looks like in BizTalk, notice the configuration options are listed in the UI. These options also get saved out into the binding file when you export bindings. &lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;a href="http://lh6.ggpht.com/_EiREDyJGw8Y/Satxf1WHL4I/AAAAAAAAACw/vQUjRbEnkBo/s1600-h/extensionconfig3.png"&gt;&lt;img title="extensionconfig" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="581" alt="extensionconfig" src="http://lh5.ggpht.com/_EiREDyJGw8Y/Satxg3fia4I/AAAAAAAAAC0/StqE1LjuX1Q/extensionconfig_thumb1.png?imgmax=800" width="619" border="0"&gt;&lt;/a&gt; &lt;/p&gt;&lt;br /&gt;&lt;p&gt;After configuring the behavior with the desired settings, my message headers now conform to what the remote service expects. &lt;/p&gt;&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;s:Header&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;br /&gt;  &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;a:Action&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;MyAction&lt;span style="color: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;a:Action&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;br /&gt;  &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;a:To&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;MyToAddress&lt;span style="color: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;a:To&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;br /&gt;  &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;a:From&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;br /&gt;    &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;a:Address&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;MyFromAddress&lt;span style="color: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;a:Address&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;br /&gt;  &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;a:From&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;br /&gt;  &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Security&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;br /&gt;    &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;UsernameToken&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;br /&gt;      &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Username&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;MyUsername&lt;span style="color: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;Username&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;br /&gt;      &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Password&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;MyPassword&lt;span style="color: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;Password&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;br /&gt;    &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;UsernameToken&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;br /&gt;  &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;Security&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;br /&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;s:Header&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;br /&gt;&lt;p&gt;Nice! &lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3696827856353448753-8015216165185976095?l=connectingsystems.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://connectingsystems.blogspot.com/feeds/8015216165185976095/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://connectingsystems.blogspot.com/2009/03/biztalk-wcf-misbehaviors-part-2.html#comment-form' title='6 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3696827856353448753/posts/default/8015216165185976095'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3696827856353448753/posts/default/8015216165185976095'/><link rel='alternate' type='text/html' href='http://connectingsystems.blogspot.com/2009/03/biztalk-wcf-misbehaviors-part-2.html' title='BizTalk WCF Misbehaviors [Part 2]'/><author><name>Grant Samuels</name><uri>http://www.blogger.com/profile/07008298142913353091</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh5.ggpht.com/_EiREDyJGw8Y/Satxg3fia4I/AAAAAAAAAC0/StqE1LjuX1Q/s72-c/extensionconfig_thumb1.png?imgmax=800' height='72' width='72'/><thr:total>6</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3696827856353448753.post-5822117101923359790</id><published>2009-02-10T17:02:00.001-08:00</published><updated>2009-02-10T17:04:16.081-08:00</updated><title type='text'>BizTalk WCF Misbehaviors [Part 1]</title><content type='html'>&lt;p&gt;For my first post I thought I would share some of my experiences getting a BizTalk WCF send adapter to behave with an unusually configured client endpoint. &lt;/p&gt; &lt;p&gt;The client had a service listening via https, and had strict requirements on what they would expect in the header of the request. Particularly they wanted WS-Addressing and WS-Security headers to look like [details obscured for obvious reasons]: &lt;/p&gt;&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;s:Header&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;br /&gt;  &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;a:Action&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;MyAction&lt;span style="color: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;a:Action&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;br /&gt;  &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;a:To&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;MyToAddress&lt;span style="color: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;a:To&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;br /&gt;  &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;a:From&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;br /&gt;    &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;a:Address&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;MyFromAddress&lt;span style="color: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;a:Address&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;br /&gt;  &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;a:From&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;br /&gt;  &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Security&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;br /&gt;    &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;UsernameToken&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;br /&gt;      &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Username&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;MyUsername&lt;span style="color: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;Username&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;br /&gt;      &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Password&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;MyPassword&lt;span style="color: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;Password&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;br /&gt;    &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;UsernameToken&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;br /&gt;  &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;Security&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;br /&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;s:Header&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;br /&gt;&lt;p&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;The client was using the Action, To and From headers to do routing at their end, so they had to be exact.&amp;nbsp; Additionally they also wanted WS-Security headers attached to the outgoing message, although their service didn’t return a compliant WS-Security response. &lt;br&gt;&lt;br&gt;First up, I tried to go down the path of getting BizTalk to send the correct headers, by setting up a WCF Custom configuration with a wsHttpBinding, in order to generate the correct security headers. &lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;a href="http://lh4.ggpht.com/_EiREDyJGw8Y/SZIjoI1BS1I/AAAAAAAAABg/IZJdOGsRyCA/s1600-h/wshttpconfig%5B7%5D.png"&gt;&lt;img title="wshttpconfig" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="422" alt="wshttpconfig" src="http://lh4.ggpht.com/_EiREDyJGw8Y/SZIjouujtLI/AAAAAAAAABk/reTyCIUQ8kQ/wshttpconfig_thumb%5B5%5D.png?imgmax=800" width="330" border="0"&gt;&lt;/a&gt; &lt;br /&gt;&lt;p&gt;Then, following the details of &lt;a href="http://msdn.microsoft.com/en-us/library/bb967002.aspx"&gt;this MSDN article&lt;/a&gt; I directly set the WCF context properties in my orchestration expression shape. &lt;br /&gt;&lt;p&gt;&amp;nbsp;&lt;a href="http://lh6.ggpht.com/_EiREDyJGw8Y/SZIjpcIC4OI/AAAAAAAAABo/ZOmclVf2bWE/s1600-h/expressionshape%5B4%5D.png"&gt;&lt;img title="expressionshape" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="409" alt="expressionshape" src="http://lh3.ggpht.com/_EiREDyJGw8Y/SZIjp7IxuRI/AAAAAAAAABs/bWcjp7kaBIw/expressionshape_thumb%5B2%5D.png?imgmax=800" width="564" border="0"&gt;&lt;/a&gt; &lt;/p&gt;&lt;br /&gt;&lt;p&gt;After sending my message through BizTalk, I got an error message from the remote endpoint indicating the message was not correctly addressed. Clearly something wasn’t working as intended, so I needed to start looking at the WCF messages directly. The easiest way to do this is enable WCF tracing directly in BizTalk by adding this section to my BTSNTSvc.exe.config file: &lt;pre class="code"&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;system.diagnostics&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;br /&gt;  &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;sources&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;br /&gt;    &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;source &lt;/span&gt;&lt;span style="color: red"&gt;name &lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;System.ServiceModel&lt;/span&gt;" &lt;span style="color: red"&gt;switchValue&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;Verbose&lt;/span&gt;"&lt;span style="color: blue"&gt;&amp;gt;&lt;br /&gt;      &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;listeners&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;br /&gt;        &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;add &lt;/span&gt;&lt;span style="color: red"&gt;name&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;xml&lt;/span&gt;" &lt;span style="color: blue"&gt;/&amp;gt;&lt;br /&gt;      &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;listeners&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;br /&gt;    &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;source&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;br /&gt;    &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;source &lt;/span&gt;&lt;span style="color: red"&gt;name &lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;System.ServiceModel.MessageLogging&lt;/span&gt;"&lt;br /&gt;            &lt;span style="color: red"&gt;switchValue&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;Verbose, ActivityTracing&lt;/span&gt;"&lt;span style="color: blue"&gt;&amp;gt;&lt;br /&gt;      &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;listeners&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;br /&gt;        &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;add &lt;/span&gt;&lt;span style="color: red"&gt;name&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;xml&lt;/span&gt;" &lt;span style="color: blue"&gt;/&amp;gt;&lt;br /&gt;      &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;listeners&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;br /&gt;    &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;source&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;br /&gt;    &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;source &lt;/span&gt;&lt;span style="color: red"&gt;name &lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;System.Runtime.Serialization&lt;/span&gt;" &lt;span style="color: red"&gt;switchValue&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;Verbose&lt;/span&gt;"&lt;span style="color: blue"&gt;&amp;gt;&lt;br /&gt;      &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;listeners&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;br /&gt;        &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;add &lt;/span&gt;&lt;span style="color: red"&gt;name&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;xml&lt;/span&gt;" &lt;span style="color: blue"&gt;/&amp;gt;&lt;br /&gt;      &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;listeners&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;br /&gt;    &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;source&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;br /&gt;  &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;sources&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;br /&gt;  &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;sharedListeners&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;br /&gt;    &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;add &lt;/span&gt;&lt;span style="color: red"&gt;name&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;xml&lt;/span&gt;" &lt;span style="color: red"&gt;type&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;System.Diagnostics.XmlWriterTraceListener&lt;/span&gt;"&lt;br /&gt;         &lt;span style="color: red"&gt;traceOutputOptions&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;LogicalOperationStack&lt;/span&gt;"&lt;br /&gt;         &lt;span style="color: red"&gt;initializeData&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;C:\log\BizTalkTrace.svclog&lt;/span&gt;" &lt;span style="color: blue"&gt;/&amp;gt;&lt;br /&gt;  &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;sharedListeners&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;br /&gt;  &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;trace &lt;/span&gt;&lt;span style="color: red"&gt;autoflush&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;true&lt;/span&gt;" &lt;span style="color: blue"&gt;/&amp;gt;&lt;br /&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;system.diagnostics&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;br /&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;system.serviceModel&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;br /&gt;  &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;diagnostics&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;br /&gt;    &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;messageLogging&lt;br /&gt;         &lt;/span&gt;&lt;span style="color: red"&gt;logEntireMessage&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;true&lt;/span&gt;"&lt;br /&gt;         &lt;span style="color: red"&gt;logMalformedMessages&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;false&lt;/span&gt;"&lt;br /&gt;         &lt;span style="color: red"&gt;logMessagesAtServiceLevel&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;true&lt;/span&gt;"&lt;br /&gt;         &lt;span style="color: red"&gt;logMessagesAtTransportLevel&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;true&lt;/span&gt;"&lt;span style="color: blue"&gt;/&amp;gt;&lt;br /&gt;  &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;diagnostics&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;br /&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;system.serviceModel&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;br /&gt;&lt;p&gt;I sent another message through BizTalk, and inspected the outgoing message headers: &lt;pre class="code"&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;a:Action &lt;/span&gt;&lt;span style="color: red"&gt;s:mustUnderstand&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;1&lt;/span&gt;"&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;MyAction&lt;span style="color: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;a:Action&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;br /&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;a:MessageID&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;urn:uuid:2a013aa6-12a8-4e67-8377-0c75847f2cb1&lt;span style="color: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;a:MessageID&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;br /&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;a:ReplyTo&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;br /&gt;  &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;a:Address&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;http://www.w3.org/2005/08/addressing/anonymous&lt;span style="color: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;a:Address&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;br /&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;a:ReplyTo&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;br /&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;a:To &lt;/span&gt;&lt;span style="color: red"&gt;s:mustUnderstand&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;1&lt;/span&gt;"&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;MySendPortPhysicalAddress&lt;span style="color: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;a:To&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;br /&gt;&lt;p&gt;Uh-oh! BizTalk is not respecting my WCF context properties from the orchestration. &lt;br /&gt;&lt;p&gt;In fact: &lt;br /&gt;&lt;p&gt;- the Action header has been &lt;strong&gt;preserved&lt;/strong&gt; from the context property&lt;br&gt;- the To address header has been &lt;strong&gt;overwritten&lt;/strong&gt; by the send port endpoint address&lt;br&gt;- the From address header is &lt;strong&gt;not written at all&lt;/strong&gt;! &lt;br /&gt;&lt;p&gt;After a few more hours of trial and error is became clear that this approach was not going to work at all. In this context, BizTalk will not respect the context properties in the send adapter for WCF – so it was time for a new direction. &lt;br /&gt;&lt;p&gt;In part two, I will show how to use a great feature of&amp;nbsp; WCF to solve this issue. &lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3696827856353448753-5822117101923359790?l=connectingsystems.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://connectingsystems.blogspot.com/feeds/5822117101923359790/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://connectingsystems.blogspot.com/2009/02/biztalk-wcf-misbehaviors-part-1.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3696827856353448753/posts/default/5822117101923359790'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3696827856353448753/posts/default/5822117101923359790'/><link rel='alternate' type='text/html' href='http://connectingsystems.blogspot.com/2009/02/biztalk-wcf-misbehaviors-part-1.html' title='BizTalk WCF Misbehaviors [Part 1]'/><author><name>Grant Samuels</name><uri>http://www.blogger.com/profile/07008298142913353091</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh4.ggpht.com/_EiREDyJGw8Y/SZIjouujtLI/AAAAAAAAABk/reTyCIUQ8kQ/s72-c/wshttpconfig_thumb%5B5%5D.png?imgmax=800' height='72' width='72'/><thr:total>1</thr:total></entry></feed>
