Rolf Nebhuthhttp://developers.de/blogs/rolf_nebhuth/atom.aspxCommunity Server2006-07-27T16:24:00ZCustom WCF Tracing problem with “propagateActivity” Attribute/blogs/rolf_nebhuth/archive/2009/05/26/custom-wcf-tracing-problem-with-propagateactivity-attribute.aspx2009-05-26T08:50:00Z2009-05-26T08:50:00Z<p>If you want to trace in the same trace source as WCF you can use this <a href="http://developers.de/blogs/damir_dobric/archive/2009/03/27/code-which-write-to-wcf-trace.aspx">Example in Damir Dobric Blog</a>. But if you use the WCF Configuration Editor to generate the System.Diagnostic section in the configuration file, this call will fail with the error “<b>'propagateActivity' is not a valid configuration attribute for type 'System.Diagnostics.TraceSource'.” </b>The Problem is that WCF uses his own TraceSource implemention, which has additional attributes, as the “propagateActivity”.</p>
<p>A simple solution to fix the problem is to have its own TraceSource implementation, which have all supported attributes of WCF Trace Source. </p>
<table cellpadding="0" cellspacing="0" class="MsoTableGrid" style="border-bottom:medium none;border-left:medium none;border-collapse:collapse;border-top:medium none;border-right:medium none;mso-border-alt:solid black .5pt;mso-border-themecolor:text1;mso-yfti-tbllook:1184;mso-padding-alt:0cm 5.4pt 0cm 5.4pt;">
<tr style="mso-yfti-irow:0;mso-yfti-firstrow:yes;mso-yfti-lastrow:yes;">
<td style="border-bottom:black 1pt solid;border-left:black 1pt solid;padding-bottom:0cm;padding-left:5.4pt;width:460.6pt;padding-right:5.4pt;border-top:black 1pt solid;border-right:black 1pt solid;padding-top:0cm;mso-border-alt:solid black .5pt;mso-border-themecolor:text1;">
<p class="MsoNormal"><span style="font-family:'Courier New';color:#0000ff;font-size:10pt;mso-ansi-language:en-us;mso-no-proof:yes;">internal</span><span style="font-family:'Courier New';font-size:10pt;mso-ansi-language:en-us;mso-no-proof:yes;"> <span style="color:#0000ff;">class</span> <span style="color:#2b91af;">WcfTraceSource</span> : <span style="color:#2b91af;">TraceSource <br /></span>{ <br /><span style="mso-spacerun:yes;"> </span><span style="color:#808080;">///</span><span style="color:#008000;"> </span><span style="color:#808080;"><summary> <br /></span><span style="mso-spacerun:yes;"> </span><span style="color:#808080;">///</span><span style="color:#008000;"> Create the WCF Trace Source. <br /></span><span style="mso-spacerun:yes;"> </span><span style="color:#808080;">///</span><span style="color:#008000;"> </span><span style="color:#808080;"></summary> <br /></span><span style="mso-spacerun:yes;"> </span><span style="color:#0000ff;">internal</span> WcfTraceSource() <br /><span style="mso-spacerun:yes;"> </span>: <span style="color:#0000ff;">base</span>(<span style="color:#a31515;">"System.ServiceModel"</span>) <br /><span style="mso-spacerun:yes;"> </span>{ <br /><span style="mso-spacerun:yes;"> </span>} <br /><br /><span style="mso-spacerun:yes;"> </span><span style="color:#808080;">///</span><span style="color:#008000;"> </span><span style="color:#808080;"><summary> <br /></span><span style="mso-spacerun:yes;"> </span><span style="color:#808080;">///</span><span style="color:#008000;"> Gets the supported attributes from WCF <br /><span style="mso-spacerun:yes;"> </span>/// "propagateActivity" and "logKnownPii" <br /></span><span style="mso-spacerun:yes;"> </span><span style="color:#808080;">///</span><span style="color:#008000;"> </span><span style="color:#808080;"></summary> <br /></span><span style="mso-spacerun:yes;"> </span><span style="color:#808080;">///</span><span style="color:#008000;"> </span><span style="color:#808080;"><returns></span><span style="color:#008000;">Returns the supported attributes.</span><span style="color:#808080;"></returns> <br /></span><span style="mso-spacerun:yes;"> </span><span style="color:#0000ff;">protected</span> <span style="color:#0000ff;">override</span> <span style="color:#0000ff;">string</span>[] GetSupportedAttributes() <br /><span style="mso-spacerun:yes;"> </span>{ <br /><span style="mso-spacerun:yes;"> </span><span style="color:#0000ff;">string</span>[] supportedAttributes = <span style="color:#0000ff;">base</span>.GetSupportedAttributes(); <br /><span style="mso-spacerun:yes;"> </span><span style="color:#0000ff;">if</span> (supportedAttributes == <span style="color:#0000ff;">null</span>) <br /><span style="mso-spacerun:yes;"> </span><span style="color:#0000ff;">return</span> <span style="color:#0000ff;">new</span> <span style="color:#0000ff;">string</span>[] { <span style="color:#a31515;">"propagateActivity"</span>, <span style="color:#a31515;">"logKnownPii"</span> }; <br /><br /><span style="mso-spacerun:yes;"> </span><span style="color:#0000ff;">string</span>[] newSupportedAttributes = <br /><span style="mso-spacerun:yes;"> </span><span style="color:#0000ff;">new</span> <span style="color:#0000ff;">string</span>[supportedAttributes.Length + 2]; <br /><span style="mso-spacerun:yes;"> </span><span style="color:#2b91af;">Array</span>.Copy( <br /><span style="mso-spacerun:yes;"> </span>supportedAttributes, <br /><span style="mso-spacerun:yes;"> </span>newSupportedAttributes, <br /><span style="mso-spacerun:yes;"> </span>supportedAttributes.Length); <br /><span style="mso-spacerun:yes;"> </span>newSupportedAttributes[supportedAttributes.Length - 1] = <span style="mso-spacerun:yes;"> </span></span>
<p> </p>
</p>
<p> </p>
<p class="MsoNormal"><span style="font-family:'Courier New';font-size:10pt;mso-ansi-language:en-us;mso-no-proof:yes;"><span style="mso-spacerun:yes;"> </span><span style="color:#a31515;">"propagateActivity"</span>; <br /><span style="mso-spacerun:yes;"> </span>newSupportedAttributes[supportedAttributes.Length] = <span style="mso-spacerun:yes;"> </span> <br /><span style="mso-spacerun:yes;"> </span><span style="color:#a31515;">"logKnownPii"</span>; <br /><span style="mso-spacerun:yes;"> </span><span style="mso-spacerun:yes;"> </span><span style="color:#0000ff;">return</span> newSupportedAttributes; <br /><span style="mso-spacerun:yes;"> </span>} <br />}</span><span style="mso-ansi-language:en-us;"> </span>
<p> </p>
</p>
<p> </p>
</td>
</tr>
</table>
<p class="MsoNormal"><span style="mso-ansi-language:en-us;"><br style="mso-special-character:line-break;" /><br style="mso-special-character:line-break;" /></span></p><div style="clear:both;"></div><img src="http://developers.de/aggbug.aspx?PostID=5558" width="1" height="1">rnebhuthhttp://developers.de/members/rnebhuth/default.aspxSigning Click Once Applications/blogs/rolf_nebhuth/archive/2009/05/14/signing-click-once-applications.aspx2009-05-14T09:00:00Z2009-05-14T09:00:00Z<p class="MsoNormal"><span style="mso-ansi-language:en-us;">If you play with Click Once deployment, you noticed that is really click twice because you will be asked if you trust the publisher.
<p> </p>
</span></p>
<p class="MsoNormal"><span style="mso-no-proof:yes;mso-fareast-language:de;"><a href="http://developers.de/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/rolf_5F00_nebhuth/clip_5F00_image002_5F00_306F8D25.jpg"><img height="130" width="244" src="http://developers.de/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/rolf_5F00_nebhuth/clip_5F00_image002_5F00_thumb_5F00_340DA802.jpg" alt="clip_image002" border="0" title="clip_image002" style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" /></a></span><span style="mso-ansi-language:en-us;"><span style="mso-spacerun:yes;"> </span><span style="mso-spacerun:yes;"> </span><span>
<p> </p>
</span></span></p>
<p class="MsoNormal"><span style="mso-ansi-language:en-us;">If you want to have the real Click Once Feeling you need to have to sign your application. <span style="mso-spacerun:yes;"> </span>Following Steps are required to do this.
<p> </p>
</span></p>
<ol>
<li>
<div class="MsoListParagraph" style="text-indent:-18pt;mso-list:l0 level1 lfo1;"><span style="mso-ansi-language:en-us;mso-bidi-font-family:calibri;mso-bidi-theme-font:minor-latin;"><span style="mso-list:ignore;">1.<span style="font-family:'Times New Roman';"> </span></span></span><span style="mso-ansi-language:en-us;">Buy or create or a Signing Certificate
<p> </p>
</span></div>
</li>
</ol>
<p class="MsoNormal"><span style="mso-ansi-language:en-us;">If you use the Click Once application for an internet deployment you should buy a certificate because your Certificate must be signed from a known root certificate. In an enterprise environment you can do self singing or better, if you have a Certificate Authority (CA) in your domain use this for creating the certificate.
<p> </p>
</span></p>
<ol>
<li>
<div class="MsoListParagraphCxSpFirst" style="text-indent:-18pt;mso-list:l0 level1 lfo1;"><span style="mso-ansi-language:en-us;mso-bidi-font-family:calibri;mso-bidi-theme-font:minor-latin;"><span style="mso-list:ignore;">2.<span style="font-family:'Times New Roman';"> </span></span></span><span style="mso-ansi-language:en-us;">Sign your application
<p> </p>
</span></div>
</li>
</ol>
<blockquote>
<p class="MsoListParagraphCxSpMiddle"><span style="mso-ansi-language:en-us;">Open the Project Properties of your application. Open Signing and add you certificate for the Click Once manifest.
<p> </p>
</span></p>
</blockquote>
<blockquote>
<p class="MsoListParagraphCxSpMiddle"><span style="mso-no-proof:yes;mso-fareast-language:de;"><a href="http://developers.de/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/rolf_5F00_nebhuth/clip_5F00_image004_5F00_68AE043D.jpg"><img height="159" width="244" src="http://developers.de/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/rolf_5F00_nebhuth/clip_5F00_image004_5F00_thumb_5F00_6841D148.jpg" alt="clip_image004" border="0" title="clip_image004" style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" /></a></span></p>
</blockquote>
<p><span style="mso-ansi-language:en-us;">
<p> </p>
</span></p>
<blockquote>
<p class="MsoListParagraphCxSpMiddle"><span style="mso-ansi-language:en-us;">If you deploy now and start the Click Once deployment the installer asks again if you want to install it.
<p> </p>
</span></p>
</blockquote>
<blockquote>
<p class="MsoListParagraphCxSpMiddle"><span style="mso-no-proof:yes;mso-fareast-language:de;"><a href="http://developers.de/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/rolf_5F00_nebhuth/clip_5F00_image006_5F00_4ED9CE0E.jpg"><img height="130" width="244" src="http://developers.de/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/rolf_5F00_nebhuth/clip_5F00_image006_5F00_thumb_5F00_20804861.jpg" alt="clip_image006" border="0" title="clip_image006" style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" /></a></span></p>
</blockquote>
<p><span style="mso-ansi-language:en-us;">
<p> </p>
</span></p>
<blockquote>
<p class="MsoListParagraphCxSpLast"><span style="mso-ansi-language:en-us;">But now you can see who create the application and that the Publisher ha valid certificate. If you are in a internet deployment scenario this is as far you can go. In an enterprise deployment you can eliminate this window, if you add the certificate in every machine in you domain in the “Trusted Publisher” Folder.
<p> </p>
</span></p>
</blockquote><div style="clear:both;"></div><img src="http://developers.de/aggbug.aspx?PostID=5355" width="1" height="1">rnebhuthhttp://developers.de/members/rnebhuth/default.aspxSetup for VSTO 3.0 Outlook 2007 Plugin with MSI/blogs/rolf_nebhuth/archive/2009/05/14/setup-for-vsto-3-0-outlook-2007-plugin-with-msi.aspx2009-05-14T08:11:00Z2009-05-14T08:11:00Z<p class="MsoNormal"><span style="mso-ansi-language:en-us;">If you want to install a VSTO Plugin with VSTO 3.0 the default way is to deploy this application with Click Once (<a href="http://developers.de/blogs/damir_dobric/archive/2009/02/12/publishing-of-outlook-2007-addin-with-clickonce-and-vs2008.aspx">Publishing of Outlook 2007 AddIn with ClickOnce and VS2008</a>).
<p> </p>
</span></p>
<p class="MsoNormal"><span style="mso-ansi-language:en-us;">This approach has the disadvantage that the user must install the plug-in manually, and in big companies the IT want to deploy their applications for all users, so they can be sure that the software is installed on every computer. Microsoft have no direct way to do this anymore, but there is a Article which describes who to do this in the MSDN.
<p> </p>
</span></p>
<p class="MsoNormal"><span style="mso-ansi-language:en-us;">Deploying a Visual Studio Tools for the Office System 3.0 Solution for the 2007 Microsoft Office System Using Windows Installer (<a href="http://msdn.microsoft.com/en-us/library/cc563937.aspx">Part 1</a> + <a href="http://msdn.microsoft.com/en-us/library/cc563937.aspx">Part 2</a>)
<p> </p>
</span></p>
<p class="MsoNormal"><span style="mso-ansi-language:en-us;">The document describes in detail, how to create a MSI package, it is not the whole solution for the deployment in a company. A VSTO plug-in is only function, for a user who installed the plug-in because; VSTO only works if it is installed in the user hive of the registry. In the automatic deployment scenario the install user is not the user who uses the software and so if fails. A solution for this is to create the user registry keys in a second deployment process which runs once a user logins a computer. The registry keys must be the same as in the MSI package which will be installed. To do this you can create a second MSI package which contains only the registry key and deploy this with a group policy or with your software deployment solution.
<p> </p>
</span></p>
<p class="MsoNormal"><span style="mso-ansi-language:en-us;">The second problem is that with MSI deployment, the plug-in-in is not really installed, this installation is started automatically when Outlook the next time started. This is the normal Click Once deployment and if the add in is not signed or the author is not trusted then the user is asked if they want to install it, and if they say no the plug-in will not be installed. Because of this it is necessary to sign the application a description, how you can do this find you <a href="http://developers.de/blogs/rolf_nebhuth/archive/2009/05/14/signing-click-once-applications.aspx">here</a>.
<p> </p>
</span></p><div style="clear:both;"></div><img src="http://developers.de/aggbug.aspx?PostID=5352" width="1" height="1">rnebhuthhttp://developers.de/members/rnebhuth/default.aspxSigning Xml Documents/blogs/rolf_nebhuth/archive/2009/05/13/signing-xml-documents.aspx2009-05-13T14:35:00Z2009-05-13T14:35:00Z<p class="MsoNormal"><span style="mso-ansi-language:en-us;">If you want to check if an XML is not changed, you can sign an XML file. Following Code show you how to sign a XML <span style="mso-spacerun:yes;"> </span>document.
<p> </p>
</span></p>
<table cellpadding="0" cellspacing="0" class="MsoTableGrid" style="border-bottom:medium none;border-left:medium none;border-collapse:collapse;border-top:medium none;border-right:medium none;mso-border-alt:solid black .5pt;mso-border-themecolor:text1;mso-yfti-tbllook:1184;mso-padding-alt:0cm 5.4pt 0cm 5.4pt;">
<tr style="mso-yfti-irow:0;mso-yfti-firstrow:yes;mso-yfti-lastrow:yes;">
<td style="border-bottom:black 1pt solid;border-left:black 1pt solid;padding-bottom:0cm;padding-left:5.4pt;width:477.3pt;padding-right:5.4pt;border-top:black 1pt solid;border-right:black 1pt solid;padding-top:0cm;mso-border-alt:solid black .5pt;mso-border-themecolor:text1;">
<p class="MsoNormal"><span style="font-family:'Courier New';color:#2b91af;font-size:10pt;mso-ansi-language:en-us;mso-no-proof:yes;">X509Certificate2</span><span style="font-family:'Courier New';font-size:10pt;mso-ansi-language:en-us;mso-no-proof:yes;"> cert = loadCertifate(); <br /><br /><span style="color:#2b91af;">XmlDocument</span> doc = <span style="color:#0000ff;">new</span> <span style="color:#2b91af;">XmlDocument</span>(); <br />doc.PreserveWhitespace = <span style="color:#0000ff;">true</span>; <br />doc.Load(<span style="color:#a31515;">@"c:\Temp\Unsigned.xml"</span>); <br /><br /><span style="color:#2b91af;">SignedXml</span> signedXml = <span style="color:#0000ff;">new</span> <span style="color:#2b91af;">SignedXml</span>(doc); <br />signedXml.SigningKey = cert.PrivateKey; <br /><br /><span style="color:#008000;">// <br />// Add a signing reference, the uri is empty and so the whole document <br />// is signed. <br /></span><span style="color:#2b91af;">Reference</span> reference = <span style="color:#0000ff;">new</span> <span style="color:#2b91af;">Reference</span>(); <br />reference.AddTransform(<span style="color:#0000ff;">new</span> <span style="color:#2b91af;">XmlDsigEnvelopedSignatureTransform</span>()); <br />reference.AddTransform(<span style="color:#0000ff;">new</span> <span style="color:#2b91af;">XmlDsigExcC14NTransform</span>()); <br />reference.Uri = <span style="color:#a31515;">""</span>; <br />signedXml.AddReference(reference); <br /><br /><span style="color:#008000;">// <br />// Add the certificate as key info, because of this the certificate <br />// with the public key will be added in the signature part. <br /></span><span style="color:#2b91af;">KeyInfo</span> keyInfo = <span style="color:#0000ff;">new</span> <span style="color:#2b91af;">KeyInfo</span>(); <br />keyInfo.AddClause(<span style="color:#0000ff;">new</span> <span style="color:#2b91af;">KeyInfoX509Data</span>(cert)); <br />signedXml.KeyInfo = keyInfo; <br /><br /><span style="color:#008000;">// Generate the signature. <br /></span>signedXml.ComputeSignature(); <br /><br /><span style="color:#008000;">// Appends the sigbature at the end of the xml document. <br /></span></span><span style="font-family:'Courier New';font-size:10pt;mso-no-proof:yes;">doc.DocumentElement.AppendChild(signedXml.GetXml()); <br style="mso-special-character:line-break;" /><br style="mso-special-character:line-break;" /></span></p>
</td>
</tr>
</table>
<p class="MsoNormal"><br /><span style="mso-ansi-language:en-us;">The result XML looks like that.
<p> </p>
</span></p>
<table cellpadding="0" cellspacing="0" class="MsoTableGrid" style="border-bottom:medium none;border-left:medium none;border-collapse:collapse;border-top:medium none;border-right:medium none;mso-border-alt:solid black .5pt;mso-border-themecolor:text1;mso-yfti-tbllook:1184;mso-padding-alt:0cm 5.4pt 0cm 5.4pt;">
<tr style="mso-yfti-irow:0;mso-yfti-firstrow:yes;mso-yfti-lastrow:yes;">
<td style="border-bottom:black 1pt solid;border-left:black 1pt solid;padding-bottom:0cm;padding-left:5.4pt;width:477.3pt;padding-right:5.4pt;border-top:black 1pt solid;border-right:black 1pt solid;padding-top:0cm;mso-border-alt:solid black .5pt;mso-border-themecolor:text1;">
<p class="MsoNormal"><span style="font-family:'Courier New';color:#0000ff;font-size:10pt;mso-ansi-language:en-us;mso-no-proof:yes;"><</span><span style="font-family:'Courier New';color:#a31515;font-size:10pt;mso-ansi-language:en-us;mso-no-proof:yes;">test</span><span style="font-family:'Courier New';color:#0000ff;font-size:10pt;mso-ansi-language:en-us;mso-no-proof:yes;">> <br /><span style="mso-spacerun:yes;"> </span><</span><span style="font-family:'Courier New';color:#a31515;font-size:10pt;mso-ansi-language:en-us;mso-no-proof:yes;">data</span><span style="font-family:'Courier New';color:#0000ff;font-size:10pt;mso-ansi-language:en-us;mso-no-proof:yes;"> </span><span style="font-family:'Courier New';color:#ff0000;font-size:10pt;mso-ansi-language:en-us;mso-no-proof:yes;">Id</span><span style="font-family:'Courier New';color:#0000ff;font-size:10pt;mso-ansi-language:en-us;mso-no-proof:yes;">=</span><span style="font-family:'Courier New';font-size:10pt;mso-ansi-language:en-us;mso-no-proof:yes;">"<span style="color:#0000ff;">test1</span>"<span style="color:#0000ff;">> <br /><span style="mso-spacerun:yes;"> </span><</span><span style="color:#a31515;">description</span><span style="color:#0000ff;">></span>bla bla bla<span style="color:#0000ff;"></</span><span style="color:#a31515;">description</span><span style="color:#0000ff;">> <br /><span style="mso-spacerun:yes;"> </span></</span><span style="color:#a31515;">data</span><span style="color:#0000ff;">> <br /><span style="mso-spacerun:yes;"> </span><</span><span style="color:#a31515;">data</span><span style="color:#0000ff;"> </span><span style="color:#ff0000;">Id</span><span style="color:#0000ff;">=</span>"<span style="color:#0000ff;">test2</span>"<span style="color:#0000ff;">> <br /><span style="mso-spacerun:yes;"> </span><</span><span style="color:#a31515;">description</span><span style="color:#0000ff;">></span>bla bla bla<span style="color:#0000ff;"></</span><span style="color:#a31515;">description</span><span style="color:#0000ff;">> <br /><span style="mso-spacerun:yes;"> </span></</span><span style="color:#a31515;">data</span><span style="color:#0000ff;">> <br /><span style="mso-spacerun:yes;"> </span><</span><span style="color:#a31515;">data</span><span style="color:#0000ff;"> </span><span style="color:#ff0000;">Id</span><span style="color:#0000ff;">=</span>"<span style="color:#0000ff;">test3</span>"<span style="color:#0000ff;">> <br /><span style="mso-spacerun:yes;"> </span><</span><span style="color:#a31515;">description</span><span style="color:#0000ff;">></span>bla bla bla<span style="color:#0000ff;"></</span><span style="color:#a31515;">description</span><span style="color:#0000ff;">> <br /><span style="mso-spacerun:yes;"> </span></</span><span style="color:#a31515;">data</span><span style="color:#0000ff;">> <br /><span style="mso-spacerun:yes;"> </span><</span><span style="color:#a31515;">Signature</span><span style="color:#0000ff;"> </span><span style="color:#ff0000;">xmlns</span><span style="color:#0000ff;">=</span>"<span style="color:#0000ff;">http://www.w3.org/2000/09/xmldsig#</span>"<span style="color:#0000ff;">> <br /><span style="mso-spacerun:yes;"> </span><</span><span style="color:#a31515;">SignedInfo</span><span style="color:#0000ff;">> <br /><span style="mso-spacerun:yes;"> </span><</span><span style="color:#a31515;">CanonicalizationMethod</span><span style="color:#0000ff;"> </span><span style="color:#ff0000;">Algorithm</span><span style="color:#0000ff;">=</span>"<span style="color:#0000ff;">http://www.w3.org/TR/2001/REC-xml-c14n-20010315</span>"<span style="color:#0000ff;"> /> <br /><span style="mso-spacerun:yes;"> </span><</span><span style="color:#a31515;">SignatureMethod</span><span style="color:#0000ff;"> </span><span style="color:#ff0000;">Algorithm</span><span style="color:#0000ff;">=</span>"<span style="color:#0000ff;">http://www.w3.org/2000/09/xmldsig#dsa-sha1</span>"<span style="color:#0000ff;"> /> <br /><span style="mso-spacerun:yes;"> </span><</span><span style="color:#a31515;">Reference</span><span style="color:#0000ff;"> </span><span style="color:#ff0000;">URI</span><span style="color:#0000ff;">=</span>""<span style="color:#0000ff;">> <br /><span style="mso-spacerun:yes;"> </span><</span><span style="color:#a31515;">Transforms</span><span style="color:#0000ff;">> <br /><span style="mso-spacerun:yes;"> </span><</span><span style="color:#a31515;">Transform</span><span style="color:#0000ff;"> </span><span style="color:#ff0000;">Algorithm</span><span style="color:#0000ff;">=</span>"<span style="color:#0000ff;">http://www.w3.org/2000/09/xmldsig#enveloped-signature</span>"<span style="color:#0000ff;"> /> <br /><span style="mso-spacerun:yes;"> </span></span></span><span style="font-family:'Courier New';color:#0000ff;font-size:10pt;mso-no-proof:yes;"><</span><span style="font-family:'Courier New';color:#a31515;font-size:10pt;mso-no-proof:yes;">Transform</span><span style="font-family:'Courier New';color:#0000ff;font-size:10pt;mso-no-proof:yes;"> </span><span style="font-family:'Courier New';color:#ff0000;font-size:10pt;mso-no-proof:yes;">Algorithm</span><span style="font-family:'Courier New';color:#0000ff;font-size:10pt;mso-no-proof:yes;">=</span><span style="font-family:'Courier New';font-size:10pt;mso-no-proof:yes;">"<span style="color:#0000ff;">http://www.w3.org/2001/10/xml-exc-c14n#</span>"<span style="color:#0000ff;"> /> <br /><span style="mso-spacerun:yes;"> </span></span></span><span style="font-family:'Courier New';color:#0000ff;font-size:10pt;mso-ansi-language:en-us;mso-no-proof:yes;"></</span><span style="font-family:'Courier New';color:#a31515;font-size:10pt;mso-ansi-language:en-us;mso-no-proof:yes;">Transforms</span><span style="font-family:'Courier New';color:#0000ff;font-size:10pt;mso-ansi-language:en-us;mso-no-proof:yes;">> <br /><span style="mso-spacerun:yes;"> </span><</span><span style="font-family:'Courier New';color:#a31515;font-size:10pt;mso-ansi-language:en-us;mso-no-proof:yes;">DigestMethod</span><span style="font-family:'Courier New';color:#0000ff;font-size:10pt;mso-ansi-language:en-us;mso-no-proof:yes;"> </span><span style="font-family:'Courier New';color:#ff0000;font-size:10pt;mso-ansi-language:en-us;mso-no-proof:yes;">Algorithm</span><span style="font-family:'Courier New';color:#0000ff;font-size:10pt;mso-ansi-language:en-us;mso-no-proof:yes;">=</span><span style="font-family:'Courier New';font-size:10pt;mso-ansi-language:en-us;mso-no-proof:yes;">"<span style="color:#0000ff;">http://www.w3.org/2000/09/xmldsig#sha1</span>"<span style="color:#0000ff;"> /> <br /><span style="mso-spacerun:yes;"> </span><</span><span style="color:#a31515;">DigestValue</span><span style="color:#0000ff;">></span>viYAUV9bBBo1nYzq0+8ehB8kdjc=<span style="color:#0000ff;"></</span><span style="color:#a31515;">DigestValue</span><span style="color:#0000ff;">> <br /><span style="mso-spacerun:yes;"> </span></</span><span style="color:#a31515;">Reference</span><span style="color:#0000ff;">> <br /><span style="mso-spacerun:yes;"> </span></</span><span style="color:#a31515;">SignedInfo</span><span style="color:#0000ff;">> <br /><span style="mso-spacerun:yes;"> </span><</span><span style="color:#a31515;">SignatureValue</span><span style="color:#0000ff;">></span>fTD4lMunhlYLWBCPDVxLL9JVXc1WWOSx+evx/Sca/3LSvEnH1ez9WA==<span style="color:#0000ff;"></</span><span style="color:#a31515;">SignatureValue</span><span style="color:#0000ff;">> <br /><span style="mso-spacerun:yes;"> </span><</span><span style="color:#a31515;">KeyInfo</span><span style="color:#0000ff;">> <br /><span style="mso-spacerun:yes;"> </span><</span><span style="color:#a31515;">X509Data</span><span style="color:#0000ff;">> <br /><span style="mso-spacerun:yes;"> </span><</span><span style="color:#a31515;">X509Certificate</span><span style="color:#0000ff;">></span>.....<span style="color:#0000ff;"></</span><span style="color:#a31515;">X509Certificate</span><span style="color:#0000ff;">> <br /><span style="mso-spacerun:yes;"> </span></</span><span style="color:#a31515;">X509Data</span><span style="color:#0000ff;">> <br /><span style="mso-spacerun:yes;"> </span></span></span><span style="font-family:'Courier New';color:#0000ff;font-size:10pt;mso-no-proof:yes;"></</span><span style="font-family:'Courier New';color:#a31515;font-size:10pt;mso-no-proof:yes;">KeyInfo</span><span style="font-family:'Courier New';color:#0000ff;font-size:10pt;mso-no-proof:yes;">> <br /><span style="mso-spacerun:yes;"> </span></</span><span style="font-family:'Courier New';color:#a31515;font-size:10pt;mso-no-proof:yes;">Signature</span><span style="font-family:'Courier New';color:#0000ff;font-size:10pt;mso-no-proof:yes;">> <br /></</span><span style="font-family:'Courier New';color:#a31515;font-size:10pt;mso-no-proof:yes;">test</span><span style="font-family:'Courier New';color:#0000ff;font-size:10pt;mso-no-proof:yes;">></span><span style="mso-ansi-language:en-us;">
<p> </p>
</span></p>
</td>
</tr>
</table>
<p class="MsoNormal"><span style="mso-ansi-language:en-us;"><br />In some cases it is necessary that only some parts of an XML are signed and not the whole document. <span style="mso-spacerun:yes;"> </span>For this you must change the URI so it references to a part of the XML, something like this.
<p> </p>
</span></p>
<table cellpadding="0" cellspacing="0" class="MsoTableGrid" style="border-bottom:medium none;border-left:medium none;border-collapse:collapse;border-top:medium none;border-right:medium none;mso-border-alt:solid black .5pt;mso-border-themecolor:text1;mso-yfti-tbllook:1184;mso-padding-alt:0cm 5.4pt 0cm 5.4pt;">
<tr style="mso-yfti-irow:0;mso-yfti-firstrow:yes;mso-yfti-lastrow:yes;">
<td style="border-bottom:black 1pt solid;border-left:black 1pt solid;padding-bottom:0cm;padding-left:5.4pt;width:477.3pt;padding-right:5.4pt;border-top:black 1pt solid;border-right:black 1pt solid;padding-top:0cm;mso-border-alt:solid black .5pt;mso-border-themecolor:text1;">
<p class="MsoNormal"><span style="font-family:'Courier New';color:#008000;font-size:10pt;mso-ansi-language:en-us;mso-no-proof:yes;">// <br />// Add a signing reference, the uri refernces to an element with the <br />// ID "test1" <br /></span><span style="font-family:'Courier New';color:#2b91af;font-size:10pt;mso-ansi-language:en-us;mso-no-proof:yes;">Reference</span><span style="font-family:'Courier New';font-size:10pt;mso-ansi-language:en-us;mso-no-proof:yes;"> reference = <span style="color:#0000ff;">new</span> <span style="color:#2b91af;">Reference</span>(); <br />reference.AddTransform(<span style="color:#0000ff;">new</span> <span style="color:#2b91af;">XmlDsigEnvelopedSignatureTransform</span>()); <br />reference.AddTransform(<span style="color:#0000ff;">new</span> <span style="color:#2b91af;">XmlDsigExcC14NTransform</span>()); <br />reference.Uri = <span style="color:#a31515;">"#test1"</span>; <br /></span><span style="font-family:'Courier New';font-size:10pt;mso-no-proof:yes;">signedXml.AddReference(reference); <br style="mso-special-character:line-break;" /><br style="mso-special-character:line-break;" /></span><span style="mso-ansi-language:en-us;">
<p> </p>
</span></p>
</td>
</tr>
</table>
<p class="MsoNormal"><span style="mso-ansi-language:en-us;"><br />This works in this case fine, because the SignedXml has only one implementation, if the Uri starts with ‘#’, the class searches in the document for an attribute with the name “Id” and the value of the Uri without the ‘#’ character. If you have an Xml which as a different Id attribute name or you want specified any other path string like XPath the Signed Xml does not work it throws the Exception with the message “Malformed reference element.<b style="mso-bidi-font-weight:normal;">” </b><span style="mso-spacerun:yes;"> </span><span style="mso-spacerun:yes;"> </span>
<p> </p>
</span></p>
<p class="MsoNormal"><span style="mso-ansi-language:en-us;">If you want to sign such XML documents than you must create a new class and inherit from SignedXml, in this class you must override the “GetIdElement” method. This method gets the XML document and the Uri Valuewithout the ‘#’ character. The Method must return the element which you want to sign.<span style="mso-spacerun:yes;"> </span>A very simple solution is:
<p> </p>
</span></p>
<table cellpadding="0" cellspacing="0" class="MsoTableGrid" style="border-bottom:medium none;border-left:medium none;border-collapse:collapse;border-top:medium none;border-right:medium none;mso-border-alt:solid black .5pt;mso-border-themecolor:text1;mso-yfti-tbllook:1184;mso-padding-alt:0cm 5.4pt 0cm 5.4pt;">
<tr style="mso-yfti-irow:0;mso-yfti-firstrow:yes;mso-yfti-lastrow:yes;">
<td style="border-bottom:black 1pt solid;border-left:black 1pt solid;padding-bottom:0cm;padding-left:5.4pt;width:477.3pt;padding-right:5.4pt;border-top:black 1pt solid;border-right:black 1pt solid;padding-top:0cm;mso-border-alt:solid black .5pt;mso-border-themecolor:text1;">
<p class="MsoNormal"><span style="font-family:'Courier New';color:#0000ff;font-size:10pt;mso-ansi-language:en-us;mso-no-proof:yes;">public</span><span style="font-family:'Courier New';font-size:10pt;mso-ansi-language:en-us;mso-no-proof:yes;"> <span style="color:#0000ff;">class</span> <span style="color:#2b91af;">MySignedXml</span> : <span style="color:#2b91af;">SignedXml <br /></span>{ <br /><span style="mso-spacerun:yes;"> </span><span style="color:#0000ff;">public</span> MySignedXml(<span style="color:#2b91af;">XmlDocument</span> document) : <span style="color:#0000ff;">base</span>(document) { } <br /><span style="mso-spacerun:yes;"> </span><span style="color:#0000ff;">public</span> <span style="color:#0000ff;">override</span> <span style="color:#2b91af;">XmlElement</span> GetIdElement( <br /><span style="mso-spacerun:yes;"> </span><span style="color:#2b91af;">XmlDocument</span> document, <span style="color:#0000ff;">string</span> idValue) <br /><span style="mso-spacerun:yes;"> </span>{ <br /><span style="mso-spacerun:yes;"> </span><span style="color:#0000ff;">return</span> (<span style="color:#2b91af;">XmlElement</span>) <br /><span style="mso-spacerun:yes;"> </span>document.SelectSingleNode(<span style="color:#a31515;">"//*[@MyId='"</span> + idValue + <span style="color:#a31515;">"']"</span>); <br /><span style="mso-spacerun:yes;"> </span></span><span style="font-family:'Courier New';font-size:10pt;mso-no-proof:yes;">} <br />}</span><span style="mso-ansi-language:en-us;">
<p> </p>
</span></p>
</td>
</tr>
</table>
<p><span style="font-family:'Calibri','sans-serif';font-size:11pt;mso-ansi-language:en-us;mso-ascii-theme-font:minor-latin;mso-fareast-font-family:calibri;mso-fareast-theme-font:minor-latin;mso-hansi-theme-font:minor-latin;mso-bidi-font-family:'Times New Roman';mso-bidi-theme-font:minor-bidi;mso-fareast-language:en-us;mso-bidi-language:ar-sa;"><br style="mso-special-character:line-break;" /><br style="mso-special-character:line-break;" /></span></p><div style="clear:both;"></div><img src="http://developers.de/aggbug.aspx?PostID=5345" width="1" height="1">rnebhuthhttp://developers.de/members/rnebhuth/default.aspxBusiness Data Catalog Configuration for WebService to use in the MOSS Enterprise Search./blogs/rolf_nebhuth/archive/2008/01/16/business-data-catalog-configuration-for-webservice-to-use-in-the-enterprise-search.aspx2008-01-16T08:25:36Z2008-01-16T08:25:36Z<p>The most examples for Business Data Catalog(BDC) used a database connection, this is an easy way to connect to a foreign system. In some cases a own Web Service has advantages, because the Web Service can prepare the data for the moss search, for example child entity data can be included in the main entity. </p> <p>The crawler of MOSS needs two operations for the indexing. </p> <blockquote> <p>The first method (called “Id Enumerator”) must return all IDs for the entities, which must be indexed. If the indexer should crawl incremental, it must also return the last modified date of each ID.</p> </blockquote> <blockquote> <p>The second method (called “Specific Finder”) becomes the ID and returns the data of the entity. The Entity may only contains simple type properties, and entities with complex type are not indexed.</p> </blockquote> <p>I create an example Customer Web Service and the service contains for the search the two methods (Example). The Web Service must use a BasicHttpBinding, because the BDC in MOSS does not use WCF to connect to the Web Service.</p> <p> </p> <p>To create a Business Data Catalog Definitions Microsoft publishes in the <a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=6D94E307-67D9-41AC-B2D6-0074D6286FA9&displaylang=en" target="_blank">MOSS SDK</a> the “Business Data Catalog Definition Editor”, which I use to create the definition file. </p> <p>The First Step is to create a new LOB (line-of-business) System in the Business Data Catalog Definition Editor, connect it to the Web Service and define the entity and all its methods.</p> <blockquote> <p>1. Add LOB System and connect to Web Service with the Web Service URL. <br /><a href="http://developers.de/blogs/rolf_nebhuth/WindowsLiveWriter/BusinessDataCatalogConfigurationforWebS_8494/image_2.png"><img style="border-top-width:0px;border-left-width:0px;border-bottom-width:0px;border-right-width:0px;" height="237" alt="image" src="http://developers.de/blogs/rolf_nebhuth/WindowsLiveWriter/BusinessDataCatalogConfigurationforWebS_8494/image_thumb.png" width="356" border="0" /></a> </p> </blockquote> <blockquote> <p>2. Drag and Drop all Methods for an Entity to the “Design Surface” <br /><a href="http://developers.de/blogs/rolf_nebhuth/WindowsLiveWriter/BusinessDataCatalogConfigurationforWebS_8494/image_4.png"><img style="border-top-width:0px;border-left-width:0px;border-bottom-width:0px;border-right-width:0px;" height="240" alt="image" src="http://developers.de/blogs/rolf_nebhuth/WindowsLiveWriter/BusinessDataCatalogConfigurationforWebS_8494/image_thumb_1.png" width="360" border="0" /></a> </p> </blockquote> <blockquote> <p>3. Press “OK” and define a name for the LOB System. The Editor creates an BDC Entity and in it the methods with all the Web Service Parameters (Arguments /Return Value)</p> </blockquote> <blockquote> <p>4. Rename the Entity (“Customer”) and create the Identifier (“Id”) <br /><a href="http://developers.de/blogs/rolf_nebhuth/WindowsLiveWriter/BusinessDataCatalogConfigurationforWebS_8494/image_6.png"><img style="border-top-width:0px;border-left-width:0px;border-bottom-width:0px;border-right-width:0px;" height="156" alt="image" src="http://developers.de/blogs/rolf_nebhuth/WindowsLiveWriter/BusinessDataCatalogConfigurationforWebS_8494/image_thumb_2.png" width="175" border="0" /></a> </p> </blockquote> <p>The next step is to create the “Id Enumerator”, which returns all Ids for the customer entities</p> <blockquote> <p>1. Define the Identifier Property with “Id(Customer)” in the Return parameter, to show the crawler which is the Id in the result entity. <br /><a href="http://developers.de/blogs/rolf_nebhuth/WindowsLiveWriter/BusinessDataCatalogConfigurationforWebS_8494/image_8.png"><img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px;" height="121" alt="image" src="http://developers.de/blogs/rolf_nebhuth/WindowsLiveWriter/BusinessDataCatalogConfigurationforWebS_8494/image_thumb_3.png" width="189" border="0" /></a> <a href="http://developers.de/blogs/rolf_nebhuth/WindowsLiveWriter/BusinessDataCatalogConfigurationforWebS_8494/image_10.png"><img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px;" height="139" alt="image" src="http://developers.de/blogs/rolf_nebhuth/WindowsLiveWriter/BusinessDataCatalogConfigurationforWebS_8494/image_thumb_4.png" width="208" border="0" /></a> </p> </blockquote> <blockquote> <p>2. Create the Instance with the name “GetCustomerIds” as an “Id Enumerator” and the Return type must be the “Ids” because the “Id Enumerator” must return a collection. <br /><a href="http://developers.de/blogs/rolf_nebhuth/WindowsLiveWriter/BusinessDataCatalogConfigurationforWebS_8494/image_12.png"><img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px;" height="238" alt="image" src="http://developers.de/blogs/rolf_nebhuth/WindowsLiveWriter/BusinessDataCatalogConfigurationforWebS_8494/image_thumb_5.png" width="244" border="0" /></a> </p> </blockquote> <blockquote> <p>3. Execute the Method Instance “GetCustomerIds” to test the configuration. The result must be a list of Ids. <br /><a href="http://developers.de/blogs/rolf_nebhuth/WindowsLiveWriter/BusinessDataCatalogConfigurationforWebS_8494/image_14.png"><img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px;" height="220" alt="image" src="http://developers.de/blogs/rolf_nebhuth/WindowsLiveWriter/BusinessDataCatalogConfigurationforWebS_8494/image_thumb_6.png" width="317" border="0" /></a> </p> </blockquote> <p>The next step is to create the “Specific Finder”, which returns one customer entity.</p> <blockquote> <p>1. Define the Identifier Properties with “Id(Customer)” in the operation argument Id and in the Return parameter. <br /><a href="http://developers.de/blogs/rolf_nebhuth/WindowsLiveWriter/BusinessDataCatalogConfigurationforWebS_8494/image_16.png"><img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px;" height="216" alt="image" src="http://developers.de/blogs/rolf_nebhuth/WindowsLiveWriter/BusinessDataCatalogConfigurationforWebS_8494/image_thumb_7.png" width="244" border="0" /></a> </p> </blockquote> <blockquote> <p>2. Create the Instance for the “GetCustomerById” as a “Specific Finder” and the Return type must be “Return”, which contains one Customer with all the entity properties, which must be indexed. <br /><a href="http://developers.de/blogs/rolf_nebhuth/WindowsLiveWriter/BusinessDataCatalogConfigurationforWebS_8494/image_18.png"><img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px;" height="283" alt="image" src="http://developers.de/blogs/rolf_nebhuth/WindowsLiveWriter/BusinessDataCatalogConfigurationforWebS_8494/image_thumb_8.png" width="290" border="0" /></a> </p> </blockquote> <blockquote> <p>3. Execute the Method Instance “GetCustomerById” to test the configuration. The argument should be an existing id and then the result must the data of the entity. <br /><a href="http://developers.de/blogs/rolf_nebhuth/WindowsLiveWriter/BusinessDataCatalogConfigurationforWebS_8494/image_20.png"><img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px;" height="259" alt="image" src="http://developers.de/blogs/rolf_nebhuth/WindowsLiveWriter/BusinessDataCatalogConfigurationforWebS_8494/image_thumb_9.png" width="372" border="0" /></a> </p> </blockquote> <p>Every BDC Entity should contain the “Title” property, which is used to define which Entity property is used as Title in the search result. If no title is defined, the title is the URL of the default action.</p> <blockquote> <p>Open the Properties for the Entity (“Customer”) and add a property. The Property name must be “Title” and the property value must be the name of the TypeDescriptor in the Return Parameter of the “Specific Finder” method, which contains the title value. <br /><a href="http://developers.de/blogs/rolf_nebhuth/WindowsLiveWriter/BusinessDataCatalogConfigurationforWebS_8494/image_24.png"><img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px;" height="211" alt="image" src="http://developers.de/blogs/rolf_nebhuth/WindowsLiveWriter/BusinessDataCatalogConfigurationforWebS_8494/image_thumb_11.png" width="289" border="0" /></a> </p> </blockquote> <p>If the crawler should support incremental crawling, and the Web Service returns a last modified date, the BDC Entity must contain the “__BdcLastModifiedTimestamp” property, which defines the name of his last modified property.</p> <blockquote> <p>Open the Properties for the Entity (“Customer”) and add a property. The Property name must be “__BdcLastModifiedTimestamp” and the property value must be the name of the TypeDescriptor in the Return Parameter of the “Specific Finder” and “Id Enumerator” method, which contains the last modified date. <br /><a href="http://developers.de/blogs/rolf_nebhuth/WindowsLiveWriter/BusinessDataCatalogConfigurationforWebS_8494/image_26.png"><img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px;" height="218" alt="image" src="http://developers.de/blogs/rolf_nebhuth/WindowsLiveWriter/BusinessDataCatalogConfigurationforWebS_8494/image_thumb_12.png" width="299" border="0" /></a></p></blockquote><div style="clear:both;"></div><img src="http://developers.de/aggbug.aspx?PostID=1749" width="1" height="1">rnebhuthhttp://developers.de/members/rnebhuth/default.aspxVerify Signed Xml Documents/blogs/rolf_nebhuth/archive/2007/03/05/Verify-Signed-Xml-Documents.aspx2007-03-05T22:14:00Z2007-03-05T22:14:00Z<p class="MsoNormal" style="margin:0cm 0cm 0pt;"><font face="Times New Roman" size="3">To check the signature of a signed Xml Document, there is a class <em>SigendXml</em> in the .NET Framework, which can validate and sign XML Documents. </font></p><p class="MsoNormal" style="margin:0cm 0cm 0pt;"><font face="Times New Roman" size="3"> </font></p><p class="MsoNormal" style="margin:0cm 0cm 0pt;"><font face="Times New Roman" size="3"> </font></p><p class="MsoNormal" style="margin:0cm 0cm 0pt;"><font face="Times New Roman" size="3">This Example shows a signed Xml Document. The Document is in this form not valid because the pretty print, changes the whitespace and so the hash is not the same. So be sure not change anything in a signed document.</font></p><div style="padding-right:4pt;padding-left:4pt;background:#ffcc00;padding-bottom:1pt;padding-top:1pt;border:windowtext 1pt solid;"><p class="MsoNormal" style="background:#ffcc00;margin:0cm 0cm 0pt;border:medium none;padding:0cm;"><span style="font-size:10pt;color:blue;font-family:'Courier New';"><</span><span style="font-size:10pt;color:#a31515;font-family:'Courier New';">test</span><span style="font-size:10pt;color:blue;font-family:'Courier New';">></span></p><p class="MsoNormal" style="background:#ffcc00;margin:0cm 0cm 0pt;border:medium none;padding:0cm;"><span style="font-size:10pt;color:blue;font-family:'Courier New';"><span> </span><</span><span style="font-size:10pt;color:#a31515;font-family:'Courier New';">data</span><span style="font-size:10pt;color:blue;font-family:'Courier New';"> </span><span style="font-size:10pt;color:red;font-family:'Courier New';">name</span><span style="font-size:10pt;color:blue;font-family:'Courier New';">=</span><span style="font-size:10pt;font-family:'Courier New';">"<span style="color:blue;">test1</span>"<span style="color:blue;">></span>value1<span style="color:blue;"></</span><span style="color:#a31515;">data</span><span style="color:blue;">></span></span></p><p class="MsoNormal" style="background:#ffcc00;margin:0cm 0cm 0pt;border:medium none;padding:0cm;"><span style="font-size:10pt;color:blue;font-family:'Courier New';"><span> </span><</span><span style="font-size:10pt;color:#a31515;font-family:'Courier New';">data</span><span style="font-size:10pt;color:blue;font-family:'Courier New';"> </span><span style="font-size:10pt;color:red;font-family:'Courier New';">name</span><span style="font-size:10pt;color:blue;font-family:'Courier New';">=</span><span style="font-size:10pt;font-family:'Courier New';">"<span style="color:blue;">test1</span>"<span style="color:blue;">></span>value1<span style="color:blue;"></</span><span style="color:#a31515;">data</span><span style="color:blue;">></span></span></p><p class="MsoNormal" style="background:#ffcc00;margin:0cm 0cm 0pt;border:medium none;padding:0cm;"><span style="font-size:10pt;color:blue;font-family:'Courier New';"><span> </span><</span><span style="font-size:10pt;color:#a31515;font-family:'Courier New';">data</span><span style="font-size:10pt;color:blue;font-family:'Courier New';"> </span><span style="font-size:10pt;color:red;font-family:'Courier New';">name</span><span style="font-size:10pt;color:blue;font-family:'Courier New';">=</span><span style="font-size:10pt;font-family:'Courier New';">"<span style="color:blue;">test1</span>"<span style="color:blue;">></span>value1<span style="color:blue;"></</span><span style="color:#a31515;">data</span><span style="color:blue;">></span></span></p><p class="MsoNormal" style="background:#ffcc00;margin:0cm 0cm 0pt;border:medium none;padding:0cm;"><span style="font-size:10pt;color:blue;font-family:'Courier New';"><span> </span><</span><span style="font-size:10pt;color:#a31515;font-family:'Courier New';">Signature</span><span style="font-size:10pt;color:blue;font-family:'Courier New';"> </span><span style="font-size:10pt;color:red;font-family:'Courier New';">xmlns</span><span style="font-size:10pt;color:blue;font-family:'Courier New';">=</span><span style="font-size:10pt;font-family:'Courier New';">"<span style="color:blue;">http://www.w3.org/2000/09/xmldsig#</span>"<span style="color:blue;">></span></span></p><p class="MsoNormal" style="background:#ffcc00;margin:0cm 0cm 0pt;border:medium none;padding:0cm;"><span style="font-size:10pt;color:blue;font-family:'Courier New';"><span> </span><</span><span style="font-size:10pt;color:#a31515;font-family:'Courier New';">SignedInfo</span><span style="font-size:10pt;color:blue;font-family:'Courier New';">></span></p><p class="MsoNormal" style="background:#ffcc00;margin:0cm 0cm 0pt;border:medium none;padding:0cm;"><span style="font-size:10pt;color:blue;font-family:'Courier New';"><span> </span><</span><span style="font-size:10pt;color:#a31515;font-family:'Courier New';">CanonicalizationMethod</span><span style="font-size:10pt;color:blue;font-family:'Courier New';"> </span><span style="font-size:10pt;color:red;font-family:'Courier New';">Algorithm</span><span style="font-size:10pt;color:blue;font-family:'Courier New';">=</span><span style="font-size:10pt;font-family:'Courier New';">"<span style="color:blue;">http://www.w3.org/TR/2001/REC-xml-c14n-20010315</span>"<span style="color:blue;"> /></span></span></p><p class="MsoNormal" style="background:#ffcc00;margin:0cm 0cm 0pt;border:medium none;padding:0cm;"><span style="font-size:10pt;color:blue;font-family:'Courier New';"><span> </span><</span><span style="font-size:10pt;color:#a31515;font-family:'Courier New';">SignatureMethod</span><span style="font-size:10pt;color:blue;font-family:'Courier New';"> </span><span style="font-size:10pt;color:red;font-family:'Courier New';">Algorithm</span><span style="font-size:10pt;color:blue;font-family:'Courier New';">=</span><span style="font-size:10pt;font-family:'Courier New';">"<span style="color:blue;">http://www.w3.org/2000/09/xmldsig#rsa-sha1</span>"<span style="color:blue;"> /></span></span></p><p class="MsoNormal" style="background:#ffcc00;margin:0cm 0cm 0pt;border:medium none;padding:0cm;"><span style="font-size:10pt;color:blue;font-family:'Courier New';"><span> </span><</span><span style="font-size:10pt;color:#a31515;font-family:'Courier New';">Reference</span><span style="font-size:10pt;color:blue;font-family:'Courier New';"> </span><span style="font-size:10pt;color:red;font-family:'Courier New';">URI</span><span style="font-size:10pt;color:blue;font-family:'Courier New';">=</span><span style="font-size:10pt;font-family:'Courier New';">""<span style="color:blue;">></span></span></p><p class="MsoNormal" style="background:#ffcc00;margin:0cm 0cm 0pt;border:medium none;padding:0cm;"><span style="font-size:10pt;color:blue;font-family:'Courier New';"><span> </span><</span><span style="font-size:10pt;color:#a31515;font-family:'Courier New';">Transforms</span><span style="font-size:10pt;color:blue;font-family:'Courier New';">></span></p><p class="MsoNormal" style="background:#ffcc00;margin:0cm 0cm 0pt;border:medium none;padding:0cm;"><span style="font-size:10pt;color:blue;font-family:'Courier New';"><span> </span><</span><span style="font-size:10pt;color:#a31515;font-family:'Courier New';">Transform</span><span style="font-size:10pt;color:blue;font-family:'Courier New';"> </span><span style="font-size:10pt;color:red;font-family:'Courier New';">Algorithm</span><span style="font-size:10pt;color:blue;font-family:'Courier New';">=</span><span style="font-size:10pt;font-family:'Courier New';">"<span style="color:blue;">http://www.w3.org/2000/09/xmldsig#enveloped-signature</span>"<span style="color:blue;"> /></span></span></p><p class="MsoNormal" style="background:#ffcc00;margin:0cm 0cm 0pt;border:medium none;padding:0cm;"><span style="font-size:10pt;color:blue;font-family:'Courier New';"><span> </span></</span><span style="font-size:10pt;color:#a31515;font-family:'Courier New';">Transforms</span><span style="font-size:10pt;color:blue;font-family:'Courier New';">></span></p><p class="MsoNormal" style="background:#ffcc00;margin:0cm 0cm 0pt;border:medium none;padding:0cm;"><span style="font-size:10pt;color:blue;font-family:'Courier New';"><span> </span><</span><span style="font-size:10pt;color:#a31515;font-family:'Courier New';">DigestMethod</span><span style="font-size:10pt;color:blue;font-family:'Courier New';"> </span><span style="font-size:10pt;color:red;font-family:'Courier New';">Algorithm</span><span style="font-size:10pt;color:blue;font-family:'Courier New';">=</span><span style="font-size:10pt;font-family:'Courier New';">"<span style="color:blue;">http://www.w3.org/2000/09/xmldsig#sha1</span>"<span style="color:blue;"> /></span></span></p><p class="MsoNormal" style="background:#ffcc00;margin:0cm 0cm 0pt;border:medium none;padding:0cm;"><span style="font-size:10pt;color:blue;font-family:'Courier New';"><span> </span><</span><span style="font-size:10pt;color:#a31515;font-family:'Courier New';">DigestValue</span><span style="font-size:10pt;color:blue;font-family:'Courier New';">></span><span style="font-size:10pt;font-family:'Courier New';">PDdixiJvxakVD6MvIAbR5SysLh0=<span style="color:blue;"></</span><span style="color:#a31515;">DigestValue</span><span style="color:blue;">></span></span></p><p class="MsoNormal" style="background:#ffcc00;margin:0cm 0cm 0pt;border:medium none;padding:0cm;"><span style="font-size:10pt;color:blue;font-family:'Courier New';"><span> </span></</span><span style="font-size:10pt;color:#a31515;font-family:'Courier New';">Reference</span><span style="font-size:10pt;color:blue;font-family:'Courier New';">></span></p><p class="MsoNormal" style="background:#ffcc00;margin:0cm 0cm 0pt;border:medium none;padding:0cm;"><span style="font-size:10pt;color:blue;font-family:'Courier New';"><span> </span></</span><span style="font-size:10pt;color:#a31515;font-family:'Courier New';">SignedInfo</span><span style="font-size:10pt;color:blue;font-family:'Courier New';">></span></p><p class="MsoNormal" style="background:#ffcc00;margin:0cm 0cm 0pt;border:medium none;padding:0cm;"><span style="font-size:10pt;color:blue;font-family:'Courier New';"><span> </span><</span><span style="font-size:10pt;color:#a31515;font-family:'Courier New';">SignatureValue</span><span style="font-size:10pt;color:blue;font-family:'Courier New';">></span><span style="font-size:10pt;font-family:'Courier New';">dqwuYsXEsaV5k4GL41B230AuXV+hCroCqCtyCRt1u5O97dwZgUbDY3Ns34Bbw+w+czxgUk4rF6m5vhflbeErb7zSyn8qwXi3QnE1g96w6sQzYc7I9qTgqRw8DuufDYfhn6/1D+FflYXYOfj3dglEpTXbcPhV76GmsPL4g+CLPKo=<span style="color:blue;"></</span><span style="color:#a31515;">SignatureValue</span><span style="color:blue;">></span></span></p><p class="MsoNormal" style="background:#ffcc00;margin:0cm 0cm 0pt;border:medium none;padding:0cm;"><span style="font-size:10pt;color:blue;font-family:'Courier New';"><span> </span><</span><span style="font-size:10pt;color:#a31515;font-family:'Courier New';">KeyInfo</span><span style="font-size:10pt;color:blue;font-family:'Courier New';">></span></p><p class="MsoNormal" style="background:#ffcc00;margin:0cm 0cm 0pt;border:medium none;padding:0cm;"><span style="font-size:10pt;color:blue;font-family:'Courier New';"><span> </span><</span><span style="font-size:10pt;color:#a31515;font-family:'Courier New';">KeyValue</span><span style="font-size:10pt;color:blue;font-family:'Courier New';">></span></p><p class="MsoNormal" style="background:#ffcc00;margin:0cm 0cm 0pt;border:medium none;padding:0cm;"><span style="font-size:10pt;color:blue;font-family:'Courier New';"><span> </span><</span><span style="font-size:10pt;color:#a31515;font-family:'Courier New';">RSAKeyValue</span><span style="font-size:10pt;color:blue;font-family:'Courier New';">></span></p><p class="MsoNormal" style="background:#ffcc00;margin:0cm 0cm 0pt;border:medium none;padding:0cm;"><span style="font-size:10pt;color:blue;font-family:'Courier New';"><span> </span><</span><span style="font-size:10pt;color:#a31515;font-family:'Courier New';">Modulus</span><span style="font-size:10pt;color:blue;font-family:'Courier New';">></span><span style="font-size:10pt;font-family:'Courier New';">4VGrIlDzCmgbIL2dZiSxP+bqgu3CL3qgwhfAU01FziPOyJMtk76+9hPDefN8qdifKjlRXHkGl4IbPUZQsdHqtE7M8HtkM9Pb5xogpma8mWcWhu3CIO9YJr8EEj2XmNa98XI2Nr0PAr7YLtneRktVWq1BKdttckcq2gtUp8amXas=<span style="color:blue;"></</span><span style="color:#a31515;">Modulus</span><span style="color:blue;">></span></span></p><p class="MsoNormal" style="background:#ffcc00;margin:0cm 0cm 0pt;border:medium none;padding:0cm;"><span style="font-size:10pt;color:blue;font-family:'Courier New';"><span> </span><</span><span style="font-size:10pt;color:#a31515;font-family:'Courier New';">Exponent</span><span style="font-size:10pt;color:blue;font-family:'Courier New';">></span><span style="font-size:10pt;font-family:'Courier New';">AQAB<span style="color:blue;"></</span><span style="color:#a31515;">Exponent</span><span style="color:blue;">></span></span></p><p class="MsoNormal" style="background:#ffcc00;margin:0cm 0cm 0pt;border:medium none;padding:0cm;"><span style="font-size:10pt;color:blue;font-family:'Courier New';"><span> </span></</span><span style="font-size:10pt;color:#a31515;font-family:'Courier New';">RSAKeyValue</span><span style="font-size:10pt;color:blue;font-family:'Courier New';">></span></p><p class="MsoNormal" style="background:#ffcc00;margin:0cm 0cm 0pt;border:medium none;padding:0cm;"><span style="font-size:10pt;color:blue;font-family:'Courier New';"><span> </span></</span><span style="font-size:10pt;color:#a31515;font-family:'Courier New';">KeyValue</span><span style="font-size:10pt;color:blue;font-family:'Courier New';">></span></p><p class="MsoNormal" style="background:#ffcc00;margin:0cm 0cm 0pt;border:medium none;padding:0cm;"><span style="font-size:10pt;color:blue;font-family:'Courier New';"><span> </span></</span><span style="font-size:10pt;color:#a31515;font-family:'Courier New';">KeyInfo</span><span style="font-size:10pt;color:blue;font-family:'Courier New';">></span></p><p class="MsoNormal" style="background:#ffcc00;margin:0cm 0cm 0pt;border:medium none;padding:0cm;"><span style="font-size:10pt;color:blue;font-family:'Courier New';"><span> </span></</span><span style="font-size:10pt;color:#a31515;font-family:'Courier New';">Signature</span><span style="font-size:10pt;color:blue;font-family:'Courier New';">></span></p><p class="MsoNormal" style="background:#ffcc00;margin:0cm 0cm 0pt;border:medium none;padding:0cm;"><span style="font-size:10pt;color:blue;font-family:'Courier New';"></</span><span style="font-size:10pt;color:#a31515;font-family:'Courier New';">test</span><span style="font-size:10pt;color:blue;font-family:'Courier New';">></span></p></div><p class="MsoNormal" style="margin:0cm 0cm 0pt;"><font face="Times New Roman" size="3"> </font></p><p class="MsoNormal" style="margin:0cm 0cm 0pt;"><font face="Times New Roman" size="3"> </font></p><p class="MsoNormal" style="margin:0cm 0cm 0pt;"><font face="Times New Roman" size="3"> </font></p><p class="MsoNormal" style="margin:0cm 0cm 0pt;"><font face="Times New Roman" size="3">1. This Example shows how to validate a signed Xml Document. </font></p><div style="padding-right:4pt;padding-left:4pt;background:#ff9900;padding-bottom:1pt;padding-top:1pt;border:windowtext 1pt solid;"><p class="MsoNormal" style="background:#ff9900;margin:0cm 0cm 0pt;border:medium none;padding:0cm;"><span style="font-size:10pt;color:green;font-family:'Courier New';">// Load the Signed Xml Document with all Whitespace.</span></p><p class="MsoNormal" style="background:#ff9900;margin:0cm 0cm 0pt;border:medium none;padding:0cm;"><span style="font-size:10pt;color:#2b91af;font-family:'Courier New';">XmlDocument</span><span style="font-size:10pt;font-family:'Courier New';"> xDoc = <span style="color:blue;">new</span> <span style="color:#2b91af;">XmlDocument</span>();</span></p><p class="MsoNormal" style="background:#ff9900;margin:0cm 0cm 0pt;border:medium none;padding:0cm;"><span style="font-size:10pt;font-family:'Courier New';">xDoc.PreserveWhitespace = <span style="color:blue;">true</span>;</span></p><p class="MsoNormal" style="background:#ff9900;margin:0cm 0cm 0pt;border:medium none;padding:0cm;"><span style="font-size:10pt;font-family:'Courier New';">xDoc.Load(fileName);</span></p><p class="MsoNormal" style="background:#ff9900;margin:0cm 0cm 0pt;border:medium none;padding:0cm;"><span style="font-size:10pt;font-family:'Courier New';"> </span></p><p class="MsoNormal" style="background:#ff9900;margin:0cm 0cm 0pt;border:medium none;padding:0cm;"><span style="font-size:10pt;color:green;font-family:'Courier New';">// Create the SignedXml object.</span></p><p class="MsoNormal" style="background:#ff9900;margin:0cm 0cm 0pt;border:medium none;padding:0cm;"><span style="font-size:10pt;color:#2b91af;font-family:'Courier New';">SignedXml</span><span style="font-size:10pt;font-family:'Courier New';"> signedXml = <span style="color:blue;">new</span> <span style="color:#2b91af;">SignedXml</span>(xDoc.DocumentElement);</span></p><p class="MsoNormal" style="background:#ff9900;margin:0cm 0cm 0pt;border:medium none;padding:0cm;"><span style="font-size:10pt;font-family:'Courier New';"> </span></p><p class="MsoNormal" style="background:#ff9900;margin:0cm 0cm 0pt;border:medium none;padding:0cm;"><span style="font-size:10pt;color:green;font-family:'Courier New';">// Set the signiture and the key. which must be checked.</span></p><p class="MsoNormal" style="background:#ff9900;margin:0cm 0cm 0pt;border:medium none;padding:0cm;"><span style="font-size:10pt;font-family:'Courier New';">signedXml.LoadXml((<span style="color:#2b91af;">XmlElement</span>)xDoc.DocumentElement.SelectSingleNode(<span style="color:#a31515;">"*[local-name(.) = 'Signature' and namespace-uri(.) = 'http://www.w3.org/2000/09/xmldsig#']"</span>));</span></p><p class="MsoNormal" style="background:#ff9900;margin:0cm 0cm 0pt;border:medium none;padding:0cm;"><span style="font-size:10pt;font-family:'Courier New';"> </span></p><p class="MsoNormal" style="background:#ff9900;margin:0cm 0cm 0pt;border:medium none;padding:0cm;"><span style="font-size:10pt;color:green;font-family:'Courier New';">// Check the signature</span></p><p class="MsoNormal" style="background:#ff9900;margin:0cm 0cm 0pt;border:medium none;padding:0cm;"><span style="font-size:10pt;color:blue;font-family:'Courier New';">bool</span><span style="font-size:10pt;font-family:'Courier New';"> valid = signedXml.CheckSignature();</span></p></div><p class="MsoNormal" style="margin:0cm 0cm 0pt;"><font face="Times New Roman" size="3">The <em>PreserveWhitespace</em> Option is necessary because all white spaces are also a part of the hash which was signed.</font></p><p class="MsoNormal" style="margin:0cm 0cm 0pt;"><strong><font face="Times New Roman" size="3"> </font></strong></p><p class="MsoNormal" style="margin:0cm 0cm 0pt;"><font face="Times New Roman" size="3"> </font></p><p class="MsoNormal" style="margin:0cm 0cm 0pt;"><font face="Times New Roman" size="3">2. This Example shows how to check an Xml Document with a specified X509 Certificate.</font></p><div style="padding-right:4pt;padding-left:4pt;background:#ff9900;padding-bottom:1pt;padding-top:1pt;border:windowtext 1pt solid;"><p class="MsoNormal" style="background:#ff9900;margin:0cm 0cm 0pt;border:medium none;padding:0cm;"><span style="font-size:10pt;color:green;font-family:'Courier New';">// Load the Signed Xml Document with all Whitespace.</span></p><p class="MsoNormal" style="background:#ff9900;margin:0cm 0cm 0pt;border:medium none;padding:0cm;"><span style="font-size:10pt;color:#2b91af;font-family:'Courier New';">XmlDocument</span><span style="font-size:10pt;font-family:'Courier New';"> xDoc = <span style="color:blue;">new</span> <span style="color:#2b91af;">XmlDocument</span>();</span></p><p class="MsoNormal" style="background:#ff9900;margin:0cm 0cm 0pt;border:medium none;padding:0cm;"><span style="font-size:10pt;font-family:'Courier New';">xDoc.PreserveWhitespace = <span style="color:blue;">true</span>;</span></p><p class="MsoNormal" style="background:#ff9900;margin:0cm 0cm 0pt;border:medium none;padding:0cm;"><span style="font-size:10pt;font-family:'Courier New';">xDoc.Load(fileName);</span></p><p class="MsoNormal" style="background:#ff9900;margin:0cm 0cm 0pt;border:medium none;padding:0cm;"><span style="font-size:10pt;font-family:'Courier New';"> </span></p><p class="MsoNormal" style="background:#ff9900;margin:0cm 0cm 0pt;border:medium none;padding:0cm;"><span style="font-size:10pt;color:green;font-family:'Courier New';">// Create the SignedXml object.</span></p><p class="MsoNormal" style="background:#ff9900;margin:0cm 0cm 0pt;border:medium none;padding:0cm;"><span style="font-size:10pt;color:#2b91af;font-family:'Courier New';">SignedXml</span><span style="font-size:10pt;font-family:'Courier New';"> signedXml = <span style="color:blue;">new</span> <span style="color:#2b91af;">SignedXml</span>(xDoc.DocumentElement);</span></p><p class="MsoNormal" style="background:#ff9900;margin:0cm 0cm 0pt;border:medium none;padding:0cm;"><span style="font-size:10pt;font-family:'Courier New';"> </span></p><p class="MsoNormal" style="background:#ff9900;margin:0cm 0cm 0pt;border:medium none;padding:0cm;"><span style="font-size:10pt;color:green;font-family:'Courier New';">// Gets The Key, which must the document must be signed.</span></p><p class="MsoNormal" style="background:#ff9900;margin:0cm 0cm 0pt;border:medium none;padding:0cm;"><span style="font-size:10pt;color:#2b91af;font-family:'Courier New';">KeyInfo</span><span style="font-size:10pt;font-family:'Courier New';"> info1 = <span style="color:blue;">new</span> <span style="color:#2b91af;">KeyInfo</span>();</span></p><p class="MsoNormal" style="background:#ff9900;margin:0cm 0cm 0pt;border:medium none;padding:0cm;"><span style="font-size:10pt;color:#2b91af;font-family:'Courier New';">KeyInfoX509Data</span><span style="font-size:10pt;font-family:'Courier New';"> data1 = <span style="color:blue;">new</span> <span style="color:#2b91af;">KeyInfoX509Data</span>(refCertifcate);</span></p><p class="MsoNormal" style="background:#ff9900;margin:0cm 0cm 0pt;border:medium none;padding:0cm;"><span style="font-size:10pt;font-family:'Courier New';">info1.AddClause(data1);</span></p><p class="MsoNormal" style="background:#ff9900;margin:0cm 0cm 0pt;border:medium none;padding:0cm;"><span style="font-size:10pt;font-family:'Courier New';"> </span></p><p class="MsoNormal" style="background:#ff9900;margin:0cm 0cm 0pt;border:medium none;padding:0cm;"><span style="font-size:10pt;color:green;font-family:'Courier New';">// Set the signiture and the key. which must be checked.</span></p><p class="MsoNormal" style="background:#ff9900;margin:0cm 0cm 0pt;border:medium none;padding:0cm;"><span style="font-size:10pt;font-family:'Courier New';">signedXml.LoadXml((<span style="color:#2b91af;">XmlElement</span>)xDoc.DocumentElement.SelectSingleNode(<span style="color:#a31515;">"*[local-name(.) = 'Signature' and namespace-uri(.) = 'http://www.w3.org/2000/09/xmldsig#']"</span>));</span></p><p class="MsoNormal" style="background:#ff9900;margin:0cm 0cm 0pt;border:medium none;padding:0cm;"><span style="font-size:10pt;font-family:'Courier New';">signedXml.KeyInfo = info1;</span></p><p class="MsoNormal" style="background:#ff9900;margin:0cm 0cm 0pt;border:medium none;padding:0cm;"><span style="font-size:10pt;font-family:'Courier New';">signedXml.SigningKey = refCert.PublicKey.Key;</span></p><p class="MsoNormal" style="background:#ff9900;margin:0cm 0cm 0pt;border:medium none;padding:0cm;"><span style="font-size:10pt;font-family:'Courier New';"> </span></p><p class="MsoNormal" style="background:#ff9900;margin:0cm 0cm 0pt;border:medium none;padding:0cm;"><span style="font-size:10pt;color:green;font-family:'Courier New';">// Check the signature</span></p><p class="MsoNormal" style="background:#ff9900;margin:0cm 0cm 0pt;border:medium none;padding:0cm;"><span style="font-size:10pt;color:blue;font-family:'Courier New';">bool</span><span style="font-size:10pt;font-family:'Courier New';"> valid = signedXml.CheckSignature();</span></p></div><p class="MsoNormal" style="margin:0cm 0cm 0pt;"><span style="font-size:10pt;font-family:'Courier New';"> </span></p><p class="MsoNormal" style="margin:0cm 0cm 0pt;"><font face="Times New Roman" size="3"> </font></p><p class="MsoNormal" style="margin:0cm 0cm 0pt;"><font size="3"><font face="Times New Roman"><span> </span>3. If the Signed Document is a part of another document (e.g. a Soap Message), and the reference Uri is empty. The Signed Part must be first imported in a new document, before it can be added to the <em>SigendXml.</em><span style="font-size:10pt;color:green;font-family:'Courier New';"></span></font></font></p><div style="padding-right:4pt;padding-left:4pt;background:#ff9900;padding-bottom:1pt;padding-top:1pt;border:windowtext 1pt solid;"><p class="MsoNormal" style="background:#ff9900;margin:0cm 0cm 0pt;border:medium none;padding:0cm;"><span style="font-size:10pt;color:green;font-family:'Courier New';">// Create a new XmlDocument with only the signed part</span></p><p class="MsoNormal" style="background:#ff9900;margin:0cm 0cm 0pt;border:medium none;padding:0cm;"><span style="font-size:10pt;font-family:'Courier New';">xDoc = <span style="color:blue;">new</span> <span style="color:#2b91af;">XmlDocument</span>();</span></p><p class="MsoNormal" style="background:#ff9900;margin:0cm 0cm 0pt;border:medium none;padding:0cm;"><span style="font-size:10pt;color:#2b91af;font-family:'Courier New';">XmlNode</span><span style="font-size:10pt;font-family:'Courier New';"> copyNode = xDoc.ImportNode(xmlElement, <span style="color:blue;">true</span>);</span></p><p class="MsoNormal" style="background:#ff9900;margin:0cm 0cm 0pt;border:medium none;padding:0cm;"><span style="font-size:10pt;font-family:'Courier New';">xDoc.AppendChild(copyNode);</span></p></div><p class="MsoNormal" style="margin:0cm 0cm 0pt;"><strong><font face="Times New Roman" size="3"> </font></strong></p><p class="MsoNormal" style="margin:0cm 0cm 0pt;"><strong><font face="Times New Roman" size="3"> </font></strong></p><p class="MsoNormal" style="margin:0cm 0cm 0pt;"><strong><font face="Times New Roman" size="3"> </font></strong></p><p class="MsoNormal" style="margin:0cm 0cm 0pt;"><font face="Times New Roman" size="3">References:</font></p><p class="MsoNormal" style="margin:0cm 0cm 0pt;"><a href="http://www.w3.org/TR/2002/REC-xmldsig-core-20020212/Overview.html" target="_blank"><font color="#800080" face="Times New Roman" size="3">XML-Signature Standard</font></a></p><div style="clear:both;"></div><img src="http://developers.de/aggbug.aspx?PostID=1211" width="1" height="1">rnebhuthhttp://developers.de/members/rnebhuth/default.aspxRegister Url for none Admin Service User/blogs/rolf_nebhuth/archive/2006/08/02/902.aspx2006-08-02T07:36:00Z2006-08-02T07:36:00Z<P class=MsoNormal> </P>
<P class=MsoNormal>To use HTTP.SYS for none administrator users, these must have the right this to do. The rights must be granted with the <I>httpcfg</I> tool (Support Tools for XP/2003). The tool must have two parameters for adding an urlacl</P>
<P class=MsoNormal><o:p> </o:p></P>
<P class=MsoNormal>The Parameter –u specified the listen URI. It can be http or an https Scheme the “+” for the hostname means all IP addresses.</P>
<P class=MsoNormal><o:p> </o:p></P>
<P class=MsoNormal>The Parameter –a specified in <SPAN>DACL (Part of SDDL) </SPAN>the rights of a specified URI</P>
<P class=MsoNormal><o:p> </o:p></P>
<P class=MsoNormal><B>DACL<o:p></o:p></B></P>
<P class=MsoNormal>The DACL starts with a “D:” and then in parenthesis 6 tokens which defines one ACL.</P>
<P class=MsoNormal><o:p> </o:p></P>
<P class=MsoNormal><SPAN>D:(t1;t2;t3;t4;t5;t6)(t1;t2;t3;t4;t5;t6)(t1;t2;t3;t4;t5;t6)...<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN><o:p> </o:p></SPAN></P>
<P class=MsoNormal>t1: <SPAN>ACE Type (A=Alowed/D=Denied)<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN>t2: ACE Flags (can be empty)<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN>t3: Permissions (GA=All;GW=Write;GX=Execute, is necessary to starts an listener)<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN>t4: Object Type (can be empty)<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN>t5: Inherited Object Type (can be empty)<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN>t6: Trustee (contains a SID of an user or group or well-known SIDs (e.g. WD=Everyone)<o:p></o:p></SPAN></P>
<P class=MsoNormal><o:p> </o:p></P>
<P class=MsoNormal><A href="http://www.washington.edu/computing/support/windows/UWdomains/SDDL.html">Syntax SDDL</A></P>
<P class=MsoNormal><o:p> </o:p></P>
<P class=MsoNormal><B><o:p> </o:p></B></P>
<P class=MsoNormal><B>Examples:<o:p></o:p></B></P>
<P class=MsoNormal><B><o:p> </o:p></B></P>
<P class=MsoNormal>Create Right to open listener for Everyone:</P>
<BLOCKQUOTE dir=ltr>
<P class=MsoNormal><FONT color=#0000ff>httpcfg set urlacl –u </FONT><A href="http://+:7777/"><FONT color=#0000ff>http://+:7777/</FONT></A><FONT color=#0000ff> -a “D:(A;;GX;;;WD)”</FONT></P></BLOCKQUOTE>
<P class=MsoNormal><o:p> </o:p></P>
<P class=MsoNormal>Create Right to open listener for specified User:</P>
<BLOCKQUOTE dir=ltr>
<P class=MsoNormal><FONT color=#0000ff>httpcfg set urlacl –u </FONT><A href="http://+:7777/"><FONT color=#0000ff>http://+:7777/</FONT></A><FONT color=#0000ff> -a “D:(A;;GX;;;S-3-5-21-1654004503-842923446-725354543-102)”</FONT></P></BLOCKQUOTE>
<P class=MsoNormal><o:p> </o:p></P>
<P class=MsoNormal>Show all urlacs on a system.</P>
<BLOCKQUOTE dir=ltr>
<P class=MsoNormal><FONT color=#0000ff>httpcfg query urlacl</FONT></P></BLOCKQUOTE>
<P class=MsoNormal><o:p> </o:p></P>
<P class=MsoNormal>Delete an urlacl on an system</P>
<BLOCKQUOTE dir=ltr>
<P class=MsoNormal><FONT color=#0000ff>httpcfg delete urlacl –u <I><A href="http://+7777/">http://+7777/</A><o:p></o:p></I></FONT></P></BLOCKQUOTE>
<P class=MsoNormal><I><SPAN> </SPAN></I></P>
<P class=MsoNormal><SPAN>There exists a <A href="http://www.stevestechspot.com/default.aspx?articleId=c1f96ead0baf4d93b9695869bc8147dc">GUI Tool </A>which can be used to create <EM>urlacl</EM> and <EM>ssl</EM> rules for HTTP.SYS.</SPAN></P>
<P class=MsoNormal><o:p> </o:p></P><div style="clear:both;"></div><img src="http://developers.de/aggbug.aspx?PostID=902" width="1" height="1">rnebhuthhttp://developers.de/members/rnebhuth/default.aspxCustom MessageHeaders in WCF/blogs/rolf_nebhuth/archive/2006/07/27/864.aspx2006-07-27T14:24:00Z2006-07-27T14:24:00Z<P class=MsoNormal><SPAN></SPAN> </P>
<P class=MsoNormal><SPAN>In WCF it can be necessary to define custom message headers, to transport additional data from client to server, without changing the body of the message, you must define custom headers.</SPAN></P>
<P class=MsoNormal><SPAN><o:p> </o:p></SPAN></P>
<P class=MsoNormal><SPAN>Soap Message with additional Header.<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN><</SPAN><SPAN>s:Envelope</SPAN><SPAN> </SPAN><SPAN>xmlns:s</SPAN><SPAN>=</SPAN><SPAN>"<SPAN>http://schemas.xmlsoap.org/soap/envelope/</SPAN>"<SPAN> </SPAN><SPAN>xmlns:a</SPAN><SPAN>=</SPAN>"<SPAN>http://www.w3.org/2005/08/addressing</SPAN>"<SPAN>><o:p></o:p></SPAN></SPAN></P>
<P class=MsoNormal><SPAN><SPAN> </SPAN><</SPAN><SPAN>s:Header</SPAN><SPAN>><o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN><SPAN> </SPAN><</SPAN><SPAN>a:Action</SPAN><SPAN> </SPAN><SPAN>s:mustUnderstand</SPAN><SPAN>=</SPAN><SPAN>"<SPAN>1</SPAN>"<SPAN>></SPAN>helloWorld<SPAN></</SPAN><SPAN>a:Action</SPAN><SPAN>><o:p></o:p></SPAN></SPAN></P>
<P class=MsoNormal><SPAN><SPAN> </SPAN><</SPAN><SPAN>MyHeader</SPAN><SPAN> </SPAN><SPAN>xmlns</SPAN><SPAN>=</SPAN><SPAN>"<SPAN>http://myExtension/Header</SPAN>"<SPAN> </SPAN><SPAN>name</SPAN><SPAN>=</SPAN>"<SPAN>test</SPAN>"<SPAN>><o:p></o:p></SPAN></SPAN></P>
<P class=MsoNormal><SPAN><SPAN> </SPAN><</SPAN><SPAN>data</SPAN><SPAN>></SPAN><SPAN>Test<SPAN></</SPAN><SPAN>data</SPAN><SPAN>><o:p></o:p></SPAN></SPAN></P>
<P class=MsoNormal><SPAN><SPAN> </SPAN></</SPAN><SPAN>MyHeader</SPAN><SPAN>><o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN><SPAN> </SPAN></</SPAN><SPAN>s:Header</SPAN><SPAN>><o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN><SPAN> </SPAN><</SPAN><SPAN>s:Body</SPAN><SPAN>><o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN><SPAN> </SPAN>...<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN><SPAN> </SPAN></</SPAN><SPAN>s:Body</SPAN><SPAN>><o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN></</SPAN><SPAN>s:Envelope</SPAN><SPAN>><o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN><o:p> </o:p></SPAN></P>
<P class=MsoNormal><SPAN>Simple Additional Headers can be inserted in to Message with:<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN>MessageHeader</SPAN><SPAN> header = <SPAN>MessageHeader</SPAN>.CreateHeader(<SPAN>"MyHeader"</SPAN>,<SPAN>"http://myExtension/Header"</SPAN>, <SPAN>"test"</SPAN>);<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN>message.Headers.Add(header);<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN><o:p> </o:p></SPAN></P>
<P class=MsoNormal><SPAN>For Complex Message Headers you must create an own class which derived from MessageHeader. This class must implement three methods wich serialize the message header and the data in it. It used an XmlWriter so you can write any xml data in this header.</SPAN></P>
<P class=MsoNormal><SPAN><o:p> </o:p></SPAN></P>
<P class=MsoNormal><SPAN><SPAN> </SPAN>/// Add the custom header.<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN><SPAN> </SPAN>message.Headers.Add(new My<SPAN>MessageHeader()</SPAN>);<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN><o:p> </o:p></SPAN></P>
<P class=MsoNormal><SPAN><o:p> </o:p></SPAN></P>
<P class=MsoNormal><SPAN><SPAN> </SPAN>/// Message Header class<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN><SPAN> </SPAN><SPAN>public</SPAN> <SPAN>class</SPAN> <SPAN><FONT color=#000000>My</FONT><SPAN>MessageHeader</SPAN></SPAN>: <SPAN>MessageHeader<o:p></o:p></SPAN></SPAN></P>
<P class=MsoNormal><SPAN><SPAN> </SPAN>{<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN><o:p> /// This method writes all header conten in the XmlWriter.</o:p></SPAN></P>
<P class=MsoNormal><SPAN><o:p> /// The header elemet is already writed in this writer.</o:p></SPAN></P>
<P class=MsoNormal><SPAN><SPAN> </SPAN><SPAN>protected</SPAN> <SPAN>override</SPAN> <SPAN>void</SPAN> OnWriteHeaderContents(<SPAN>XmlDictionaryWriter</SPAN> writer, <SPAN>MessageVersion</SPAN> messageVersion)<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN><SPAN> </SPAN>{<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN><SPAN> </SPAN>writer.WriteAttributeString("name", "test");<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN><SPAN> </SPAN><SPAN> </SPAN><SPAN> </SPAN>writer.WriteStartElement(<SPAN>"data"</SPAN>);<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN><SPAN> </SPAN><SPAN> </SPAN>writer.WriteString("test");<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN><SPAN> </SPAN><SPAN> </SPAN>writer.WriteEndElement(); <o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN><SPAN> </SPAN>}<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN><o:p> </o:p></SPAN></P>
<P class=MsoNormal><SPAN><SPAN> </SPAN><SPAN> </SPAN>/// The Name of the header element.<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN><SPAN> </SPAN><SPAN>public</SPAN> <SPAN>override</SPAN> <SPAN>string</SPAN> Name<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN><SPAN> </SPAN>{<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN><SPAN> </SPAN><SPAN>get</SPAN> { <SPAN>return</SPAN> <SPAN>" MyHeader</SPAN><SPAN> </SPAN><SPAN>"</SPAN>; }<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN><SPAN> </SPAN>}<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN><o:p> </o:p></SPAN></P>
<P class=MsoNormal><SPAN><SPAN> </SPAN>/// The Namespace of the header element<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN><SPAN> </SPAN><SPAN>public</SPAN> <SPAN>override</SPAN> <SPAN>string</SPAN> Namespace<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN><SPAN> </SPAN>{<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN><SPAN> </SPAN><SPAN>get</SPAN> { <SPAN>return</SPAN> NamespaceHeader; }<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN><SPAN> </SPAN>}<SPAN> </SPAN><o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN><SPAN> </SPAN>}<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN><o:p> </o:p></SPAN></P>
<P class=MsoNormal><SPAN><o:p> </o:p></SPAN></P>
<P class=MsoNormal><SPAN>On the Reciver side it is necessary to extract the MessageHeader from the message. There are no methods to do this in the <FONT size=2><FONT face="Courier New">My<SPAN>MessageHeader</SPAN></FONT></FONT> class. <o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN><o:p> </o:p></SPAN></P>
<P class=MsoNormal><SPAN>Simple Additional Headers can be extracted form a Message with:<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN>int</SPAN><SPAN> index = message.Headers.FindHeader(<SPAN>"MyHeader"</SPAN>, <SPAN>"http://myExtension/Header"</SPAN>);<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN>string str = message.Headers.GetHeader<<SPAN>string</SPAN>>(index);<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN><o:p> </o:p></SPAN></P>
<P class=MsoNormal><SPAN>For Complex Message Headers can be extracted form a Message with:<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN>int</SPAN><SPAN> index = message.Headers.FindHeader(<SPAN>"MyHeader"</SPAN>, <SPAN>"http://myExtension/Header"</SPAN>);<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN>XmlReader</SPAN><SPAN> xmlReader = message.Headers.GetReaderAtHeader(index);<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN><o:p> </o:p></SPAN></P>
<P class=MsoNormal><SPAN>If you need a XmlDocument you must create a SubTreeReader <SPAN> </SPAN>before you can load the XmlDocument, because the </SPAN><SPAN>GetReaderAtHeader </SPAN><SPAN>contains all heades and not only the specified header.<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN><o:p> </o:p></SPAN></P>
<P class=MsoNormal><SPAN>XmlReader</SPAN><SPAN> myHeaderReader = xmlReader.ReadSubtree();<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN>XmlDocument</SPAN><SPAN> doc = <SPAN>new</SPAN> <SPAN>XmlDocument</SPAN>();<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN>doc.Load(xmlReader);<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN><SPAN> </SPAN>doc.Load(myHeaderReader);</SPAN></P><div style="clear:both;"></div><img src="http://developers.de/aggbug.aspx?PostID=864" width="1" height="1">rnebhuthhttp://developers.de/members/rnebhuth/default.aspx