<?xml version="1.0" encoding="utf-8"?>
<feed xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xml:lang="en-us" xmlns="http://www.w3.org/2005/Atom">
  <title>Matevz Gacnik's Weblog</title>
  <link rel="alternate" type="text/html" href="http://www.request-response.com/blog/" />
  <link rel="self" href="http://www.request-response.com/blog/SyndicationService.asmx/GetAtom" />
  <logo>http://www.request-response.com/blog/images/favicon.jpg</logo>
  <icon>favicon.ico</icon>
  <updated>2008-10-09T22:30:13.656+02:00</updated>
  <author>
    <name>Matevz Gacnik</name>
  </author>
  <subtitle>Technology Philanthropy</subtitle>
  <id>http://www.request-response.com/blog/</id>
  <generator uri="http://dasblog.info/" version="2.1.8102.813">DasBlog</generator>
  <entry>
    <title>DOW(n)</title>
    <link rel="alternate" type="text/html" href="http://www.request-response.com/blog/PermaLink,guid,98b65bd1-31fc-4a88-88d4-b8276d119ea1.aspx" />
    <id>http://www.request-response.com/blog/PermaLink,guid,98b65bd1-31fc-4a88-88d4-b8276d119ea1.aspx</id>
    <published>2008-10-09T22:29:37.728+02:00</published>
    <updated>2008-10-09T22:30:13.656+02:00</updated>
    <category term="Personal" label="Personal" scheme="http://www.request-response.com/blog/CategoryView,category,Personal.aspx" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <a href="http://en.wikipedia.org/wiki/Dow_Jones_Industrial_Average">DOW</a> is down
almost 700, again. And...
</p>
        <p>
... I just have to post this. Especially when almost everything (besides devaluation
of <em>the safe currency</em>) has already been done.
</p>
        <blockquote dir="ltr" style="MARGIN-RIGHT: 0px">
          <p>
            <em>If you had bought $1,000.00 of </em>
            <a href="http://nortel.com/" target="beer">
              <em>Nortel</em>
            </a>
            <em> stock
one year ago, it would now be worth $49.00.<br /><br />
With </em>
            <a href="http://www.enron.com/" target="beer">
              <em>Enron</em>
            </a>
            <em>, you
would have $16.50 of the original $1,000.00.<br /><br />
With </em>
            <a href="http://www.mci.com/" target="beer">
              <em>MCI/Worldcom</em>
            </a>
            <em>,
you would have less than $5.00 left.<br /><br />
If you had bought $1,000.00 worth of </em>
            <a href="http://www.mgd.com/" target="beer">
              <em>Miller
Genuine Draft</em>
            </a>
            <em> (the beer, not the stock) one year ago, drunk all the beer
then turned in the cans for the 10-cent deposit, you would have $214.00.<br /><br />
Based on the above, 401KegPlan.com's current investment advice is to take that $5.00
you have left over and </em>
            <a href="http://www.sotallytober.com/beer/" target="morebeer">
              <em>drink
lots and lots of beer</em>
            </a>
            <em> and recycle.</em>
          </p>
          <p>
            <em>
              <font color="#808080" size="1">Via: </font>
              <a href="http://401kegplan.com/keg/">
                <font color="#808080" size="1">http://401kegplan.com/keg/</font>
              </a>
            </em>
          </p>
        </blockquote>
        <p>
We are going over the edge. <em>We</em> as a world economy.
</p>
        <p>
And yea, I opened a keg of Guinness.
</p>
        <img width="0" height="0" src="http://www.request-response.com/blog/aggbug.ashx?id=98b65bd1-31fc-4a88-88d4-b8276d119ea1" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Bleeding Edge 2008: Postback</title>
    <link rel="alternate" type="text/html" href="http://www.request-response.com/blog/PermaLink,guid,3e45c176-f86b-4b60-b0a5-9425631e2438.aspx" />
    <id>http://www.request-response.com/blog/PermaLink,guid,3e45c176-f86b-4b60-b0a5-9425631e2438.aspx</id>
    <published>2008-10-09T21:42:02.568+02:00</published>
    <updated>2008-10-09T21:42:02.568+02:00</updated>
    <category term="CLR" label="CLR" scheme="http://www.request-response.com/blog/CategoryView,category,CLR.aspx" />
    <category term="Conferences" label="Conferences" scheme="http://www.request-response.com/blog/CategoryView,category,Conferences.aspx" />
    <category term="Microsoft" label="Microsoft" scheme="http://www.request-response.com/blog/CategoryView,category,Microsoft.aspx" />
    <category term="Web Services" label="Web Services" scheme="http://www.request-response.com/blog/CategoryView,category,WebServices.aspx" />
    <category term="Work" label="Work" scheme="http://www.request-response.com/blog/CategoryView,category,Work.aspx" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
I'm sorry it took a week, but here we go.
</p>
        <p>
This is my exit content from <a href="http://www.bleedingedge.si/">Bleeding Edge 2008</a>.
I'm also posting complete conference contents, just in case.
</p>
        <p>
          <img src="http://www.request-response.com/blog/content/binary/be2008.jpg" />
        </p>
        <p>
Thanks go out to <a href="http://blogs.solidq.com/EN/dzupancic/default.aspx">Dušan</a>, <a href="http://blogs.solidq.com/EN/dsarka/default.aspx">Dejan</a>, <a href="http://www.mihavalencic.com/?p=124">Miha</a>, <a href="http://cs.rthand.com/blogs/blog_with_righthand/archive/2008/10/03/Material-from-my-_2200_Make-ORM-applications-more-secure_2F00_Naredimo-ORM-aplikacije-varnej_6101_e_2200_-presentation.aspx">Miha</a> and <a href="http://www.krneki.net/blog/">Miha</a>.
</p>
        <p>
Downloads:
</p>
        <ul>
          <li>
Middle Tier Design Unleashed: <a href="http://downloads.request-response.com/BleedingEdge2008_MiddleTier.zip">PPT
&amp; Code</a></li>
          <li>
Complete Conference: <a href="http://downloads.request-response.com/BleedingEdge2008.zip">PPT
&amp; Code</a></li>
        </ul>
        <p>
          <font color="#808080" size="1">Remark: PPT in Slovene only. Code international.</font>
        </p>
        <p>
Thank you for attending. Hope to see you next year!
</p>
        <img width="0" height="0" src="http://www.request-response.com/blog/aggbug.ashx?id=3e45c176-f86b-4b60-b0a5-9425631e2438" />
      </div>
    </content>
  </entry>
  <entry>
    <title>XmlSerializer: Serialized Syntax and How to Override It</title>
    <link rel="alternate" type="text/html" href="http://www.request-response.com/blog/PermaLink,guid,efa4e231-ddf1-48f4-9a26-54363e799d42.aspx" />
    <id>http://www.request-response.com/blog/PermaLink,guid,efa4e231-ddf1-48f4-9a26-54363e799d42.aspx</id>
    <published>2008-08-29T20:38:07.673+02:00</published>
    <updated>2008-08-29T21:03:06.694+02:00</updated>
    <category term="XML" label="XML" scheme="http://www.request-response.com/blog/CategoryView,category,XML.aspx" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
Recently I needed to specify exactly how I would like a <em>specific class</em> serialized.
Suppose we have the following simple schema:
</p>
        <p>
          <font face="Courier New">&lt;xs:schema targetNamespace="</font>
          <font face="Courier New">http://my.favourite.ns/person.xsd</font>
          <font face="Courier New">"<br />
   elementFormDefault="qualified"<br />
   xmlns:xs="</font>
          <font face="Courier New">http://www.w3.org/2001/XMLSchema</font>
          <font face="Courier New">"<br />
   </font>
          <font face="Courier New">xmlns="</font>
          <font face="Courier New">http://my.favourite.ns/person.xsd"</font>
          <font face="Courier New">&gt;<br /><strong>  &lt;xs:complexType name="Person"&gt;</strong><br />
    &lt;xs:sequence&gt;<br />
      &lt;xs:element name="Name" type="xs:string" /&gt;<br />
      &lt;xs:element name="Surname" type="xs:string" /&gt;<br />
      &lt;xs:element name="Age" type="xs:int" minOccurs="0"
/&gt;<br />
    &lt;/xs:sequence&gt;<br /><strong>  &lt;/xs:complexType&gt;<br /></strong>&lt;/xs:schema&gt;</font>
        </p>
        <p>
Let's call this schema <font face="Courier New">President.xsd</font>.
</p>
        <p>
A valid XML instance against this schema would be, for example:
</p>
        <p>
          <font face="Courier New">&lt;Person xmlns="http://my.favourite.ns/person.xsd"&gt;<br />
   &lt;Name&gt;Barrack&lt;/Name&gt;<br />
   &lt;Surname&gt;Obama&lt;/Surname&gt;<br />
   &lt;Age&gt;47&lt;/Age&gt;<br />
&lt;/Person&gt;</font>
        </p>
        <p>
Since we are serializing against a specific <a href="http://www.w3.org/XML/Schema">XML
schema</a> (XSD), we have an option of schema compilation:
</p>
        <p>
          <font face="Courier New">xsd /c President.xsd</font>
        </p>
        <p>
This, obviously, yields a programmatic type system result in a form of a C# class.
All well and done.
</p>
        <p>
Now.
</p>
        <p>
If we serialize the filled up class instance back to XML, we get a valid XML instance.
It's valid against <font face="Courier New">President.xsd</font>.
</p>
        <p>
There is a case where your schema changes ever so slightly - read, the namespaces
change, and you don't want to recompile the entire solution to support this, but you
still want to use XML serialization. Who doesn't - what do you do?
</p>
        <p>
Suppose we want to get <strong>the following back</strong>, when serializing:
</p>
        <p>
          <font face="Courier New">&lt;PresidentPerson xmlns="</font>
          <font face="Courier New">http://schemas.gama-system.com/<br />
      president.xsd"</font>
          <font face="Courier New">&gt;<br />
   &lt;Name&gt;Barrack&lt;/Name&gt;<br />
   &lt;Surname&gt;Obama&lt;/Surname&gt;<br />
   &lt;Age&gt;47&lt;/Age&gt;<br />
&lt;/PresidentPerson&gt;</font>
        </p>
        <p>
There is an option to override the default serialization technique of <font face="Courier New">XmlSerializer</font>.
Enter  the world of <font face="Courier New">XmlAttributes</font> and <font face="Courier New">XmlAttributeOverrides</font>:
</p>
        <p>
          <font face="Courier New">private XmlSerializer GetOverridedSerializer()<br />
{<br />
   // set overrides for person element<br />
   XmlAttributes attrsPerson = new XmlAttributes();<br />
   XmlRootAttribute rootPerson = 
<br />
      new XmlRootAttribute("<strong>PresidentPerson</strong>");<br />
   rootPerson.Namespace = "</font>
          <font face="Courier New">
            <strong>http://schemas.gama-system.com/<br />
      president.xsd</strong>
          </font>
          <font face="Courier New">";<br />
   attrsPerson.XmlRoot = rootPerson;</font>
        </p>
        <p>
          <font face="Courier New">   // create overrider<br />
   XmlAttributeOverrides xOver = new XmlAttributeOverrides();<br />
   xOver.Add(typeof(Person), attrsPerson);</font>
        </p>
        <p>
          <font face="Courier New">   XmlSerializer xSer = new XmlSerializer(typeof(Person),
xOver);<br />
   return xSer;<br />
}</font>
        </p>
        <p>
Now serialize normally:
</p>
        <p>
          <font face="Courier New">Stream ms = new MemoryStream();<br />
XmlTextWriter tw = new XmlTextWriter(ms, null);<br />
xSer.Serialize(tw, person);</font>
        </p>
        <p>
This will work even if you only have a compiled version of your object graph, and
you don't have any sources. <font face="Courier New">System.Xml.Serialization.XmlAttributeOverrides</font> class
allows you to adorn any XML serializable class with your own XML syntax - element
names, attribute names, namespaces and types.
</p>
        <p>
Remember - you can override them all and <em>still</em> serialize <em>your</em> angle
brackets.<br /></p>
        <br />
        <img width="0" height="0" src="http://www.request-response.com/blog/aggbug.ashx?id=efa4e231-ddf1-48f4-9a26-54363e799d42" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Bleeding Edge 2008</title>
    <link rel="alternate" type="text/html" href="http://www.request-response.com/blog/PermaLink,guid,b6565ebe-4d35-4676-a09e-08b84b6554b1.aspx" />
    <id>http://www.request-response.com/blog/PermaLink,guid,b6565ebe-4d35-4676-a09e-08b84b6554b1.aspx</id>
    <published>2008-07-17T15:50:06.688+02:00</published>
    <updated>2008-07-28T19:37:27.603+02:00</updated>
    <category term="Architecture" label="Architecture" scheme="http://www.request-response.com/blog/CategoryView,category,Architecture.aspx" />
    <category term="Conferences" label="Conferences" scheme="http://www.request-response.com/blog/CategoryView,category,Conferences.aspx" />
    <category term="MVP" label="MVP" scheme="http://www.request-response.com/blog/CategoryView,category,MVP.aspx" />
    <category term="Work" label="Work" scheme="http://www.request-response.com/blog/CategoryView,category,Work.aspx" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
I'm happy to announce <a href="http://blogs.solidq.com/EN/dsarka/Lists/Posts/Post.aspx?ID=119">our</a> organization
work is coming to fruition.
</p>
        <p>
          <a href="http://www.bleedingedge.si">Bleeding Edge 2008</a> is taking the stage for
the autumn season.
</p>
        <p>
          <strong>
            <img src="http://www.request-response.com/blog/content/binary/be2008.jpg" />
            <br />
          </strong>
          <strong>Portorož, Slovenia, October 1<sup>st</sup>, 9:00</strong>
        </p>
        <p>
          <a href="http://www.bleedingedge.si">Official site</a>, <a href="http://www.bleedingedge.si/prijava.html">Registration</a>, <a href="http://www.bleedingedge.si/sponzorji.html">Sponsors</a></p>
        <p>
Go for the early bird registration (till September 12<sup>th</sup>). The time is now.
</p>
        <p>
Potential sponsor? <a href="http://www.bleedingedge.si/sponzorji.html">Here</a>'s
the offering.
</p>
        <img width="0" height="0" src="http://www.request-response.com/blog/aggbug.ashx?id=b6565ebe-4d35-4676-a09e-08b84b6554b1" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Accreditus: Gama System eArchive</title>
    <link rel="alternate" type="text/html" href="http://www.request-response.com/blog/PermaLink,guid,dc2c17a8-a37b-4aa5-9e73-b0c55efe22f0.aspx" />
    <id>http://www.request-response.com/blog/PermaLink,guid,dc2c17a8-a37b-4aa5-9e73-b0c55efe22f0.aspx</id>
    <published>2008-07-05T14:18:06.428+02:00</published>
    <updated>2008-07-07T10:40:20.4687479+02:00</updated>
    <category term=".NET 3.0 - General" label=".NET 3.0 - General" scheme="http://www.request-response.com/blog/CategoryView,category,NET30General.aspx" />
    <category term=".NET 3.0 - WCF" label=".NET 3.0 - WCF" scheme="http://www.request-response.com/blog/CategoryView,category,NET30WCF.aspx" />
    <category term=".NET 3.5 - WCF" label=".NET 3.5 - WCF" scheme="http://www.request-response.com/blog/CategoryView,category,NET35WCF.aspx" />
    <category term="Other" label="Other" scheme="http://www.request-response.com/blog/CategoryView,category,Other.aspx" />
    <category term="Personal" label="Personal" scheme="http://www.request-response.com/blog/CategoryView,category,Personal.aspx" />
    <category term="Work" label="Work" scheme="http://www.request-response.com/blog/CategoryView,category,Work.aspx" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
One of our core products, <a href="http://gama-system.com/Content.aspx?id=20050200">Gama
System eArchive</a> was <a href="http://www.merriam-webster.com/dictionary/accredit">accredited</a> last
week.
</p>
        <p>
This is <strong>the first accreditation</strong> of a domestic product and <strong>the
first one</strong> covering long term electronic document storage in a SOA based system.
</p>
        <blockquote dir="ltr" style="MARGIN-RIGHT: 0px">
          <p>
            <em>Every document stored inside the Gama System eArchive product is now legally legal.
No questions asked.</em>
          </p>
        </blockquote>
        <p>
Accreditation is done by a <a href="http://www.arhiv.gov.si/en/">national body</a> and
represents the last step in a formal acknowledgement to holiness.
</p>
        <p align="center">
          <img src="http://www.request-response.com/blog/content/binary/archive1.jpg" />
        </p>
        <p>
That means a lot to me, even more to <a href="http://www.gama-system.si">our company</a>.
</p>
        <p>
The following blog entries were (in)directly inspired by the development of this product:
</p>
        <ul>
          <li>
            <a href="http://www.request-response.com/blog/PermaLink,guid,f37eda08-845c-4b0a-a66c-ea9cec03c06b.aspx">Laws
and Digital Signatures</a>
          </li>
          <li>
            <a href="http://www.request-response.com/blog/PermaLink,guid,a510f1dc-23bb-42aa-b683-a70c4740bfe5.aspx">Reliable
Messaging and Retry Timeouts</a>
          </li>
          <li>
            <a href="http://www.request-response.com/blog/PermaLink,guid,ab874bc2-1546-48d1-a8aa-46f0bf876d93.aspx">Approaches
to Document Style Parameter Models</a>
          </li>
          <li>
            <a href="http://www.request-response.com/blog/PermaLink,guid,26149053-63bc-495e-bab0-8d14e7e46190.aspx">XmlSerializer,
Ambient XML Namespaces and Digital Signatures</a>
          </li>
          <li>
            <a href="http://www.request-response.com/blog/PermaLink,guid,f731e5cc-9490-4f1e-bc7d-efb91f357cd1.aspx">Security
Sessions and Service Throttling</a>
          </li>
          <li>
            <a href="http://www.request-response.com/blog/PermaLink,guid,a6cb59e6-cbc2-4ce3-92b2-ea40bc5929f6.aspx">Reliable
Message Delivery</a>
          </li>
          <li>
            <a href="http://www.request-response.com/blog/PermaLink,guid,aa617aa7-1073-422c-86f5-deaaa0758e7d.aspx">Reliable
Message Delivery Continued</a>
          </li>
          <li>
            <a href="http://www.request-response.com/blog/PermaLink,guid,03fb0e40-b446-42b5-ad90-3be9b0260cb5.aspx">Durable
Reliable Messaging</a>
          </li>
        </ul>
        <p>
We've made <strong>a lot of effort</strong> to get this thing developed and accredited.
The certificate is <a href="http://www.request-response.com/blog/content/binary/e_ars_2007_003.pdf">here</a>.
</p>
        <p>
          <a href="http://www.arhiv.gov.si/si/e_hramba_dokumentarnega_gradiva/akreditacija/register_akreditirane_opreme_in_storitev">This</a>, <a href="http://www.posta.si/Namizje.aspx?tabid=746">this</a>, <a href="http://www.agencijanet.si/gama-system-e-arhiv-inovacija-leta-med-malimi-in-srednjimi-podjetji/">this</a>, <a href="http://finance.si/214263">this</a>, <a href="http://www.mojmikro.si/mreza/po_slovensko/ucinkovito_upravljanje_dokumentov_in_varna_e-hramba_podatkov">this</a>, <a href="http://mladipodjetnik.si/arhiv/novice/clani-tehnoloskega-parka-ljubljana-izbrani-med-10-najbolj-inovativnih-podjetij-v-sloveniji">this</a>, <a href="http://www.mojmikro.si/news/gama_system_pricakuje_preboj_med_svetovno_elito">this</a>, <a href="http://www.imix.ba/">this</a>, <a href="http://www.ashrafcom.com/edoc.htm">this</a> and <a href="http://www.si21.com/news.php?id=62696">t</a><a href="http://download.microsoft.com/download/7/D/E/7DE50907-87DD-4FFB-B10F-44A891EB49EC/cs_posta-slovenije-arhiviranje.doc">h</a><a href="http://www.agencijanet.si/slovenska-podjetja-na-cebit-u-2008/">o</a><a href="http://download.microsoft.com/download/F/2/4/F248F674-5D6E-430D-9C31-76546D57C2A3/CS%20Posta%20CEP.DOC">s</a><a href="http://www.agencijanet.si/matevzu-gacniku-ze-tretjic-mandat-microsoftovega-regionalnega-direktorja/">e</a> are
direct approvals of our correct decisions.
</p>
        <img width="0" height="0" src="http://www.request-response.com/blog/aggbug.ashx?id=dc2c17a8-a37b-4aa5-9e73-b0c55efe22f0" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Sysinternals Live</title>
    <link rel="alternate" type="text/html" href="http://www.request-response.com/blog/PermaLink,guid,40794232-f39b-4068-a536-23c5b56a9216.aspx" />
    <id>http://www.request-response.com/blog/PermaLink,guid,40794232-f39b-4068-a536-23c5b56a9216.aspx</id>
    <published>2008-06-19T19:52:52.954+02:00</published>
    <updated>2008-06-19T19:56:17.398+02:00</updated>
    <category term="Other" label="Other" scheme="http://www.request-response.com/blog/CategoryView,category,Other.aspx" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
This is <strong>brilliant</strong>.
</p>
        <p>
          <a href="http://technet.microsoft.com/en-us/sysinternals">Sysinternals</a> tools are
now (actually were already when I left for vacation) available live via a web (http
and <strong>WebDAV</strong>) based resource on <font face="Courier New"><a href="http://live.sysinternals.com">http://live.sysinternals.com</a></font><font face="Verdana">and </font><font face="Courier New">\\live.sysinternals.com</font>.
</p>
        <p>
This means I can do the following:
</p>
        <blockquote dir="ltr" style="MARGIN-RIGHT: 0px">
          <p>
            <font face="Courier New">[c:\]dir </font>
            <font face="Courier New">\\live.sysinternals.com\tools</font>
          </p>
          <p>
            <font face="Courier New"> Directory of  </font>
            <font face="Courier New">\\live.sysinternals.com\tools\</font>
            <font face="Courier New">*</font>
          </p>
          <p>
            <font face="Courier New"> 2.06.2008   1:16        
&lt;DIR&gt;    .<br />
 2.06.2008   1:16         &lt;DIR&gt;   
..<br />
 2.06.2008   1:16         &lt;DIR&gt;   
WindowsInternals<br />
30.05.2008  17:55            
668  About_This_Site.txt<br />
13.05.2008  19:00         225.320 
accesschk.exe<br />
 1.11.2006  15:06         174.968 
AccessEnum.exe<br />
 1.11.2006  23:05         121.712 
accvio.EXE<br />
12.07.2007   7:26         
50.379  AdExplorer.chm<br />
26.11.2007  14:21         422.952 
ADExplorer.exe<br />
 7.11.2007  11:13         401.616 
ADInsight.chm<br />
20.11.2007  14:25       1.049.640  ADInsight.exe<br />
 1.11.2006  15:05         150.328 
adrestore.exe<br />
 1.11.2006  15:06         154.424 
Autologon.exe<br />
 8.05.2008  10:20         
48.476  autoruns.chm<br />
12.05.2008  17:31         622.632 
autoruns.exe 1.11.2006  <br />
...<br />
 1.11.2006  15:06         207.672 
Winobj.exe<br />
30.12.1999  12:26          
7.653  WINOBJ.HLP<br />
27.05.2008  16:21         142.376 
ZoomIt.exe<br />
     24.185.901 bytes in 103 files and 3 dirs<br />
109.442.727.936 bytes free</font>
          </p>
        </blockquote>
        <p dir="ltr">
Or, I can fire up a Windows Explorer window (or <strong>press the start key</strong>,
then type) and just type: <font face="Courier New">\\live.sysinternals.com\tools</font>.
</p>
        <p dir="ltr">
Or:
</p>
        <blockquote dir="ltr" style="MARGIN-RIGHT: 0px">
          <p dir="ltr">
            <font face="Courier New">[c:\]copy </font>
            <font face="Courier New">\\live.sysinternals.com\tools\Procmon.exe</font>
            <font face="Courier New">
              <br />
        C:\Windows\System32<br /></font>
            <font face="Courier New">\\live.sysinternals.com\tools\Procmon.exe</font>
            <font face="Courier New"> =&gt; 
<br />
        C:\Windows\System32\Procmon.exe<br />
     1 file copied</font>
          </p>
        </blockquote>
        <p dir="ltr">
Brilliant and useful.
</p>
        <img width="0" height="0" src="http://www.request-response.com/blog/aggbug.ashx?id=40794232-f39b-4068-a536-23c5b56a9216" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Demos from the NT Conference 2008</title>
    <link rel="alternate" type="text/html" href="http://www.request-response.com/blog/PermaLink,guid,a6f0a54f-31ae-4ccd-ad90-fdfbabba5d95.aspx" />
    <id>http://www.request-response.com/blog/PermaLink,guid,a6f0a54f-31ae-4ccd-ad90-fdfbabba5d95.aspx</id>
    <published>2008-05-15T17:24:19.828+02:00</published>
    <updated>2008-05-21T17:08:27.3461229+02:00</updated>
    <category term=".NET 3.5 - WCF" label=".NET 3.5 - WCF" scheme="http://www.request-response.com/blog/CategoryView,category,NET35WCF.aspx" />
    <category term="Transactions" label="Transactions" scheme="http://www.request-response.com/blog/CategoryView,category,Transactions.aspx" />
    <category term="XML" label="XML" scheme="http://www.request-response.com/blog/CategoryView,category,XML.aspx" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
As promised, here are the sources from my <a href="http://www.ntk.si">NTK 2008</a> sessions <font size="1">[1]</font>.
</p>
        <p>
          <strong>Talk: Document Style Service Interfaces</strong>
        </p>
        <p>
Read the following <a href="http://www.request-response.com/blog/PermaLink,guid,ab874bc2-1546-48d1-a8aa-46f0bf876d93.aspx">blog
entry</a>, I tried to describe the concept in detail. Also, this <a href="http://www.request-response.com/blog/PermaLink,guid,a510f1dc-23bb-42aa-b683-a70c4740bfe5.aspx">blog post</a> discusses
issues when using large document parameters with reliable transport  (WS-RM)
channels.
</p>
        <p>
Demo: Document Style Service Interfaces [<a href="http://www.request-response.com/blog/content/binary/NTK2008DocStyleParamModels.zip">Download</a>]
</p>
        <p>
This demo defines a service interface with the document parameter model, ie. <font face="Courier New">Guid
CreatePerson(XmlDocument person)</font>. It shows three different approaches to creation
of the passed document:
</p>
        <ol>
          <li>
Raw XML creation 
</li>
          <li>
XML Serialization of the (attribute annotated) object graph 
</li>
          <li>
XML Serialization using the <em>client object model</em></li>
        </ol>
        <p>
Also, versioned schemas for the <font face="Courier New">Person</font> document are
shown, including the support for document validation and version independence.
</p>
        <p>
          <strong>Talk: Windows Server 2008 and Transactional NTFS</strong>
        </p>
        <p>
This <a href="http://www.request-response.com/blog/PermaLink,guid,bca19fa8-7ba8-43d8-873e-3a8cf03335cb.aspx">blog
entry</a> describes the concept.
</p>
        <p>
Demo 1: Logging using CLFS (Common Log File System) [<a href="http://www.request-response.com/blog/content/binary/NTK2008TxFCLFS.zip">Download</a>]<br />
Demo 2: NTFS Transactions using the File System, SQL, WCF [<a href="http://www.request-response.com/blog/content/binary/NTK2008TxFFSSQLWCF.zip">Download</a>]<br />
Demo 3: NTFS Transactions using the WCF, MTOM Transport [<a href="http://www.request-response.com/blog/content/binary/NTK2008TxFWCFMTOM.zip">Download</a>] <font size="1">[2]</font></p>
        <p>
          <font size="1">[1] All sources are in VS 2008 solution file format.<br />
[2] This transaction spans from the client, through the service boundary, to the server.</font>
        </p>
        <img width="0" height="0" src="http://www.request-response.com/blog/aggbug.ashx?id=a6f0a54f-31ae-4ccd-ad90-fdfbabba5d95" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Laws and Digital Signatures</title>
    <link rel="alternate" type="text/html" href="http://www.request-response.com/blog/PermaLink,guid,f37eda08-845c-4b0a-a66c-ea9cec03c06b.aspx" />
    <id>http://www.request-response.com/blog/PermaLink,guid,f37eda08-845c-4b0a-a66c-ea9cec03c06b.aspx</id>
    <published>2008-04-16T19:32:29.84+02:00</published>
    <updated>2008-04-16T19:55:33.058875+02:00</updated>
    <category term="Other" label="Other" scheme="http://www.request-response.com/blog/CategoryView,category,Other.aspx" />
    <category term="XML" label="XML" scheme="http://www.request-response.com/blog/CategoryView,category,XML.aspx" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
Suppose we have a document like this:
</p>
        <p>
          <font face="Courier New">&lt;?xml version="1.0"?&gt;<br />
&lt;root xmlns="urn-foo-bar"&gt;<br />
  &lt;subroot&gt;<br />
    &lt;value1&gt;value1&lt;/value1&gt;<br />
    &lt;value2&gt;value2&lt;/value2&gt;<br />
  &lt;/subroot&gt;<br />
  &lt;Signature xmlns="h</font>
          <font face="Courier New">ttp://www.w3.org/2000/09/xmldsig</font>
          <font face="Courier New">#"&gt;<br />
    &lt;SignedInfo&gt;<br />
      &lt;CanonicalizationMethod 
<br />
        Algorithm="</font>
          <font face="Courier New">http://www.w3.org/TR/2001/REC-xml-c14n-20010315</font>
          <font face="Courier New">"
/&gt;<br />
      &lt;SignatureMethod<br />
        Algorithm="</font>
          <font face="Courier New">http://www.w3.org/2000/09/xmldsig#rsa-sha1</font>
          <font face="Courier New">"
/&gt;<br />
      &lt;Reference URI=""&gt;<br />
        &lt;Transforms&gt;<br />
          &lt;Transform <br />
            Algorithm="</font>
          <font face="Courier New">http://www.w3.org/2000/09/<br />
              xmldsig#enveloped-signature</font>
          <font face="Courier New">"/&gt;<br />
        &lt;/Transforms&gt;<br />
        &lt;DigestMethod<br />
          Algorithm="</font>
          <font face="Courier New">http://www.w3.org/2000/09/xmldsig#sha1</font>
          <font face="Courier New">"
/&gt;<br />
        &lt;DigestValue&gt;1Xp...EOko=&lt;/DigestValue&gt;<br />
      &lt;/Reference&gt;<br />
    &lt;/SignedInfo&gt;<br />
    &lt;SignatureValue&gt;nls...cH0k=&lt;/SignatureValue&gt;<br />
    &lt;KeyInfo&gt;<br />
      &lt;KeyValue&gt;<br />
        &lt;RSAKeyValue&gt;<br />
          &lt;Modulus&gt;9f3W...fxG0E=&lt;/Modulus&gt;<br />
          &lt;Exponent&gt;AQAB&lt;/Exponent&gt;<br />
        &lt;/RSAKeyValue&gt;<br />
      &lt;/KeyValue&gt;<br />
      &lt;X509Data&gt;<br />
        &lt;X509Certificate&gt;MIIEi...ktYgN&lt;/X509Certificate&gt;<br />
      &lt;/X509Data&gt;<br />
    &lt;/KeyInfo&gt;<br />
  &lt;/Signature&gt;<br />
&lt;/root&gt;</font>
        </p>
        <p>
This document represents data and an <em>enveloped digital signature</em> over the
complete XML document. The <em>digital signature completeness</em> is defined in the <font face="Courier New">Reference</font> element,
which has <font face="Courier New">URI</font> attribute set to empty string (<font face="Courier New">Reference
Uri=""</font>).
</p>
        <p>
          <strong>Checking the Signature</strong>
        </p>
        <p>
The following should always be applied during signature validation:
</p>
        <ol>
          <li>
Validating the digital signature 
</li>
          <li>
Validating the certificate(s) used to create the signature 
</li>
          <li>
Validating the certificate(s) chain(s)</li>
        </ol>
        <p>
          <strong>
            <em>Note:</em>
          </strong> In most situations this is the optimal validation
sequence. Why? Signatures are broken far more frequently then certificates are revoked/expired.
And certificates are revoked/expired far more frequently then their chains.
</p>
        <p>
          <em>1. Validating the digital signature</em>
        </p>
        <blockquote dir="ltr" style="MARGIN-RIGHT: 0px">
          <p>
First, get it out of there:
</p>
          <p>
            <font face="Courier New">XmlNamespaceManager xmlns = new XmlNamespaceManager(xdkDocument.NameTable);
[1]<br />
xmlns.AddNamespace("ds", "</font>
            <font face="Courier New">http://www.w3.org/2000/09/xmldsig</font>
            <font face="Courier New">#");<br />
XmlNodeList nodeList = xdkDocument.SelectNodes("//ds:Signature", xmlns);<br /></font> <br /><font size="1">[1] <font face="Courier New">xdkDocument </font>should be an <font face="Courier New">XmlDocument</font> instance
representing your document.</font></p>
          <p>
Second, construct a <font face="Courier New">SignedXml</font> instance:
</p>
          <p>
            <font face="Courier New">foreach (XmlNode xmlNode in nodeList)<br />
{<br />
  // create signed xml object<br />
  SignedXml signedXml = new SignedXml(xdkDocument); [2]</font>
          </p>
          <p>
            <font face="Courier New">  // verify signature<br />
  signedXml.LoadXml((XmlElement)xmlNode);<br />
}</font>
          </p>
          <p>
            <font size="1">[2] Note that we are constructing the <font face="Courier New">SignedXml</font> instance
from a complete document, not only the signature. Read this.</font>
          </p>
          <p>
Third, validate:
</p>
          <p>
            <font face="Courier New">bool booSigValid = signedXml.CheckSignature();</font>
          </p>
          <p>
If <font face="Courier New">booSigValid</font> is <font face="Courier New">true</font>,
proceed.
</p>
        </blockquote>
        <p>
          <em>2. Validating the certificate(s) used to create the signature</em>
        </p>
        <blockquote dir="ltr" style="MARGIN-RIGHT: 0px">
          <p>
First, get it out of there:
</p>
          <p>
            <font face="Courier New">XmlNode xndCert = xmlNode.SelectSingleNode(".//ds:X509Certificate",
xmlns); [3]</font>
          </p>
          <p>
            <font size="1">[3] There can be multiple <font face="Courier New">X509Certificate</font> elements
qualified with <font face="Courier New">h</font></font>
            <font face="Courier New" size="1">ttp://www.w3.org/2000/09/xmldsig</font>
            <font size="1">
              <font face="Courier New">#</font> namespace
in there. Xml Digital Signature specification is allowing the serialization of a complete
certificate chain of the certificate used to sign the document. Normally, the signing
certificate should be the first to be serialized.</font>
          </p>
          <p>
Second, get the <font face="Courier New">X509Certificate2</font> instance:
</p>
          <p>
            <font face="Courier New">byte[] bytCert = Convert.FromBase64String(xndCert.InnerText);<br />
X509Certificate2 x509cert = new X509Certificate2(bytCert);</font>
          </p>
          <p>
Third, validate:
</p>
          <p>
            <font face="Courier New">bool booCertValid = x509cert.Verify();</font>
          </p>
          <p>
If <font face="Courier New">booCertValid</font> is <font face="Courier New">true</font>,
proceed.
</p>
        </blockquote>
        <p>
          <em>3. Validating the certificate(s) chain(s)</em>
        </p>
        <blockquote dir="ltr" style="MARGIN-RIGHT: 0px">
          <p>
Building and validating the chain:
</p>
          <p>
            <font face="Courier New">X509Chain certChain = new X509Chain();<br />
bool booChainValid = certChain.Build(x509cert);<br />
int intChainLength = certChain.ChainElements.Count; [4]</font>
          </p>
          <p>
If <font face="Courier New">booChainValid</font> is <font face="Courier New">true</font>,
your signature is <strong>valid</strong>.
</p>
        </blockquote>
        <p dir="ltr">
          <strong>Some Rules and Some Laws</strong>
        </p>
        <p dir="ltr" style="MARGIN-RIGHT: 0px">
We have three booleans:
</p>
        <p dir="ltr" style="MARGIN-RIGHT: 0px">
        </p>
        <ul>
          <li>
            <font face="Courier New">booSigValid</font> - signature validity 
</li>
          <li>
            <font face="Courier New">booCertValid</font> - certificate validity 
</li>
          <li>
            <font face="Courier New">booChainValid</font> - certificate's chain validity</li>
        </ul>
        <p>
        </p>
        <p>
If <font face="Courier New">booSigValid</font> evaluates to <font face="Courier New">false</font>,
there is no discussion. Someone <strong>changed the document</strong>.
</p>
        <p>
What happens if one of the following two expressions evaluates to <font face="Courier New">true</font>:
</p>
        <p>
1. <font face="Courier New">((booSigValid) &amp;&amp; (!booCertValid) &amp;&amp; (!booChainValid))<br /></font>2. <font face="Courier New">((booSigValid) &amp;&amp; (booCertValid) &amp;&amp;
(!booChainValid))</font></p>
        <p>
This normally means that either the certificate is not valid (CRLed or expired) [4],
or one of the chain's certificate is not valid/expired.
</p>
        <p>
          <font size="1">[4] The premise is that one checked the signature according to 1, 2,
3 schema described above.</font>
        </p>
        <p>
          <strong>The Question</strong>
        </p>
        <p>
Is digital signature valid even if CA revoked the certificate after the
signature has already been done? Is it valid even after the certificate expires? If
signature is valid and certificate has been revoked, what is the legal validity of
the signature?
</p>
        <p>
In legal terms, the signature would be <strong>invalid</strong> on both upper assertions,
1 and 2. 
</p>
        <p>
This means, that once the generator of the signature is dead, or one of his predecessors
is dead, all his children die too.
</p>
        <p>
          <strong>Timestamps to the Rescue</strong>
        </p>
        <p>
According to most country's digital signature laws the signature is valid only during
the validity of the signing certificate and validity of the signing certificate's
chain, both being checked for revocation and expiry date ... if you don't timestamp
it.
</p>
        <p>
If the source document has <em>another signature</em> from a trusted authority, and
that authority is a timestamp authority, it would look like this:
</p>
        <p>
          <font face="Courier New">&lt;?xml version="1.0"?&gt;<br />
&lt;root xmlns="urn-foo-bar"&gt;<br />
  &lt;subroot&gt;<br />
    &lt;value1&gt;value1&lt;/value1&gt;<br />
    &lt;value2&gt;value2&lt;/value2&gt;<br />
  &lt;/subroot&gt;<br />
  &lt;Signature xmlns="</font>
          <font face="Courier New">http://www.w3.org/2000/09/xmldsig</font>
          <font face="Courier New">#"&gt;<br />
    ...<br />
  &lt;/Signature&gt;<br />
  &lt;dsig:Signature Id="TimeStampToken"<br />
    </font>
          <font face="Courier New">xmlns:dsig="</font>
          <font face="Courier New">http://www.w3.org/2000/09/xmldsig</font>
          <font face="Courier New">#"&gt;<br />
    &lt;dsig:SignedInfo&gt;<br />
      &lt;dsig:CanonicalizationMethod<br />
        Algorithm="</font>
          <font face="Courier New">http://www.w3.org/TR/2001/REC-xml-c14n-20010315</font>
          <font face="Courier New">"
/&gt;<br />
      &lt;dsig:SignatureMethod<br />
        Algorithm="</font>
          <font face="Courier New">http://www.w3.org/2000/09/xmldsig#rsa-sha1"</font>
          <font face="Courier New"> /&gt;<br />
      &lt;dsig:Reference<br />
        URI="#TimeStampInfo-113D2EEB158BBB2D7CC000000000004DF65"&gt;<br />
        &lt;dsig:DigestMethod<br />
          Algorithm="</font>
          <font face="Courier New">http://www.w3.org/2000/09/xmldsig#sha1"</font>
          <font face="Courier New"> /&gt;<br />
          &lt;dsig:DigestValue&gt;y+xw...scKg=&lt;/dsig:DigestValue&gt;<br />
      &lt;/dsig:Reference&gt;<br />
      &lt;dsig:Reference URI="#TimeStampAuthority"&gt;<br />
        &lt;dsig:DigestMethod<br />
          Algorithm="</font>
          <font face="Courier New">http://www.w3.org/2000/09/xmldsig#sha1"</font>
          <font face="Courier New"> /&gt;<br />
        &lt;dsig:DigestValue&gt;KhFIr...Sv4=&lt;/dsig:DigestValue&gt;<br />
      &lt;dsig:/Reference&gt;<br />
    &lt;/dsig:SignedInfo&gt;<br />
    &lt;dsig:SignatureValue&gt;R4m...k3aQ==&lt;/dsig:SignatureValue&gt;<br />
    &lt;dsig:KeyInfo Id="TimeStampAuthority"&gt;<br />
      &lt;dsig:X509Data&gt;<br />
        &lt;dsig:X509Certificate&gt;MII...Osmg==&lt;/dsig:X509Certificate&gt;<br />
      &lt;/dsig:X509Data&gt;<br />
    &lt;/dsig:KeyInfo&gt;<br />
    &lt;dsig:Object<br />
      Id="TimeStampInfo-113D2EEB158BBB2D7CC000000000004DF65"&gt;<br />
      &lt;ts:TimeStampInfo<br />
         xmlns:ts="</font>
          <font face="Courier New">http://www.provider.com/schemas<font color="#003300"><br />
           </font>/timestamp-protocol-20020207</font>
          <font face="Courier New">"<br />
         xmlns:ds="</font>
          <font face="Courier New">http://www.w3.org/2000/09/xmldsig</font>
          <font face="Courier New">#"&gt;<br />
        &lt;ts:Policy id="</font>
          <font face="Courier New">http://provider.tsa.com/documents"</font>
          <font face="Courier New"> /&gt;<br />
          &lt;ts:Digest&gt;<br />
            &lt;ds:DigestMethod
Algorithm="</font>
          <font face="Courier New">http://www.w3.org/2000/<br />
              09/xmldsig#sha1"</font>
          <font face="Courier New"> /&gt;<br />
            &lt;ds:DigestValue&gt;V7+bH...Kmsec=&lt;/ds:DigestValue&gt;<br />
          &lt;/ts:Digest&gt;<br />
          &lt;ts:SerialNumber&gt;938...045&lt;/ts:SerialNumber&gt;<br />
          &lt;ts:CreationTime&gt;2008-04-13T11:31:42.004Z&lt;/ts:CreationTime&gt;<br />
          &lt;ts:Nonce&gt;121...780&lt;/ts:Nonce&gt;<br />
      &lt;/ts:TimeStampInfo&gt;<br />
    &lt;/dsig:Object&gt;<br />
  &lt;/dsig:Signature&gt;<br />
&lt;/root&gt;</font>
        </p>
        <p>
The second signature would be performed by an out-of-band authority, normally a <strong>TSA
authority</strong>. It would only sign a <em>hash value</em> (in this case SHA1 hash)
which was constructed by hashing the original document and the included digital signature.
</p>
        <p>
This (second) signature should be checked using the same 1, 2, 3 steps. For the purpose
of this mind experiment, let's say it would generate a <font face="Courier New">booTimestampValid</font> boolean.
</p>
        <p>
Now, let's reexamine the booleans:
</p>
        <ol>
          <li>
            <font face="Courier New">((booSigValid) &amp;&amp; (!booCertValid) &amp;&amp; (!booChainValid)
&amp;&amp; (booTimestampValid))</font>
          </li>
          <li>
            <font face="Courier New">((booSigValid) &amp;&amp; (booCertValid) &amp;&amp; (!booChainValid)
&amp;&amp; (booTimestampValid))</font>
          </li>
        </ol>
        <p>
In this case, <em>even though the signature's certificate (or its chain) is invalid,
the signature would pass legal validity</em> if the timesamp's signature is valid,
together with its certificate and certificate chain. Note that the TSA signature is
generated with a different set of keys than the original digital signature.
</p>
        <p>
Actually <font face="Courier New">booTimestampValid</font> is defined as <font face="Courier New">((booSigValid)
&amp;&amp; (booCertValid) &amp;&amp; (booChainValid))</font> for the timestamp signature/certificate/certificate
chain [5].
</p>
        <p>
          <font size="1">[5] Legal validity is guaranteed only in cases where 1 or 2 are true.</font>
        </p>
        <img width="0" height="0" src="http://www.request-response.com/blog/aggbug.ashx?id=f37eda08-845c-4b0a-a66c-ea9cec03c06b" />
      </div>
    </content>
  </entry>
  <entry>
    <title>WCF: Reliable Messaging and Retry Timeouts</title>
    <link rel="alternate" type="text/html" href="http://www.request-response.com/blog/PermaLink,guid,a510f1dc-23bb-42aa-b683-a70c4740bfe5.aspx" />
    <id>http://www.request-response.com/blog/PermaLink,guid,a510f1dc-23bb-42aa-b683-a70c4740bfe5.aspx</id>
    <published>2008-04-09T00:33:13.159+02:00</published>
    <updated>2008-04-16T17:20:00.887+02:00</updated>
    <category term=".NET 3.0 - WCF" label=".NET 3.0 - WCF" scheme="http://www.request-response.com/blog/CategoryView,category,NET30WCF.aspx" />
    <category term=".NET 3.5 - WCF" label=".NET 3.5 - WCF" scheme="http://www.request-response.com/blog/CategoryView,category,NET35WCF.aspx" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
There is a <em>serious limitation</em> present in the RTM version of WCF 3.0/3.5 regarding
control of WS-RM retry messages during a <strong>reliable session</strong> saga.
</p>
        <p>
Let me try to explain the concept.
</p>
        <p>
We have a sender (communication initiator) and a receiver (service). When a reliable
session is constructed between the two, every message needs to come to the other side.
In a request-reply world, the sender would be a client during the request phase. Then
roles would switch during the response phase.
</p>
        <p>
The problem arises when one of the sides <strong>does not get</strong> the message
acknowledgement in time. WCF reliable messaging implementation retries the sending
process and hopes for the acknowledgement. All is well.
</p>
        <p>
The problem is that there is <em>no way </em>for the sending application to specify <em>how
long the retry timeout should be</em>. There is a way to specify channel opening and
closing timeouts, acknowledgement interval and more, but nothing will define how long
should the initiator wait for message acks.
</p>
        <p>
          <img src="http://www.request-response.com/blog/images/wcfreplytimeout1.gif" />
        </p>
        <p>
Let's talk about how WCF acknowledges messages.
</p>
        <p>
During a request-reply exchange every request message is acknowledged <em>in a response
message</em>. WS-RM SOAP headers regarding sequence definition (request) and acknowledgements
(response) look like this:
</p>
        <p>
          <font face="Courier New">a1 &lt;r:Sequence s:mustUnderstand="1" u:Id="_2"&gt;<br />
a2    &lt;r:Identifier&gt;urn:uuid:6c9d...ca90&lt;/r:Identifier&gt;<br />
a3    <strong>&lt;r:MessageNumber&gt;1&lt;/r:MessageNumber&gt;<br /></strong>a4 &lt;/r:Sequence&gt;</font>
        </p>
        <p>
          <font face="Courier New">b1 &lt;r:SequenceAcknowledgement u:Id="_3"&gt;<br />
b2    &lt;r:Identifier&gt;urn:uuid:6c99...ca290&lt;/r:Identifier&gt;<br />
b3    <strong>&lt;r:AcknowledgementRange Lower="1" Upper="1"/&gt;<br />
b4    &lt;netrm:BufferRemaining 
<br />
b5       xmlns:netrm="</strong></font>
          <font face="Courier New">
            <strong>http://schemas.microsoft.com/ws/2006/05/rm"</strong>
          </font>
          <font face="Courier New">
            <strong>&gt;<br />
b6    &lt;/netrm:BufferRemaining&gt;<br /></strong>b7 &lt;/r:SequenceAcknowledgement&gt;</font>
        </p>
        <p>
Request phase defines a sequence and sends the first message (<font face="Courier New">a3</font>).
In response, there is the appropriate acknowledgement present, which acks the first
message (<font face="Courier New">b3</font>) with <font face="Courier New">Lower</font> and <font face="Courier New">Upper</font> attributes.
Lines <font face="Courier New">b4-b6</font> define a benign and super useful WCF implementation
of <em>flow control</em>, which allows the sender to limit the rate of sent messages
if service side <strong>becomes congested</strong>.
</p>
        <p>
When the session is setup, WCF will have a really small time waiting window for acks.
Therefore, if ack is not received during this period, the infrastructure <em>will
retry the message</em>.
</p>
        <p>
Duplex contracts work slightly differently. There, the acknowledgement interval can
be set. This configuration option (config attribute is called <font face="Courier New">acknowledgementInterval</font>)
is named inappropriately, since it controls the service and not the client side.
</p>
        <p>
It does not define the time limit on <em>received acknowledgements</em>, but the necessary
time to <em>send the acknowledgments back</em>. It allows grouping of sent acks, so
that multiple incoming messages can be acked together. Also, the infrastructure will
not necessarily honor the specified value.
</p>
        <p>
Now consider the following scenario:
</p>
        <ol>
          <li>
The client is on a reliable network 
</li>
          <li>
Network bandwidth is so thin that the sending message takes 20s to come through <font face="Courier New">[1]</font></li>
          <li>
            <a href="http://www.request-response.com/blog/PermaLink,guid,48b65a92-4015-45f2-8fee-78ae5c0e48b8.aspx">Service
instancing</a> is set to <font face="Courier New">Multiple</font></li>
          <li>
The solution uses a request-reply semantics</li>
        </ol>
        <p>
          <font size="1">
            <font face="Courier New">[1]</font> It does not matter whether the
initiator is on a dial up, or the message is huge.</font>
        </p>
        <p>
          <strong>What happens?</strong>
        </p>
        <p>
Service initiator sets up a reliable session, then:
</p>
        <ol>
          <li>
First message is being sent 
</li>
          <li>
Since the retry interval is really small <font face="Courier New">[2]</font>, the
message will not get to the other end and the acknowledgement will not bounce
back in time 
</li>
          <li>
First message is retried, now two messages are being transported 
</li>
          <li>
No acks received yet 
</li>
          <li>
First message is retried again 
</li>
          <li>
Network bandwidth is even thinner 
</li>
          <li>
First message is acknowledged 
</li>
          <li>
First message retry is discarded on the service side 
</li>
          <li>
Second message retry is discarded on the service side</li>
        </ol>
        <p>
          <font size="1">
            <font face="Courier New">[2]</font> Under 3s.</font>
        </p>
        <p>
The number of retry messages depends on the <em>bandwidth</em> and <em>message size</em>.
It can happen that tens of messages will be sent before first acknowledgement will
be received.
</p>
        <p>
          <strong>Adaptability algorithms</strong>
        </p>
        <p>
A good thing is that there are undocumented algorithms implemented for retry timeout.
The implementation increases the reply timeout <em>exponentially</em> when the infrastructure
detects that the network conditions demand more time (slow throughput) and allows
reliable delivery (no losses). If loses are present the reply timeout decreases.
</p>
        <p>
Retry timeout is actually calculated when establishing an RM session. It
is based on the roundtrip time and is bigger if the roundtrip time is long.
</p>
        <p>
So, when first messages in a session are exchanged, don't be too surprised to see
a couple of message retries.
</p>
        <img width="0" height="0" src="http://www.request-response.com/blog/aggbug.ashx?id=a510f1dc-23bb-42aa-b683-a70c4740bfe5" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Calculating Outsourcing Project Cost</title>
    <link rel="alternate" type="text/html" href="http://www.request-response.com/blog/PermaLink,guid,fff35773-9d2b-4ffc-9795-4e2b62fc61a4.aspx" />
    <id>http://www.request-response.com/blog/PermaLink,guid,fff35773-9d2b-4ffc-9795-4e2b62fc61a4.aspx</id>
    <published>2008-02-18T23:01:39.53125+01:00</published>
    <updated>2008-02-18T23:01:39.53125+01:00</updated>
    <category term="Personal" label="Personal" scheme="http://www.request-response.com/blog/CategoryView,category,Personal.aspx" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
Wow, <a href="http://www.stephenforte.net/PermaLink,guid,48917fe9-ab8a-4d98-8d49-c70cb53a82ef.aspx">Stephen</a>. 
</p>
        <p>
This is one of the best ideas I've heard of hedging against the dollar in terms if
IT outsourcing cost. And I mean it.
</p>
        <p>
I'm not in a position of valueing the description made, but I am willing to take the
pill, no matter what.
</p>
        <p>
What everybody needs is only to get to one million sterling project,
taking half a year. 
</p>
        <p>
That's it, hedging done or not.
</p>
        <img width="0" height="0" src="http://www.request-response.com/blog/aggbug.ashx?id=fff35773-9d2b-4ffc-9795-4e2b62fc61a4" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Happy Birthday XML</title>
    <link rel="alternate" type="text/html" href="http://www.request-response.com/blog/PermaLink,guid,b8fa5b93-1d54-4cdb-a353-5febb4232890.aspx" />
    <id>http://www.request-response.com/blog/PermaLink,guid,b8fa5b93-1d54-4cdb-a353-5febb4232890.aspx</id>
    <published>2008-02-13T20:36:09.046875+01:00</published>
    <updated>2008-02-13T20:36:09.046875+01:00</updated>
    <category term="XML" label="XML" scheme="http://www.request-response.com/blog/CategoryView,category,XML.aspx" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
This week XML is <a href="http://www.tbray.org/ongoing/When/200x/2008/02/10/XML-People">ten
years old</a>. The core XML 1.0 specification was released in February 1998. 
</p>
        <p>
It's a nice anniversary to have.
</p>
        <p>
The XML + Namespaces specification has a built in namespace declaration of <font face="Courier New">http://www.w3.org/XML/1998/namespace</font>.
That's an implicit namespace declaration, a special one, governing all other. One
namespace declaration to rule them all. Bound to <font face="Courier New"><a href="http://www.w3.org/XML/1998/namespace">xml:</a></font> prefix.
</p>
        <p>
          <img src="http://www.request-response.com/blog/images/originalxmlnamespace.jpg" />
        </p>
        <p>
XML was born and published as a W3C Recommendation on 10<sup>th</sup> of February
1998.
</p>
        <p>
So, well done XML. You did <strong>a lot</strong> for IT industry in the past decade.
</p>
        <img width="0" height="0" src="http://www.request-response.com/blog/aggbug.ashx?id=b8fa5b93-1d54-4cdb-a353-5febb4232890" />
      </div>
    </content>
  </entry>
  <entry>
    <title>European Silverlight Challenge</title>
    <link rel="alternate" type="text/html" href="http://www.request-response.com/blog/PermaLink,guid,3990a494-ac6f-4314-978b-39a459c36759.aspx" />
    <id>http://www.request-response.com/blog/PermaLink,guid,3990a494-ac6f-4314-978b-39a459c36759.aspx</id>
    <published>2008-01-04T10:33:22.60225+01:00</published>
    <updated>2008-01-04T10:33:22.60225+01:00</updated>
    <category term="Other" label="Other" scheme="http://www.request-response.com/blog/CategoryView,category,Other.aspx" />
    <category term="Silverlight" label="Silverlight" scheme="http://www.request-response.com/blog/CategoryView,category,Silverlight.aspx" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
If you're into <a href="http://silverlight.net/Default.aspx">Silverlight</a>, and
you should be, check out <a href="http://www.silverlightchallenge.eu">http://www.silverlightchallenge.eu</a>,
and especially sign up on <a href="http://slovenia.silverlightchallenge.eu">http://slovenia.silverlightchallenge.eu</a> and
join one of our many developers who will participate in this competition.
</p>
        <p>
          <img src="http://www.request-response.com/blog/images/silverlightchallenge2008.jpg" />
        </p>
        <p>
More <a href="http://www.slodug.si/blogs/system/archive/2007/12/20/1.-evropski-nate_0D01_aj-Silverlight.aspx">here</a>.
</p>
        <img width="0" height="0" src="http://www.request-response.com/blog/aggbug.ashx?id=3990a494-ac6f-4314-978b-39a459c36759" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Mr. Larry Lessig</title>
    <link rel="alternate" type="text/html" href="http://www.request-response.com/blog/PermaLink,guid,3b183ab0-9506-470b-807a-e9f39a40aa12.aspx" />
    <id>http://www.request-response.com/blog/PermaLink,guid,3b183ab0-9506-470b-807a-e9f39a40aa12.aspx</id>
    <published>2007-11-09T23:59:24.083+01:00</published>
    <updated>2007-11-09T23:59:24.083+01:00</updated>
    <category term="Personal" label="Personal" scheme="http://www.request-response.com/blog/CategoryView,category,Personal.aspx" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
Mr. <a href="http://www.lessig.org/blog/">Lawrence Lessig</a> is a founder of <a href="http://cyberlaw.stanford.edu/">Stanford
Center for Internet and Society</a>. He's also a chairman for the <a href="http://creativecommons.org/">Creative
Commons</a> organization.
</p>
        <p>
Lessig is one of the most effective speakers in the world, a professor at
Stanford, who tries to make this world a better place from a standpoint of stupidity
in terms of the copyright law.
</p>
        <p>
The following is published on the <a href="http://creativecommons.org/">CC</a>'s site:
</p>
        <blockquote dir="ltr" style="MARGIN-RIGHT: 0px">
          <p>
            <em>We use <strong>private rights</strong> to create <strong>public goods</strong>:
creative works set free for certain uses. ... We work to offer creators a best-of-both-worlds
way to protect their works while encouraging certain uses of them — to declare <strong>“some
rights reserved.”</strong></em>
          </p>
        </blockquote>
        <p>
Therefore Creative Commons stands for the mantra of <em>some rights reserved</em> and
not <em>all rights reserved</em> in terms of meaningful usage of digital technology.
</p>
        <p>
Being a <a href="http://en.wikipedia.org/wiki/Libertarianism">libertarian</a> myself,
I cannot oppose these stands. <em>Balance</em> and <em>compromise </em>are good things for
content and intellectual products, such as software.
</p>
        <p>
Watch <a href="http://www.ted.com/index.php/talks/view/id/187">his masterpiece</a>,
delivered at <a href="http://www.ted.com">TED</a>.
</p>
        <img width="0" height="0" src="http://www.request-response.com/blog/aggbug.ashx?id=3b183ab0-9506-470b-807a-e9f39a40aa12" />
      </div>
    </content>
  </entry>
  <entry>
    <title>On Instance and Static Method Signatures</title>
    <link rel="alternate" type="text/html" href="http://www.request-response.com/blog/PermaLink,guid,634a58b1-13e5-4b7a-b2ac-010965235bcb.aspx" />
    <id>http://www.request-response.com/blog/PermaLink,guid,634a58b1-13e5-4b7a-b2ac-010965235bcb.aspx</id>
    <published>2007-11-03T22:04:38.531+01:00</published>
    <updated>2007-11-04T09:03:14.390625+01:00</updated>
    <category term="CLR" label="CLR" scheme="http://www.request-response.com/blog/CategoryView,category,CLR.aspx" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
We talked today, with <a href="http://cs.rthand.com/blogs/blog_with_righthand/">Miha</a>,
a C# <a href="http://en.wikipedia.org/wiki/Yoda">Yoda</a>. Via IM, everything seemed
pointless. Couldn't find a good case for the cause of the following mind experiment:
</p>
        <p>
          <font face="Courier New">using System;<br />
class Tubo<br />
{<br />
  public static void Test() {}<br />
  private void Test() {} <br />
}<br /></font>
          <font size="1">
            <br />
Note: I'm using Miha's syntax in this post.</font>
        </p>
        <p>
We have a <strong>static method</strong> called <font face="Courier New">Test</font> and
an <strong>instance method</strong>, also called <font face="Courier New">Test</font>.
Parameter models of both methods are the same, <em>empty</em>.
</p>
        <p>
Would this compile?
</p>
        <p>
          <em>It does not.</em>
        </p>
        <p>
The question is why and who/what causes this. There is actually <strong>no rationale </strong>behind
not allowing this thing to compile since both, the compiler and the runtime know the
method info upfront.
</p>
        <p>
Since the runtime has all the information it needs, it is strange that this would
not be allowed at compile time. However, a (C#) compiler has to determine whether
you, <strong>the programmer </strong>meant to access a <em>static</em> or an <em>instance</em> method.
</p>
        <p>
          <em>Here lie the dragons.</em>
        </p>
        <p>
It is illegal in most virtual machine based languages to have the same method name
and signature for a static/instance method.
</p>
        <p>
The following is an excerpt from a <a href="http://java.sun.com/docs/books/jls/third_edition/html/classes.html#8.4.2">Java
specification</a>:
</p>
        <blockquote dir="ltr" style="MARGIN-RIGHT: 0px">
          <p>
            <em>8.4.2 Method Signature</em>
          </p>
        </blockquote>
        <blockquote>
          <p>
            <em>Two methods have the <strong>same signature</strong> if they have the same name
and argument types.</em>
          </p>
          <p>
            <em>Two method or constructor declarations M and N have the same argument types if
all of the following conditions hold: </em>
          </p>
          <p>
            <em>
            </em>
          </p>
          <ul>
            <a name="299803">
            </a>
            <li>
              <em>They have the same number of formal parameters (possibly zero) </em>
              <a name="299804">
              </a>
            </li>
            <li>
              <em>They have the same number of type parameters (possibly zero) </em>
              <a name="324473">
              </a>
            </li>
            <li>
              <em>Let &lt;A<sub>1</sub>,...,A<sub>n</sub>&gt; be the formal type parameters of M
and let &lt;B<sub>1</sub>,...,B<sub>n</sub>&gt; be the formal type parameters of N.
After renaming each occurrence of a B<sub>i</sub> in N's type to A<sub>i</sub> the
bounds of corresponding type variables and the argument types of M and N are the same. </em>
            </li>
          </ul>
        </blockquote>
        <p>
Java (and also C#) does not allow two methods with the same name and parameter model
no matter what the access modifier is (public, private, internal, protected ...) and
whether the method is static or instance based.
</p>
        <p>
          <em>Why?</em>
        </p>
        <p>
Simple. <strong>Programmer ambiguity.</strong> There is no technical reason not to
allow it.
</p>
        <p>
Consider the following:
</p>
        <p>
          <font face="Courier New">using System;<br />
class Tubo<br />
{ 
<br />
  public static void Test(); 
<br />
  private void Test(); 
<br />
  public void AmbiguousCaller() { Test(); } 
<br />
}</font>
        </p>
        <p>
What would method <font face="Courier New">AmbiguousCaller</font> call? A static <font face="Courier New">Test</font> or
instance <font face="Courier New">Test</font> method? 
</p>
        <p>
          <em>Can't decide? </em>
        </p>
        <p>
That's why this is not allowed. 
</p>
        <p>
And yes, it would call the instance method if this would be allowed, since statics
in C# <em>should</em> be called using a class name, as in <font face="Courier New">Test.Test()</font>.
Note that the preceding example <em>does not compile</em>. Also note, that
it <em>is legal</em> to have a <font face="Courier New">AmbiguousCaller</font> body
as <font face="Courier New">Test()</font> or <font face="Courier New">Tubo.Test()</font>.
</p>
        <p>
There is another ambiguous reason. Local variables in C# <strong>cannot</strong> be
named <em>the same as the enclosing class</em>. Therefore, this is illegal:
</p>
        <p>
          <font face="Courier New">using System;<br />
class Tubo<br />
{<br />
  private int Tubo;<br />
}</font>
        </p>
        <p>
It is. Do a <font face="Courier New">csc /t:library</font> on it.
</p>
        <p>
Since you confirmed this fact, consider the following:
</p>
        <p>
          <font face="Courier New">using System;<br />
public class Tubo<br />
{ 
<br />
  public static void StaticMethod() {} 
<br />
  public void InstanceMethod() {} 
<br />
}</font>
        </p>
        <p>
          <font face="Courier New">public class RunMe<br />
{<br />
  public static void Main()<br />
  { 
<br />
    Tubo Tubo = new Tubo();<br />
    Tubo.InstanceMethod();<br />
    Tubo.StaticMethod();<br />
  }<br />
}</font>
        </p>
        <p>
Focus on the <font face="Courier New">Main</font> method <em>body</em>. In <font face="Courier New">Tubo.InstanceMethod()</font> an
instance method is called and a reference (namely <font face="Courier New">Tubo</font>)
is used. In <font face="Courier New">Tubo.StaticMethod()</font> a static method is
called and <font face="Courier New">Tubo</font> is not an instance reference, but
class name.
</p>
        <p>
It all comes down to <em>programmer ambiguity</em>. Given a chance, I would support
this design decision too.
</p>
        <img width="0" height="0" src="http://www.request-response.com/blog/aggbug.ashx?id=634a58b1-13e5-4b7a-b2ac-010965235bcb" />
      </div>
    </content>
  </entry>
  <entry>
    <title>WCF: Passing Collections Through Service Boundaries, Why and How</title>
    <link rel="alternate" type="text/html" href="http://www.request-response.com/blog/PermaLink,guid,ff5fab81-affb-4b2b-aa67-c80bdfc86cbd.aspx" />
    <id>http://www.request-response.com/blog/PermaLink,guid,ff5fab81-affb-4b2b-aa67-c80bdfc86cbd.aspx</id>
    <published>2007-09-27T23:04:47.328+02:00</published>
    <updated>2007-09-27T23:28:02.546875+02:00</updated>
    <category term=".NET 3.0 - WCF" label=".NET 3.0 - WCF" scheme="http://www.request-response.com/blog/CategoryView,category,NET30WCF.aspx" />
    <category term=".NET 3.5 - WCF" label=".NET 3.5 - WCF" scheme="http://www.request-response.com/blog/CategoryView,category,NET35WCF.aspx" />
    <category term="Web Services" label="Web Services" scheme="http://www.request-response.com/blog/CategoryView,category,WebServices.aspx" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
In WCF, collection data that is passed through the service boundary goes through a <em>type
filter </em>- meaning you will not necessarily get the <em>intrinsic service side
type</em> on the client, even if you're <strong>expecting it</strong>.
</p>
        <p>
No matter if you throw back an <font face="Courier New">int[]</font> or <font face="Courier New">List&lt;int&gt;,</font> you
will get the <font face="Courier New">int[]</font> by default on the client.
</p>
        <p>
The main reason is that there is no representation for <font face="Courier New">System.Collections.Generic.List</font> or <font face="Courier New">System.Collection.Generic.LinkedList</font> in
service metadata. The concept of <font face="Courier New">System.Collection.Generic.List&lt;int&gt;</font> for
example, actually does not have a different semantic meaning from an <em>integer array</em> -
it's still a list of <em>ints</em> - but will allow you to program against it with
ease.
</p>
        <p>
Though, if one asks nicely, <strong>it is possible</strong> to guarantee the preferred
collection type on the client proxy in certain scenarios.
</p>
        <p>
Unidimensional collections, like <font face="Courier New">List&lt;T&gt;</font>, <font face="Courier New">LinkedList&lt;T&gt;</font> or <font face="Courier New">SortedList&lt;T&gt;</font> are
always exposed as <font face="Courier New">T</font> arrays in the client proxy. <font face="Courier New">Dictionary&lt;K,
V&gt;</font>, though, is regened on the client via an annotation hint in WSDL (XSD
if we are precise). More on that later.
</p>
        <p>
Let's look into it.
</p>
        <p>
WCF infrastructure bends over backwards to simplify client development. If the service
side contains a really serializable collection (marked with <font face="Courier New">[Serializable]</font>,
not <font face="Courier New">[DataContract]</font>) that is also concrete (not an
interface), and has an <font face="Courier New">Add</font> method with the following
signatures...
</p>
        <p>
          <font face="Courier New">public void Add(object obj);<br />
public void Add(T item); </font>
        </p>
        <p>
... then WCF will serialize the data to an array of the collections type.
</p>
        <p>
Too complicated? Consider the following:
</p>
        <p>
          <font face="Courier New">[ServiceContract]<br />
interface ICollect<br />
{<br />
   [OperationContract]<br />
   public void AddCoin(Coin coin);</font>
        </p>
        <p>
          <font face="Courier New">   [OperationContract]<br />
   public List&lt;Coin&gt; GetCoins();<br />
}</font>
        </p>
        <p>
Since the <font face="Courier New">List&lt;T&gt;</font> supports a <font face="Courier New">void
Add&lt;T&gt;</font> method and is marked with <font face="Courier New">[Serializable]</font>,
the following wire representation will be passed to the client:
</p>
        <p>
          <font face="Courier New">[ServiceContract]<br />
interface ICollect<br />
{<br />
  [OperationContract]<br />
  void AddCoin(Coin coin);</font>
        </p>
        <p>
          <font face="Courier New">  [OperationContract]<br />
  Coin[] GetCoins();<br />
}<br /></font>
          <font size="1">
            <br />
Note: <font face="Courier New">Coin</font> class should be marked either with a <font face="Courier New">[DataContract]</font> or <font face="Courier New">[Serializable]</font> in
this case.</font>
        </p>
        <p>
So what happens if one wants the same contract <em>on the client proxy and the service</em>?
There is an option in the WCF proxy generator, <font face="Courier New">svcutil.exe</font> to
force generation of class definitions with a specific collection type.
</p>
        <p>
Use the following for <font face="Courier New">List&lt;T&gt;</font>:
</p>
        <p>
          <font face="Courier New">svcutil.exe http://service/metadata/address<br />
  /collectionType:System.Collections.Generic.List`1<br /><br /></font>
          <font size="1">Note: <font face="Courier New">List`1</font> uses back quote,
not normal single quote character.</font>
        </p>
        <p>
What the <font face="Courier New">/collectionType</font> (short <font face="Courier New">/ct</font>)
does, is forces generation of strongly typed collection types. It will generate the
holy grail on the client:
</p>
        <p>
          <font face="Courier New">[ServiceContract]<br />
interface ICollect<br />
{<br />
  [OperationContract]<br />
  void AddCoin(Coin coin);</font>
        </p>
        <p>
          <font face="Courier New">  [OperationContract]<br />
  List&lt;Coin&gt; GetCoins();<br />
}</font>
        </p>
        <p>
In Visual Studio 2008, you will even have an option to specify which types you want
to use as <em>collection types</em> and <em>dictionary collection types</em>, as in
the following picture:
</p>
        <p>
          <img src="http://www.request-response.com/blog/images/vs2008servicereference.jpg" />
        </p>
        <p>
On the other hand, dictionary collections, as in <font face="Courier New">System.Collections.Generic.Dictionary&lt;K,
V&gt;</font> collections, will go through to the client no matter what you specify
as a <font face="Courier New">/ct</font> parameter (or don't at all).
</p>
        <p>
If you define the following on the service side...
</p>
        <p>
          <font face="Courier New">[OperationContract]<br />
Dictionary&lt;string, int&gt; GetFoo();</font>
        </p>
        <p>
... this will get generated on the client:
</p>
        <p>
          <font face="Courier New">[OperationContract]<br />
Dictionary&lt;string, int&gt; GetFoo();</font>
        </p>
        <p>
          <strong>Why?</strong>
        </p>
        <p>
Because using <font face="Courier New">System.Collections.Generic.Dictionary</font> probably
means <strong>you</strong> know there is no guarantee that client side representation
will be possible if you are using an alternative platform. There is no way to meaningfully
convey the semantics of a .NET dictionary class using WSDL/XSD. 
</p>
        <p>
          <strong>So, how does the client know?</strong>
        </p>
        <p>
In fact, the values are serialized as <strong>joined name value pair elements</strong> as
the following schema says:
</p>
        <p>
          <font face="Courier New">&lt;xs:complexType name="ArrayOfKeyValueOfstringint"&gt;<br /><font color="#a52a2a">  &lt;xs:annotation&gt;<br />
    &lt;xs:appinfo&gt;<br />
      &lt;IsDictionary<br />
        xmlns="</font></font>
          <font face="Courier New" color="#a52a2a">http://schemas.microsoft.com/2003/10/Serialization/</font>
          <font face="Courier New">
            <font color="#a52a2a">"&gt;<br />
        true<br />
      &lt;/IsDictionary&gt; 
<br />
    &lt;/xs:appinfo&gt;<br />
  &lt;/xs:annotation&gt;<br /></font>  &lt;xs:sequence&gt;<br />
    &lt;xs:element minOccurs="0" maxOccurs="unbounded"<br />
      name="KeyValueOfstringint"&gt;<br />
      &lt;xs:complexType&gt;<br />
        &lt;xs:sequence&gt;<br />
          &lt;xs:element name="Key" nillable="true"
type="xs:string" /&gt; 
<br />
          &lt;xs:element name="Value"
type="xs:int" /&gt; 
<br />
        &lt;/xs:sequence&gt;<br />
      &lt;/xs:complexType&gt;<br />
    &lt;/xs:element&gt;<br />
  &lt;/xs:sequence&gt;<br />
&lt;/xs:complexType&gt;<br />
&lt;xs:element name="ArrayOfKeyValueOfstringint"<br />
  nillable="true" type="tns:ArrayOfKeyValueOfstringint" /&gt;<br /><br /></font>
          <font size="1">Note: You can find this schema under <font face="Courier New">types</font> definition
of the metadata endpoint. Usually <font face="Courier New">?xsd=xsd2</font>, instead
of <font face="Courier New">?wsdl</font> will suffice.</font>
        </p>
        <p>
As in:
</p>
        <p>
          <font face="Courier New">&lt;GetFooResponse&gt;<br />
  &lt;KeyValueOfstringint&gt;<br />
    &lt;Key&gt;one&lt;/Key&gt;<br />
    &lt;Value&gt;1&lt;/Value&gt;</font>
        </p>
        <p>
          <font face="Courier New">    &lt;Key&gt;two&lt;/Key&gt;<br />
    &lt;Value&gt;2&lt;/Value&gt;</font>
        </p>
        <p>
          <font face="Courier New">    &lt;!-- ... --&gt;</font>
        </p>
        <p>
          <font face="Courier New">    &lt;Key&gt;N&lt;/Key&gt;<br />
    &lt;Value&gt;N&lt;/Value&gt;<br />
  &lt;/KeyValueOfstringint&gt;<br />
&lt;GetFooResponse&gt;</font>
        </p>
        <p>
The meaningful part of type service-to-client-transportation resides in <font face="Courier New">&lt;xs:annotation&gt;</font> element,
specifically in <font face="Courier New">/xs:annotation/xs:appinfo/IsDictionary</font> element,
which defines that this complex type represents a <font face="Courier New">System.Collections.Generic.Dictionary</font> class. <a href="http://www.w3.org/TR/xmlschema-0/#CommVers">Annotation</a> elements
in XML Schema are parser specific and do not convey any structure/data type semantics,
but are there <em>for the receiver to interpret</em>.
</p>
        <p>
This must be one of the <strong>most excellent school cases</strong> of using XML
Schema <a href="http://www.w3.org/TR/xmlschema-0/#CommVers">annotations</a>. It allows
the well-informed client (as in .NET client, VS 2008 or <font face="Courier New">svcutil.exe</font>)
to utilize the semantic meaning if it understands it. If not, no harm is done since
the best possible representation, in a form of joined name value pairs still goes
through to the client.
</p>
        <img width="0" height="0" src="http://www.request-response.com/blog/aggbug.ashx?id=ff5fab81-affb-4b2b-aa67-c80bdfc86cbd" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Approaches to Document Style Parameter Models</title>
    <link rel="alternate" type="text/html" href="http://www.request-response.com/blog/PermaLink,guid,ab874bc2-1546-48d1-a8aa-46f0bf876d93.aspx" />
    <id>http://www.request-response.com/blog/PermaLink,guid,ab874bc2-1546-48d1-a8aa-46f0bf876d93.aspx</id>
    <published>2007-09-24T12:19:10.09375+02:00</published>
    <updated>2007-09-24T12:19:10.09375+02:00</updated>
    <category term=".NET 3.0 - WCF" label=".NET 3.0 - WCF" scheme="http://www.request-response.com/blog/CategoryView,category,NET30WCF.aspx" />
    <category term=".NET 3.5 - WCF" label=".NET 3.5 - WCF" scheme="http://www.request-response.com/blog/CategoryView,category,NET35WCF.aspx" />
    <category term="Architecture" label="Architecture" scheme="http://www.request-response.com/blog/CategoryView,category,Architecture.aspx" />
    <category term="Web Services" label="Web Services" scheme="http://www.request-response.com/blog/CategoryView,category,WebServices.aspx" />
    <category term="XML" label="XML" scheme="http://www.request-response.com/blog/CategoryView,category,XML.aspx" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
I'm a huge fan of document style parameter models when implementing a public, programmatic <a href="http://en.wikipedia.org/wiki/Facade_pattern">façade</a> to
a business functionality that often changes.
</p>
        <p>
          <font face="Courier New">public interface IDocumentParameterModel<br />
{<br />
   [OperationContract]<br />
   [FaultContract(typeof(XmlInvalidException))]<br />
   XmlDocument Process(XmlDocument doc);<br />
}</font>
        </p>
        <p>
This contract defines a simple method, called <font face="Courier New">Process</font>,
which processes the input document. The idea is to define the <a href="http://www.w3.org/TR/xmlschema-1/">document
schema</a> and validate inbound XML documents, while throwing exceptions on <em>validation
errors</em>. The processing semantics is arbitrary and can support any kind of action,
depending on the defined <em>invoke document </em>schema.
</p>
        <p>
A simple instance document which validates against a version 1.0 <em>processing schema</em> could
look like this:
</p>
        <p>
          <font face="Courier New">&lt;?xml version="1.0?&gt;<br />
&lt;Process xmlns="http://www.gama-system.com/process10.xsd" version="1.0"&gt;<br />
   &lt;Instruction&gt;Add&lt;/Instruction&gt;<br />
   &lt;Parameter1&gt;10&lt;/Parameter1&gt;<br />
   &lt;Parameter2&gt;21&lt;/Parameter2&gt;<br />
&lt;/Process&gt;</font>
        </p>
        <p>
Another processing instruction, supported in version 1.1 of the <em>processing schema</em>,
with different semantics could be:
</p>
        <p>
          <font face="Courier New">&lt;?xml version="1.0?&gt;<br />
&lt;Process xmlns="http://www.gama-system.com/process11.xsd" version="1.1"&gt;<br />
   &lt;Instruction&gt;Store&lt;/Instruction&gt;<br />
   &lt;Content&gt;77u/PEFwcGxpY2F0aW9uIHhtbG5zPSJod...mdVcCI&lt;/Content&gt;<br />
&lt;/Process&gt;</font>
        </p>
        <p>
Note that the default XML namespace changed, but that is <strong>not a norm</strong>.
It only allows you to automate schema retrieval using the schema repository (think <font face="Courier New">System.Xml.Schema.XmlSchemaSet</font>),
load all supported schemas and validate automatically.
</p>
        <p>
          <font face="Courier New">public class ProcessService : IDocumentParameterModel<br />
{<br />
   public XmlDocument Process(XmlDocument doc)<br />
   {<br />
      XmlReaderSettings sett = new XmlReaderSettings();</font>
        </p>
        <p>
          <font face="Courier New">
            <strong>      sett.Schemas.Add(&lt;document
namespace 1&gt;, &lt;schema uri 1&gt;);<br />
      ...<br />
      sett.Schemas.Add(&lt;document namespace n&gt;, &lt;schema
uri n&gt;);</strong>
          </font>
        </p>
        <p>
          <font face="Courier New">      sett.ValidationType = ValidationType.Schema;<br />
      sett.ValidationEventHandler += new 
<br />
         ValidationEventHandler(XmlInvalidHandler);<br /></font>
          <font face="Courier New">      XmlReader books = XmlReader.Create(doc.OuterXml,
sett);<br /></font>
          <font face="Courier New">      while (books.Read())
{ }</font>
        </p>
        <p>
          <font face="Courier New">      // processing goes here<br />
      ...<br />
   }</font>
        </p>
        <p>
          <font face="Courier New">   static void XmlInvalidHandler(object sender,
ValidationEventArgs e)<br />
   {<br />
      if (e.Severity == XmlSeverityType.Error)<br />
         throw new XmlInvalidException(e.Message);<br />
   }<br />
}</font>
        </p>
        <p>
The main benefit of this approach is <em>decoupling</em> the parameter model and method
processing version from the <em>communication contract</em>. A service maintainer
has an option to change the terms of processing over time, while supporting older
version-aware document instances.
</p>
        <p>
This notion is of course most beneficial in situations where your processing syntax <strong>changes
frequently</strong> and has complex validation schemas. A simple case presented here
is informational only.
</p>
        <p>
So, how do we validate?
</p>
        <ul>
          <li>
We need to check the instance document version first. This is especially true in cases
where the document is <em>not qualified with a different namespace</em> when the version
changes.</li>
          <li>
We grab the appropriate schema or schema set</li>
          <li>
We validate the inbound XML document, throw a typed <font face="Courier New">XmlInvalidException</font> if
invalid</li>
          <li>
We process the call</li>
        </ul>
        <p>
The service side is quite straightforward.
</p>
        <p>
Let's look at the <strong>client</strong> and what are the options for painless generation
of service calls using this mechanism.
</p>
        <p>
Generally, one can always produce an instance <em>invoke document</em> by hand on
the client. <em>By hand</em> meaning using <font face="Courier New">System.Xml</font> classes
and DOM concepts. Since this is higly error prone and gets tedious with increasing
complexity, there is a notion of a schema compiler, which automatically translates
your XML Schema into the CLR type system. <font face="Courier New">Xsd.exe</font> and <font face="Courier New">XmlSerializer</font> are
your friends. 
</p>
        <p>
If your schema requires parts of the instance document to be digitally signed or encrypted,
you will need to adorn the serializer output with some manual DOM work. This might
also be a reason to use the third option.
</p>
        <p>
The third, and easiest option for the general developer, is to provide a <strong>local
object model</strong>, which serializes the requests on the client. This is an example:
</p>
        <p>
          <font face="Courier New">ProcessInstruction pi = new ProcessInstruction();<br />
pi.Instruction = "Add";<br />
pi.Parameter1 = 10;<br />
pi.Parameter2 = 21;<br />
pi.Sign(cert); // pi.Encrypt(cert);<br />
pi.Serialize();<br />
proxy.Process(pi.SerializedForm);</font>
        </p>
        <p>
The main benefit of this approach comes down to having an option on the server and
the client. Client developers have three different levels of complexity for generating
service calls. The model allows them to be as close to the wire as they see fit. Or
they can be abstracted completely from the wire representation if you provide a local
object model to access your services.
</p>
        <img width="0" height="0" src="http://www.request-response.com/blog/aggbug.ashx?id=ab874bc2-1546-48d1-a8aa-46f0bf876d93" />
      </div>
    </content>
  </entry>
  <entry>
    <title>XmlSerializer, Ambient XML Namespaces and Digital Signatures</title>
    <link rel="alternate" type="text/html" href="http://www.request-response.com/blog/PermaLink,guid,26149053-63bc-495e-bab0-8d14e7e46190.aspx" />
    <id>http://www.request-response.com/blog/PermaLink,guid,26149053-63bc-495e-bab0-8d14e7e46190.aspx</id>
    <published>2007-09-19T22:57:57.468+02:00</published>
    <updated>2007-09-20T09:57:43.3125+02:00</updated>
    <category term="CLR" label="CLR" scheme="http://www.request-response.com/blog/CategoryView,category,CLR.aspx" />
    <category term="XML" label="XML" scheme="http://www.request-response.com/blog/CategoryView,category,XML.aspx" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
If you use <font face="Courier New">XmlSerializer</font> type to perform serialization
of documents which are digitally signed later on, you should be <strong>careful</strong>.
</p>
        <p>
XML namespaces which are included in the serialized form could cause trouble for anyone
signing the document after serialization, especially in the case of normalized signature
checks.
</p>
        <p>
Let's go step by step.
</p>
        <p>
Suppose we have this simple schema, let's call it <font face="Courier New">problem.xsd</font>:
</p>
        <p>
          <font face="Courier New">&lt;?xml version="1.0" encoding="utf-8"?&gt;<br />
&lt;xs:schema targetNamespace="</font>
          <font face="Courier New">http://www.gama-system.com/problems.xsd</font>
          <font face="Courier New">" 
<br />
           elementFormDefault="qualified"<br />
           xmlns="</font>
          <font face="Courier New">http://www.gama-system.com/problems.xsd</font>
          <font face="Courier New">"<br />
           xmlns:xs="</font>
          <font face="Courier New">http://www.w3.org/2001/XMLSchema</font>
          <font face="Courier New">"&gt;<br />
  &lt;xs:element name="Problem" type="ProblemType"/&gt;<br />
  &lt;xs:complexType name="<font color="#a52a2a">ProblemType</font>"&gt;<br />
    &lt;xs:sequence&gt;<br />
      &lt;xs:element name="Name" type="xs:string" /&gt;<br />
      &lt;xs:element name="Severity" type="xs:int" /&gt;<br />
      &lt;xs:element name="Definition" type="DefinitionType"/&gt;<br />
      &lt;xs:element name="Description" type="xs:string"
/&gt;<br />
    &lt;/xs:sequence&gt;<br />
  &lt;/xs:complexType&gt;<br />
  &lt;xs:complexType name="<font color="#a52a2a">DefinitionType</font>"&gt;<br />
    &lt;xs:simpleContent&gt;<br />
      &lt;xs:extension base="xs:base64Binary"&gt;<br />
        &lt;xs:attribute name="Id" type="GUIDType"
use="required"/&gt;<br />
      &lt;/xs:extension&gt;<br />
    &lt;/xs:simpleContent&gt;<br />
  &lt;/xs:complexType&gt;<br />
  &lt;xs:simpleType name="<font color="#a52a2a">GUIDType</font>"&gt;<br />
    &lt;xs:restriction base="xs:string"&gt;<br />
      &lt;xs:pattern value="Id-[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-<br />
                        
[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}"/&gt;<br />
    &lt;/xs:restriction&gt;<br />
  &lt;/xs:simpleType&gt;<br />
&lt;/xs:schema&gt;</font>
        </p>
        <p>
This schema describes <em>a problem</em>, which is defined by a <strong>name</strong> (typed
as <font face="Courier New">string</font>), <strong>severity</strong> (typed as <font face="Courier New">integer</font>), <strong>definition</strong> (typed
as <font face="Courier New">byte array</font>) and <strong>description</strong> (typed
as <font face="Courier New">string</font>). The schema also says that the definition
of a problem has an <font face="Courier New">Id</font> attribute, which we will use
when digitally signing a specific problem definition. This <font face="Courier New">Id</font> attribute
is defined as GUID, as the simple type <font face="Courier New">GUIDType</font> defines.
</p>
        <p>
Instance documents validating against this schema would look like this:
</p>
        <p>
          <font face="Courier New">&lt;?xml version="1.0"?&gt;<br />
&lt;Problem xmlns="</font>
          <font face="Courier New">http://www.gama-system.com/problems.xsd</font>
          <font face="Courier New">"&gt;<br />
  &lt;Name&gt;Specific problem&lt;/Name&gt;<br />
  &lt;Severity&gt;4&lt;/Severity&gt;<br />
  &lt;Definition Id="c31dd112-dd42-41da-c11d-33ff7d2112s2"&gt;MD1sDQ8=&lt;/Definition&gt;<br />
  &lt;Description&gt;This is a specific problem.&lt;/Description&gt;<br />
&lt;/Problem&gt;</font>
        </p>
        <p>
Or this:
</p>
        <p>
          <font face="Courier New">&lt;?xml version="1.0"?&gt;<br />
&lt;Problem xmlns="http://www.gama-system.com/problems.xsd"&gt;<br />
  &lt;Name&gt;XML DigSig Problem&lt;/Name&gt;<br />
  &lt;Severity&gt;5&lt;/Severity&gt;<br />
  &lt;Definition Id="b01cb152-cf93-48df-b07e-97ea7f2ec2e9"&gt;CgsMDQ8=&lt;/Definition&gt;<br />
  &lt;Description&gt;Ambient namespaces break digsigs.&lt;/Description&gt;<br />
&lt;/Problem&gt;</font>
        </p>
        <p>
Mark this one as <strong>exhibit A</strong>.
</p>
        <p>
Only a few of you out there are still generating XML documents by hand, since there
exists a notion of schema compilers. In the .NET Framework world, there is <font face="Courier New">xsd.exe</font>,
which bridges the gap between the XML type system and the CLR type system.
</p>
        <p>
          <font face="Courier New">xsd.exe /c problem.xsd</font>
        </p>
        <p>
The tool compiles <font face="Courier New">problem.xsd</font> schema into the CLR
type system. This allows you to use in-schema defined classes and serialize them later
on with the <font face="Courier New">XmlSerializer</font> class. The second instance
document (exhibit A) serialization program would look like this:
</p>
        <p>
          <font face="Courier New">// generate problem<br />
ProblemType problem = new ProblemType();<br />
problem.Name = "XML DigSig Problem";<br />
problem.Severity = 5;<br />
DefinitionType dt = new DefinitionType();<br />
dt.Id = Guid.NewGuid().ToString();<br />
dt.Value = new byte[] { 0xa, 0xb, 0xc, 0xd, 0xf };<br />
problem.Definition = dt;<br />
problem.Description = "Ambient namespaces break digsigs.";</font>
        </p>
        <p>
          <font face="Courier New">// serialize problem<br />
XmlSerializer ser = new XmlSerializer(typeof(ProblemType));<br />
FileStream stream = new FileStream("Problem.xml", FileMode.Create, FileAccess.Write);<br />
ser.Serialize(stream, problem);<br />
stream.Close();<br /></font>            
<br />
Here <strong>lie </strong>the dragons.
</p>
        <p>
          <font face="Courier New">XmlSerializer</font> class default serialization mechanism
would output this:
</p>
        <p>
          <font face="Courier New">&lt;?xml version="1.0"?&gt;<br />
&lt;Problem <font color="#a52a2a">xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"</font><br />
         <font color="#a52a2a">xmlns:xsd="http://www.w3.org/2001/XMLSchema"<br /></font><font color="#000000">         xmlns="http://www.gama-system.com/problems.xsd"&gt;</font><br />
  &lt;Name&gt;XML DigSig Problem&lt;/Name&gt;<br />
  &lt;Severity&gt;5&lt;/Severity&gt;<br />
  &lt;Definition Id="b01cb152-cf93-48df-b07e-97ea7f2ec2e9"&gt;CgsMDQ8=&lt;/Definition&gt;<br />
  &lt;Description&gt;Ambient namespaces break digsigs.&lt;/Description&gt;<br />
&lt;/Problem&gt;</font>
        </p>
        <p>
Mark this one as <strong>exhibit B</strong>.
</p>
        <p>
If you look closely, you will notice two additional prefix namespace declarations
in exhibit B bound to <font face="Courier New">xsi</font> and <font face="Courier New">xsd</font> prefixes,
against exhibit A.
</p>
        <p>
The fact is, that both documents (exhibit B, and exhibit A) are valid against the <font face="Courier New">problem.xsd</font> schema.
</p>
        <p dir="ltr" style="MARGIN-RIGHT: 0px">
          <font face="Courier New">&lt;theory&gt;</font>
        </p>
        <blockquote dir="ltr" style="MARGIN-RIGHT: 0px">
          <p dir="ltr" style="MARGIN-RIGHT: 0px">
Prefixed namespaces are part of the <a href="http://www.w3.org/TR/xml-infoset/">XML
Infoset</a>. All XML processing is done on XML Infoset level. Since only declarations
(look at prefixes <font face="Courier New">xsi</font> and <font face="Courier New">xsd</font>)
are made in exhibit B, the document itself is not semantically different from exhibit
A. That stated, instance documents are equivalent and should validate against the
same schema.
</p>
        </blockquote>
        <p dir="ltr" style="MARGIN-RIGHT: 0px">
          <font face="Courier New">&lt;/theory&gt;</font>
        </p>
        <p>
What happens if we sign the <font face="Courier New">Definition</font> element of
exhibit B (<font face="Courier New">XmlSerializer</font> generated, prefixed namespaces
present)?
</p>
        <p>
We get this:
</p>
        <p>
          <font face="Courier New">&lt;?xml version="1.0"?&gt;<br />
&lt;Problem <font color="#a52a2a">xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"</font><br />
         <font color="#a52a2a">xmlns:xsd="http://www.w3.org/2001/XMLSchema"<br /></font><font color="#000000">         xmlns="http://www.gama-system.com/problems.xsd"&gt;</font><br />
  &lt;Name&gt;XML DigSig Problem&lt;/Name&gt;<br />
  &lt;Severity&gt;5&lt;/Severity&gt;<br />
  &lt;Definition <font color="#a52a2a"><strong>Id="b01cb152-cf93-48df-b07e-97ea7f2ec2e9"</strong></font>&gt;CgsMDQ8=&lt;/Definition&gt;<br />
  &lt;Description&gt;Ambient namespaces break digsigs.&lt;/Description&gt;<br /><font color="#000000"><strong>  &lt;Signature xmlns="http://www.w3.org/2000/09/xmldsig#"&gt;<br />
    &lt;SignedInfo&gt;<br />
      &lt;CanonicalizationMethod Algorithm="http://www.w3.org/TR/...20010315"
/&gt;<br />
      &lt;SignatureMethod Algorithm="http://www.w3.org/...rsa-sha1"
/&gt;<br />
      &lt;Reference <font color="#a52a2a">URI="#Id-b01cb152-cf93-48df-b07e-97ea7f2ec2e9"&gt;</font><br />
        &lt;DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"
/&gt;<br />
        &lt;DigestValue&gt;k3gbdFVJEpv4LWJAvvHUZZo/VUQ=&lt;/DigestValue&gt;<br />
      &lt;/Reference&gt;<br />
    &lt;/SignedInfo&gt;<br />
    &lt;SignatureValue&gt;K8f...p14=&lt;/SignatureValue&gt;<br />
    &lt;KeyInfo&gt;<br />
      &lt;KeyValue&gt;<br />
        &lt;RSAKeyValue&gt;<br />
          &lt;Modulus&gt;eVs...rL4=&lt;/Modulus&gt;<br />
          &lt;Exponent&gt;AQAB&lt;/Exponent&gt;<br />
        &lt;/RSAKeyValue&gt;<br />
      &lt;/KeyValue&gt;<br />
      &lt;X509Data&gt;<br />
        &lt;X509Certificate&gt;MIIF...Bw==&lt;/X509Certificate&gt;<br />
      &lt;/X509Data&gt;<br />
    &lt;/KeyInfo&gt;<br />
  &lt;/Signature&gt;</strong><br /></font>&lt;/Problem&gt;</font>
        </p>
        <p>
Let's call this document <strong>exhibit D</strong>.
</p>
        <p>
This document is the same as exhibit B, but has the <font face="Courier New">Definition</font> element
digitally signed. Note the <font face="Courier New">/Problem/Signature/SingedInfo/Reference[@URI]</font> value.
Digital signature is performed only on the <font face="Courier New">Definition</font> element
and not the complete document.
</p>
        <p>
Now, if one would validate the same document without the prefixed namespace declarations,
as in:
</p>
        <p>
          <font face="Courier New">&lt;?xml version="1.0"?&gt;<br />
&lt;Problem xmlns="http://www.gama-system.com/problems.xsd"&gt;<br />
  &lt;Name&gt;XML DigSig Problem&lt;/Name&gt;<br />
  &lt;Severity&gt;5&lt;/Severity&gt;<br />
  &lt;Definition <strong>Id="b01cb152-cf93-48df-b07e-97ea7f2ec2e9"&gt;</strong>CgsMDQ8=&lt;/Definition&gt;<br />
  &lt;Description&gt;Ambient namespaces break digsigs.&lt;/Description&gt;<br /><strong>  &lt;Signature xmlns="http://www.w3.org/2000/09/xmldsig#"&gt;<br />
    ...<br />
  &lt;/Signature&gt;</strong><br />
&lt;/Problem&gt;</font>
        </p>
        <p>
... the signature verification <strong>would fail</strong>. Let's call this document <strong>exhibit
C</strong>.
</p>
        <p>
          <font face="Courier New">&lt;theory&gt;</font>
        </p>
        <blockquote dir="ltr" style="MARGIN-RIGHT: 0px">
          <p>
As said earlier, all XML processing is done on the XML Infoset level. Since ambient
prefixed namespace declarations are visible in all child elements of the declaring
element, exhibits C and D are different. Explicitly, element contexts are different
for element <font face="Courier New">Definition</font>, since exhibit C does not have
ambient declarations present and exhibit D does. The signature verification <strong>fails</strong>.
</p>
        </blockquote>
        <p>
          <font face="Courier New">&lt;/theory&gt;</font>
        </p>
        <p>
Solution?
</p>
        <p>
Much simpler than what's written above. Force <font face="Courier New">XmlSerializer</font> class
to serialize what should be serialized in the first place. We need to declare the
namespace definition of the serialized document and prevent <font face="Courier New">XmlSerializer</font> to
be too smart. The .NET Framework serialization mechanism contains a <font face="Courier New">XmlSerializerNamespaces</font> class
which can be specified during serialization process.
</p>
        <p>
Since we know the only (and by the way, default) namespace of the serialized document,
this makes things work out OK:
</p>
        <p>
          <font face="Courier New">// generate problem<br />
ProblemType problem = new ProblemType();<br />
problem.Name = "XML DigSig Problem";<br />
problem.Severity = 5;<br />
DefinitionType dt = new DefinitionType();<br />
dt.Id = Guid.NewGuid().ToString();<br />
dt.Value = new byte[] { 0xa, 0xb, 0xc, 0xd, 0xf };<br />
problem.Definition = dt;<br />
problem.Description = "Ambient namespaces break digsigs.";</font>
        </p>
        <p>
          <font face="Courier New">// serialize problem<br /><strong><font color="#a52a2a">XmlSerializerNamespaces xsn = new XmlSerializerNamespaces();<br />
xsn.Add(String.Empty, "http://www.gama-system.com/problem.xsd");</font></strong></font>
        </p>
        <p>
          <font face="Courier New">XmlSerializer ser = new XmlSerializer(typeof(ProblemType));<br />
FileStream stream = new FileStream("Problem.xml", FileMode.Create, FileAccess.Write);<br />
ser.Serialize(stream, problem, <strong><font color="#a52a2a">xsn</font></strong>);<br />
stream.Close();</font>
        </p>
        <p>
This will force <font face="Courier New">XmlSerializer</font> to produce a valid document
- with valid XML element contexts, without any ambient namespaces.
</p>
        <p>
The question is, why does <font face="Courier New">XmlSerialzer</font> produce this
namespaces by default? That should be a topic for another post.
</p>
        <img width="0" height="0" src="http://www.request-response.com/blog/aggbug.ashx?id=26149053-63bc-495e-bab0-8d14e7e46190" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Oh my God: 1.1</title>
    <link rel="alternate" type="text/html" href="http://www.request-response.com/blog/PermaLink,guid,d66f26c7-eb42-46f7-bd99-29b9a1062c9c.aspx" />
    <id>http://www.request-response.com/blog/PermaLink,guid,d66f26c7-eb42-46f7-bd99-29b9a1062c9c.aspx</id>
    <published>2007-08-29T18:40:16.15625+02:00</published>
    <updated>2007-08-29T18:40:16.15625+02:00</updated>
    <category term="Apple" label="Apple" scheme="http://www.request-response.com/blog/CategoryView,category,Apple.aspx" />
    <category term="Other" label="Other" scheme="http://www.request-response.com/blog/CategoryView,category,Other.aspx" />
    <category term="Personal" label="Personal" scheme="http://www.request-response.com/blog/CategoryView,category,Personal.aspx" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
Shame? Nokia?
</p>
        <p>
Same sentence, as in <a href="http://www.engadget.com/2007/08/29/nokias-iphone-no-seriously/">Shame and
Nokia</a>?
</p>
        <p>
There is just no pride in IT anymore. Backbones are long gone too.
</p>
        <img width="0" height="0" src="http://www.request-response.com/blog/aggbug.ashx?id=d66f26c7-eb42-46f7-bd99-29b9a1062c9c" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Oh my God: 1.0</title>
    <link rel="alternate" type="text/html" href="http://www.request-response.com/blog/PermaLink,guid,b01fbfe1-6db1-45ad-bf57-0c4dce869053.aspx" />
    <id>http://www.request-response.com/blog/PermaLink,guid,b01fbfe1-6db1-45ad-bf57-0c4dce869053.aspx</id>
    <published>2007-08-29T18:35:38.90625+02:00</published>
    <updated>2007-08-29T18:35:38.90625+02:00</updated>
    <category term="Other" label="Other" scheme="http://www.request-response.com/blog/CategoryView,category,Other.aspx" />
    <category term="Personal" label="Personal" scheme="http://www.request-response.com/blog/CategoryView,category,Personal.aspx" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
This <a href="http://vidmar.net/weblog/archive/2007/08/29/what-you-dont-want-to-see-when-you-open-your.aspx">post</a> puts
shame to a new level.
</p>
        <p>
There is no excuse for having Microsoft Access database serving <strong>any </strong>kind
of content in an online banking solution.
</p>
        <p>
The funny thing is, that even the comment excuses seem fragile. They obviously just
don't get it. The bank should not defend their position, but focus on changing it
immediately.
</p>
        <p>
So, they should fix this ASAP, then fire PR, then apologize.
</p>
        <p>
Well-done David, for exposing what should never reach a production environment. 
</p>
        <p>
Never. Ever.
</p>
        <img width="0" height="0" src="http://www.request-response.com/blog/aggbug.ashx?id=b01fbfe1-6db1-45ad-bf57-0c4dce869053" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Apple vs. Dell</title>
    <link rel="alternate" type="text/html" href="http://www.request-response.com/blog/PermaLink,guid,3bda30c6-654b-4d98-8788-d2eeeafe4943.aspx" />
    <id>http://www.request-response.com/blog/PermaLink,guid,3bda30c6-654b-4d98-8788-d2eeeafe4943.aspx</id>
    <published>2007-08-08T20:37:18.97+02:00</published>
    <updated>2007-08-08T20:40:54.627+02:00</updated>
    <category term="Apple" label="Apple" scheme="http://www.request-response.com/blog/CategoryView,category,Apple.aspx" />
    <category term="Personal" label="Personal" scheme="http://www.request-response.com/blog/CategoryView,category,Personal.aspx" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
This is why one should buy best of both worlds. Mac <strong>rules</strong> on a client.
Dell is quite competitive on the (home) server market.
</p>
        <p>
We don't care about cables around servers. Yet.
</p>
        <p>
          <img src="http://www.request-response.com/blog/images/applevsdell.jpg" />
        </p>
        <p>
So? <a href="http://www.apple.com/imac">'nuff said</a>.
</p>
        <img width="0" height="0" src="http://www.request-response.com/blog/aggbug.ashx?id=3bda30c6-654b-4d98-8788-d2eeeafe4943" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Windows Vista Performance and Reliability Updates</title>
    <link rel="alternate" type="text/html" href="http://www.request-response.com/blog/PermaLink,guid,3bb7bfca-61a4-40de-863f-5e8114cd8f9f.aspx" />
    <id>http://www.request-response.com/blog/PermaLink,guid,3bb7bfca-61a4-40de-863f-5e8114cd8f9f.aspx</id>
    <published>2007-08-08T08:13:20.455+02:00</published>
    <updated>2007-08-08T08:22:14.97075+02:00</updated>
    <category term="Windows Vista" label="Windows Vista" scheme="http://www.request-response.com/blog/CategoryView,category,WindowsVista.aspx" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
These have been brewing for a couple of months. They're out today.
</p>
        <blockquote dir="ltr" style="MARGIN-RIGHT: 0px">
          <blockquote dir="ltr" style="MARGIN-RIGHT: 0px">
            <blockquote dir="ltr" style="MARGIN-RIGHT: 0px">
              <p>
                <img src="http://www.request-response.com/blog/images/vista_logo_small_fixed.jpg" />
              </p>
            </blockquote>
          </blockquote>
        </blockquote>
        <p>
They contain a number of patches that <strike>improve</strike> fix Vista. You
can get them here:
</p>
        <p>
          <a href="http://support.microsoft.com/?kbid=938979" target="_blank">Windows Vista
Performance Update</a>:
</p>
        <ul>
          <li>
            <a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=3FB80BB9-D832-425B-B42C-D3EB2071BBEC" target="_blank">x86
Download</a>
          </li>
          <li>
            <a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=24EAD3A0-77F6-4196-8A3F-78C1470AC18E" target="_blank">x64
Download</a>
          </li>
        </ul>
        <p>
          <a href="http://support.microsoft.com/?kbid=938194" target="_blank">Windows Vista
Reliability Update</a>:
</p>
        <ul>
          <li>
            <a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=AE2F819D-C33D-48DB-A7E3-62EEF7C1F7C2" target="_blank">x86
Download</a>
          </li>
          <li>
            <a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=5B7F1544-FEF3-4C80-AF1A-8B732DCB2756" target="_blank">x64
Download</a>
          </li>
        </ul>
        <p>
Go get them. Now.
</p>
        <img width="0" height="0" src="http://www.request-response.com/blog/aggbug.ashx?id=3bb7bfca-61a4-40de-863f-5e8114cd8f9f" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Midyear Reader Profile</title>
    <link rel="alternate" type="text/html" href="http://www.request-response.com/blog/PermaLink,guid,0f69303d-0a93-4d04-a7de-d76208f4b77c.aspx" />
    <id>http://www.request-response.com/blog/PermaLink,guid,0f69303d-0a93-4d04-a7de-d76208f4b77c.aspx</id>
    <published>2007-07-26T22:58:25.203125+02:00</published>
    <updated>2007-07-26T22:58:25.203125+02:00</updated>
    <category term="Blogging" label="Blogging" scheme="http://www.request-response.com/blog/CategoryView,category,Blogging.aspx" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
Since it's summer here in Europe, and thus roughly middle of the year, here comes
your, Dear Reader, profile. 
</p>
        <p>
Mind you, only last years data (June 2006 - June 2007) is included, according to <a href="http://www.google.com/analytics">Google
Analytics</a>.
</p>
        <p>
          <strong>Browser Versions:</strong>
          <br />
          <br />
          <img src="http://www.request-response.com/blog/images/readerprofile2007_1.jpg" />
        </p>
        <p>
          <strong>Operating Systems:<br /></strong>
          <br />
          <img src="http://www.request-response.com/blog/images/readerprofile2007_2.jpg" />
        </p>
        <p>
          <strong>Browser Versions and Operating Systems:</strong>
          <br />
          <br />
          <img src="http://www.request-response.com/blog/images/readerprofile2007_3.jpg" />
        </p>
        <p>
          <strong>Screen Resolutions:<br /><br /><img src="http://www.request-response.com/blog/images/readerprofile2007_4.jpg" /></strong>
        </p>
        <p>
          <strong>Adobe Flash Support:</strong>
          <br />
          <br />
          <img src="http://www.request-response.com/blog/images/readerprofile2007_5.jpg" />
        </p>
        <p>
          <strong>And finally, most strangely, Java Support:</strong>
          <br />
          <br />
          <img src="http://www.request-response.com/blog/images/readerprofile2007_6.jpg" />
        </p>
        <p>
The last one surprised me.
</p>
        <img width="0" height="0" src="http://www.request-response.com/blog/aggbug.ashx?id=0f69303d-0a93-4d04-a7de-d76208f4b77c" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Managed TxF: Distributed Transactions and Transactional NTFS</title>
    <link rel="alternate" type="text/html" href="http://www.request-response.com/blog/PermaLink,guid,bca19fa8-7ba8-43d8-873e-3a8cf03335cb.aspx" />
    <id>http://www.request-response.com/blog/PermaLink,guid,bca19fa8-7ba8-43d8-873e-3a8cf03335cb.aspx</id>
    <published>2007-07-23T22:54:13.156+02:00</published>
    <updated>2007-07-24T09:21:23.75+02:00</updated>
    <category term=".NET 3.5 - WCF" label=".NET 3.5 - WCF" scheme="http://www.request-response.com/blog/CategoryView,category,NET35WCF.aspx" />
    <category term="Transactions" label="Transactions" scheme="http://www.request-response.com/blog/CategoryView,category,Transactions.aspx" />
    <category term="Web Services" label="Web Services" scheme="http://www.request-response.com/blog/CategoryView,category,WebServices.aspx" />
    <category term="Windows Vista" label="Windows Vista" scheme="http://www.request-response.com/blog/CategoryView,category,WindowsVista.aspx" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
Based on my <a href="http://www.request-response.com/blog/PermaLink,guid,c421ff72-d5bc-4b5f-8c52-ed5e73e8dd00.aspx">previous
post</a>, I managed to get <strong>distributed transaction</strong> scenario
working using <a href="http://wcf.netfx3.com/">WCF</a>, <a href="http://www.w3.org/TR/soap12-mtom/">MTOM</a> and <a href="http://www.ibm.com/developerworks/library/specification/ws-tx/">WS-AtomicTransactions</a>.
</p>
        <p>
This means that you have the option to transport <em>arbitrary files</em>, using transactional <strong>ACID</strong> semantics,
from the client, over HTTP and MTOM.
</p>
        <p>
The idea is to integrate a distributed transaction with <a href="http://msdn2.microsoft.com/En-US/library/aa365456.aspx">TxF</a>,
or NTFS file system transaction. This only works on Windows Server 2008 (Longhorn
Server) and Windows Vista. 
</p>
        <p>
Download: <a href="http://www.request-response.com/blog/content/binary/txf_wcf.zip">Sample
code</a></p>
        <p>
If the client starts a transaction then <em>all files</em> within it should be stored
on the server. If something fails or client does not commit, <em>no harm is done</em>.
The beauty of this is that it's all seamlessly integrated into the current communication/OS
stack.
</p>
        <p>
This is <strong>shipping technology</strong>; you just have to dive a little deeper
to use it.
</p>
        <p>
Here's the scenario:<br /><br /><img src="http://www.request-response.com/blog/images/txf_wcf1.jpg" /></p>
        <p>
There are a couple of issues that need to be addressed before we move to the implementation:
</p>
        <ul>
          <li>
            <strong>You should use the managed wrapper included <a href="http://www.request-response.com/blog/content/binary/txf_wcf.zip">here</a><br /></strong>There is support for <font face="Courier New">TransactedFile</font> and <font face="Courier New">TransactedDirectory</font> built
it. Next version of <a href="http://msdn2.microsoft.com/en-us/library/ms756482.aspx">VistaBridge</a> samples
will include an updated version of this wrapper.<br /><br /></li>
          <li>
            <strong>Limited distributed transactions support on a system drive<br /></strong>There is no way to get DTC a superior access coordinator<em></em>role for <a href="http://msdn2.microsoft.com/En-US/library/aa365456.aspx">TxF</a> on
the system drive (think <font face="Courier New">c:\</font> system drive). This is
a major downside in the current implementation of <a href="http://msdn2.microsoft.com/En-US/library/aa365456.aspx">TxF</a>,
since I would prefer that system/boot files would be transaction-locked anyway. You
have two options if you want to run the <a href="http://www.request-response.com/blog/content/binary/txf_wcf.zip">following
sample</a>:<br /><br /><ul><li><strong>Define secondary resource manager for your directory</strong><br />
This allows system drive resource manager to still protect system files, but creates
a secondary resource manager for the specified directory. Do this: 
<ul><li><font face="Courier New">fsutil resource create c:\txf</font></li><li><font face="Courier New">fsutil resource start c:\txf<br /></font>You can query your new secondary resource manager by <font face="Courier New">fsutil
resource info c:\txf</font>.<br /><br /></li></ul></li><li><strong>Use another partition<br /></strong>Any partition outside the system partition is ok. You cannot use network
shares, but <em>USB keys will work</em>. Plug it in and change the paths as defined
at the end of this post.</li></ul></li>
        </ul>
        <p>
OK, here we go.
</p>
        <p>
Here's the service contract:
</p>
        <p>
          <font face="Courier New">[ServiceContract(SessionMode = SessionMode.Allowed)]<br />
interface ITransportFiles<br />
{<br />
   [OperationContract]<br />
   [TransactionFlow(TransactionFlowOption.Allowed)]<br />
   byte[] GetFile(string name);</font>
        </p>
        <p>
          <font face="Courier New">   [OperationContract]<br />
   [TransactionFlow(TransactionFlowOption.Allowed)]<br />
   void PutFile(byte[] data, string name);<br />
} </font>
        </p>
        <p>
We allow the sessionful binding (it's not <em>required</em>, though) and allow transactions
to flow from the client side. Again, transactions are not <em>mandatory</em>, since
client may opt-out of using them and just transport files without a transaction.
</p>
        <p>
The provided transport mechanism uses <a href="http://www.w3.org/TR/soap12-mtom/">MTOM</a>,
since the contract's parameter model is appropriate for it and because it's much more
effective transferring binary data.
</p>
        <p>
So here's the service config:
</p>
        <p>
          <font face="Courier New">&lt;system.serviceModel&gt;<br />
  &lt;bindings&gt;<br />
    &lt;wsHttpBinding&gt;<br /><strong>      &lt;binding name="MTOMBinding"<br />
          transactionFlow="true"<br />
          messageEncoding="Mtom"<br />
          maxReceivedMessageSize="10485760"&gt;<br />
        &lt;readerQuotas maxArrayLength="10485760"/&gt;</strong><br />
      &lt;/binding&gt;<br />
    &lt;/wsHttpBinding&gt;<br />
  &lt;/bindings&gt;<br />
  &lt;services&gt;<br />
    &lt;service name="WCFService.TransportService"&gt;<br />
      &lt;host&gt;<br />
        &lt;baseAddresses&gt;<br />
          &lt;add baseAddress="</font>
          <font face="Courier New">http://localhost:555/transportservice"</font>
          <font face="Courier New">&gt;<br />
        &lt;/baseAddresses&gt;<br />
      &lt;/host&gt;<br />
      &lt;endpoint address=""<br />
          binding="wsHttpBinding"<br /><strong>          bindingConfiguration="MTOMBinding"<br /></strong>          contract="WCFService.ITransportFiles"/&gt;<br />
    &lt;/service&gt;<br />
  &lt;/services&gt;<br />
&lt;/system.serviceModel&gt;</font>
        </p>
        <p>
Here, <font face="Courier New">MTOMBinding</font> is being used to specify <a href="http://www.w3.org/TR/soap12-mtom/">MTOM</a> wire
encoding. Also, quotas and <font face="Courier New">maxReceivedMessageSize</font> attribute
is being adjusted to 10 MB, since we are probably transferring larger binary files.
</p>
        <p>
Service implementation is straight forward:
</p>
        <p>
          <font face="Courier New">[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall)]<br />
class TransportService : ITransportFiles<br />
{<br />
    [OperationBehavior(TransactionScopeRequired = true)]<br /><strong>    public byte[] GetFile(string name)<br /></strong>    {<br />
        Console.WriteLine("GetFile: {0}", name);<br />
        Console.WriteLine("Distributed Tx ID: {0}",<br />
          Transaction.Current.TransactionInformation.DistributedIdentifier);<br />
        return ReadFully(TransactedFile.Open(@"C:\TxF\Service\"
+ name,<br />
          FileMode.Open, FileAccess.Read,
FileShare.Read), 0);<br />
    }</font>
        </p>
        <p>
          <font face="Courier New">    [OperationBehavior(TransactionScopeRequired
= true)]<br /><strong>    public void PutFile(byte[] data, string filename)<br /></strong>    {<br />
        Console.WriteLine("PutFile: {0}", filename);<br />
        Console.WriteLine("Distributed Tx ID: {0}",<br />
          Transaction.Current.TransactionInformation.DistributedIdentifier);</font>
        </p>
        <p>
          <font face="Courier New">        using (BinaryWriter
bw = new BinaryWriter(<br />
            TransactedFile.Open(@"C:\TxF\Service\"
+ filename,<br />
              FileMode.Create,
FileAccess.Write, FileShare.Write)))<br />
        {<br />
            bw.Write(data,
0, data.Length);<br />
            
<br />
            // clean up<br />
            bw.Flush();<br />
        }<br />
    }<br />
}</font>
        </p>
        <p>
Client does four things:
</p>
        <ol>
          <li>
Sends three files (client - server) - no transaction 
</li>
          <li>
Gets three files (server - client) - no transaction 
</li>
          <li>
Sends three files (client - server) - distributed transaction, all or nothing 
</li>
          <li>
Gets three files (server - client) - distributed transaction, all or nothing</li>
        </ol>
        <p>
Before you run:
</p>
        <ul>
          <li>
Decide on the secondary resource manager option (system drive, enable it using <font face="Courier New">fsutil.exe</font>)
or use another partition (USB key) 
</li>
          <li>
Change the paths to your scenario. The sample uses <font face="Courier New">C:\TxF</font>, <font face="Courier New">C:\TxF\Service</font> and <font face="Courier New">C:\TxF\Client</font> and
a secondary resource manager. Create these directories before running the sample.</li>
        </ul>
        <p>
Download: <a href="http://www.request-response.com/blog/content/binary/txf_wcf.zip">Sample
code</a></p>
        <p>
          <font color="#a9a9a9" size="1">This sample is provided without any warranty. It's
a sample, so don't use it in production environments.</font>
        </p>
        <img width="0" height="0" src="http://www.request-response.com/blog/aggbug.ashx?id=bca19fa8-7ba8-43d8-873e-3a8cf03335cb" />
      </div>
    </content>
  </entry>
  <entry>
    <title>WS-Management: Windows Vista and Windows Server 2008</title>
    <link rel="alternate" type="text/html" href="http://www.request-response.com/blog/PermaLink,guid,e4ad0d8c-6fb6-40b8-9b52-7ab9092ccc7c.aspx" />
    <id>http://www.request-response.com/blog/PermaLink,guid,e4ad0d8c-6fb6-40b8-9b52-7ab9092ccc7c.aspx</id>
    <published>2007-07-22T20:48:22.421+02:00</published>
    <updated>2007-07-22T21:01:09.078125+02:00</updated>
    <category term="Web Services" label="Web Services" scheme="http://www.request-response.com/blog/CategoryView,category,WebServices.aspx" />
    <category term="Windows Vista" label="Windows Vista" scheme="http://www.request-response.com/blog/CategoryView,category,WindowsVista.aspx" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
I dived into <a href="http://specs.xmlsoap.org/ws/2005/06/management/ws-management.pdf">WS-Management</a> support
in Vista / <strike>Longhorn Server</strike> Windows Server 2008 this weekend. There
are a couple of caveats if you want to enable remote WS-Management based access to
these machines. Support for remote management is also built into Windows Server 2003 <strong>R2</strong>.
</p>
        <p>
WS-Management specification allows remote access to any resource that implements the
specification. Everything accessed in a WS-Management world is a resource, which is
identifiable by a URI. The spec uses WS-Eventing, WS-Enumeration, WS-Transfer and
SOAP 1.2 via HTTP.
</p>
        <p>
Since remote management implementation in Windows acknowledges all the work done in
the <a href="http://www.microsoft.com/whdc/system/pnppwr/wmi/default.mspx">WMI</a> space,
you can simply issue commands in terms of URIs that incorporate WMI namespaces.
</p>
        <p>
          <img src="http://www.request-response.com/blog/images/ws-management1.jpg" />
        </p>
        <p>
For example, the WMI class or action (method) is identified by a URI, just as any
other WS-Management based resource. You can construct access to any WMI class / action
using the following semantics:
</p>
        <ul>
          <li>
            <font face="Courier New">http://schemas.microsoft.com/wbem/wsman/1/wmi</font> denotes
a <strong>default WMI namespace</strong> accessible via WS-Management 
</li>
          <li>
            <font face="Courier New">http://schemas.microsoft.com/wbem/wsman/1/wmi/root/default</font> denotes
access to <font face="Courier New"><strong>root/default</strong></font> namespace</li>
        </ul>
        <p>
Since the majority of WMI classes are in <font face="Courier New">root/cimv2</font> namespace,
you should use the following URI to access those:
</p>
        <p>
          <font face="Courier New">http://schemas.microsoft.com/wbem/wsman/1/wmi/root/cimv2</font>
        </p>
        <p>
OK, back to WS-Management and its implementation in Vista / Windows Server 2008.
</p>
        <p>
First, Windows Server 2008 has the <strong>Windows Remote Management</strong> service
started up by default. Vista doesn't. So <em>start it up</em>, if you're on a Vista
box.
</p>
        <p>
Second, depending on your network configuration, if you're in a workgroup environment
(not joined to a domain) you should tell your client to <em>trust the server side</em>.
</p>
        <p>
Trusting the server side involves executing a command on a client. Remote management
tools included in Windows Server 2008 / Windows Vista are capable of configuring the
local machine and issuing commands to remote machine. There are basically two
tools which allow you to setup the infrastructure and issue remote commands to the
destination. They are:
</p>
        <ul>
          <li>
            <font face="Courier New">winrm.cmd</font> (uses <font face="Courier New">winrm.vbs</font>),
defines configuration of local machine 
</li>
          <li>
            <font face="Courier New">winrs.exe</font> (<font face="Courier New">winrscmd.dll</font> and
friends), Windows Remote Shell client, issues commands to a remote machine</li>
        </ul>
        <p>
As said, WS-Management support is enabled by default in Windows Server 2008. This
means that the appropriate service is running, but one should still define basic configuration
on it. Nothing is enabled by default; you have to <strong>opt-in</strong>. 
</p>
        <p>
Since Microsoft is progressing to a more admin friendly environment, this is done
by issuing the following command (server command):
</p>
        <p>
          <font face="Courier New">winrm quickconfig</font>
          <font face="Verdana"> (or <font face="Courier New">winrm
qc</font>)</font>
        </p>
        <p>
This enables the obvious:
</p>
        <ul>
          <li>
Starts the <strong>Windows Remote Management</strong> service (if not stared; in Windows
Vista case) 
</li>
          <li>
Enables <strong>autostart</strong> on the Windows Remote Management service 
</li>
          <li>
Starts up a <strong>listener</strong> for all machine's IP addresses 
</li>
          <li>
Configures appropriate <strong>firewall</strong> exceptions</li>
        </ul>
        <p>
You should get the following output:
</p>
        <p>
          <font face="Courier New">[c:\windows\system32]winrm quickconfig<br /></font>
          <font face="Courier New">
            <br />
WinRM is not set up to allow remote access to this machine for management.<br />
The following changes must be made:</font>
        </p>
        <p>
          <font face="Courier New">Create a WinRM listener on HTTP://* to accept WS-Man requests
to any IP on this machine.<br />
Enable the WinRM firewall exception.</font>
        </p>
        <p>
          <font face="Courier New">Make these changes [y/n]? y</font>
        </p>
        <p>
          <font face="Courier New">WinRM has been updated for remote management.<br /></font>
          <font face="Courier New">Created a WinRM listener on HTTP://* to accept WS-Man
requests to any IP on this machine.<br />
WinRM firewall exception enabled.</font>
        </p>
        <p>
There are options in <font face="Courier New">winrm.cmd</font> to fine tune anything,
including the listening ports and / or SSL (HTTPS) support. In a trusted environment
you probably don't want to issue commands using HTTP based mechanism, since you are
located behind the trust boundary and have complete control over available (allowed)
TCP ports.
</p>
        <p>
You can now issue remote management commands against the configured server, but only
if the communication <strong>is trusted</strong>. So in case you are in a workgroup
environment (client and server in a workgroup), this should get you started (client
command):
</p>
        <p>
          <font face="Courier New">winrm set winrm/config/client @{TrustedHosts="&lt;server
ip or hostname&gt;"}</font>
        </p>
        <p>
You can specify multiple trusted servers using a comma:
</p>
        <p>
          <font face="Courier New">winrm set winrm/config/client @{TrustedHosts="10.10.10.108,
10.10.10.109"}</font>
        </p>
        <p>
This trusts the server(s) no matter what. Even over HTTP only.
</p>
        <p>
Enumerating the configured listeners - remember, listener is located on the destination
side - is done via: 
</p>
        <p>
          <font face="Courier New">winrm enumerate winrm/config/listener</font>
        </p>
        <p>
OK, now we're able to issue commands to the remote side using WS-Management infrastructure.
You can, for example, try this (client command):
</p>
        <p>
          <font face="Courier New">winrs -r:http://&lt;server ip&gt; -u:&lt;username&gt; -p:&lt;password&gt;
&lt;shell command&gt;<font face="Verdana">, ie.<br /></font>winrs -r:http://10.10.10.108 -u:administrator -p:p$38E0jjW! dir -s</font>
        </p>
        <p>
or
</p>
        <p>
          <font face="Courier New">winrs -r:http://10.10.10.108 -u:administrator -p:p$38E0jjW!
hostname</font>
        </p>
        <p>
You can even explose HTTP based approach through your firewall if you're crazy enough.
But using HTTPS would be the smart way out. What you need is a valid certificate with
server authentication capability and a matching CN. Self-signed certs won't work.
</p>
        <p>
Simple and effective.
</p>
        <img width="0" height="0" src="http://www.request-response.com/blog/aggbug.ashx?id=e4ad0d8c-6fb6-40b8-9b52-7ab9092ccc7c" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Managed TxF: Support in Windows Vista and Windows Server 2008</title>
    <link rel="alternate" type="text/html" href="http://www.request-response.com/blog/PermaLink,guid,c421ff72-d5bc-4b5f-8c52-ed5e73e8dd00.aspx" />
    <id>http://www.request-response.com/blog/PermaLink,guid,c421ff72-d5bc-4b5f-8c52-ed5e73e8dd00.aspx</id>
    <published>2007-07-20T16:59:16.281+02:00</published>
    <updated>2007-07-23T20:35:56.625+02:00</updated>
    <category term="Transactions" label="Transactions" scheme="http://www.request-response.com/blog/CategoryView,category,Transactions.aspx" />
    <category term="Windows Vista" label="Windows Vista" scheme="http://www.request-response.com/blog/CategoryView,category,WindowsVista.aspx" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
If you happen to be on a Windows Vista or Windows Server 2008 box, there is some goodness
going your way.
</p>
        <p>
There is a basic managed <