<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.infosupport.com/utility/FeedStylesheets/atom.xsl" media="screen"?><feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en"><title type="html">Edwin van Wijk</title><subtitle type="html" /><id>http://blogs.infosupport.com/blogs/edwinw/atom.aspx</id><link rel="alternate" type="text/html" href="http://blogs.infosupport.com/blogs/edwinw/default.aspx" /><link rel="self" type="application/atom+xml" href="http://blogs.infosupport.com/blogs/edwinw/atom.aspx" /><generator uri="http://communityserver.org" version="2.1.60809.935">Community Server</generator><updated>2008-04-18T12:25:00Z</updated><entry><title>WCF: namespaces in WSDL</title><link rel="alternate" type="text/html" href="http://blogs.infosupport.com/blogs/edwinw/archive/2008/07/20/WCF_3A00_-namespaces-in-WSDL.aspx" /><id>http://blogs.infosupport.com/blogs/edwinw/archive/2008/07/20/WCF_3A00_-namespaces-in-WSDL.aspx</id><published>2008-07-20T21:50:00Z</published><updated>2008-07-20T21:50:00Z</updated><content type="html">&lt;p&gt;I've been working with WCF services a lot lately and I always specify namespaces for my service- and data-contracts. But I noticed that - by default - the WSDL of such a WCF service is generated in two parts:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;a part that resides in the namespace &amp;quot;&lt;code&gt;http://tempuri.org/&lt;/code&gt;&amp;quot;, &lt;/li&gt;    &lt;li&gt;a part that resides in the namespace I specified for the service. &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;The first WSDL contains an import of the second one. This also results in two separate .WSDL files when you download the meta-data (I leave any generated XML Schemas containing the data-contracts out of it in this post).&lt;/p&gt;  &lt;p&gt;Although this works fine, I wondered whether or not it is possible to combine these WSDL files in to one file that uses the namespace I specified for my service, and get rid of this ugly &amp;quot;tempuri&amp;quot; namespace. And guess what, this is easy!&lt;/p&gt;  &lt;p&gt;Here's an example of a service I will use to demonstrate how to do this:&lt;/p&gt;  &lt;table style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;" cellspacing="0" cellpadding="4"&gt;     &lt;tr&gt;       &lt;td&gt;&lt;code&gt;           &lt;div class="code"&gt;&lt;font color="#000000"&gt;[ServiceContract(&lt;span style="background-color:yellow;"&gt;Namespace&lt;font color="#808080"&gt;&amp;#160;&lt;/font&gt;&lt;font color="#0000ff"&gt;=&lt;/font&gt;&lt;font color="#808080"&gt; &amp;quot;urn:wcfsamples:mywcfservice&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;)&lt;/font&gt;]&lt;/font&gt;&lt;font color="#808080"&gt;&amp;#160; &lt;br /&gt;&lt;/font&gt;&lt;font color="#0000ff"&gt;public&lt;/font&gt;&lt;font color="#808080"&gt;&amp;#160;&lt;/font&gt;&lt;font color="#0000ff"&gt;interface&lt;/font&gt;&lt;font color="#808080"&gt;&amp;#160;&lt;/font&gt;&lt;font color="#000000"&gt;IMyWcfService&lt;/font&gt;&lt;font color="#808080"&gt;&amp;#160; &lt;br /&gt;&lt;/font&gt;&lt;font color="#000000"&gt;{&lt;/font&gt;&lt;font color="#808080"&gt;&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160; &lt;/font&gt;&lt;font color="#000000"&gt;[OperationContract]&lt;/font&gt;&lt;font color="#808080"&gt;&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160; &lt;/font&gt;&lt;font color="#0000ff"&gt;string&lt;/font&gt;&lt;font color="#808080"&gt;&amp;#160;&lt;/font&gt;&lt;font color="#000000"&gt;GetData(&lt;/font&gt;&lt;font color="#0000ff"&gt;int&lt;/font&gt;&lt;font color="#808080"&gt;&amp;#160;&lt;/font&gt;&lt;font color="#0000ff"&gt;value&lt;/font&gt;&lt;font color="#000000"&gt;)&lt;/font&gt;&lt;font color="#0000ff"&gt;;&lt;/font&gt;&lt;font color="#808080"&gt;&amp;#160; &lt;br /&gt;&lt;/font&gt;&lt;font color="#000000"&gt;}&lt;/font&gt;&lt;font color="#808080"&gt;&amp;#160; &lt;br /&gt;                &lt;br /&gt;&lt;/font&gt;&lt;font color="#006400"&gt;// implementation of the service&amp;#160; &lt;br /&gt;&lt;/font&gt;&lt;font color="#0000ff"&gt;public&lt;/font&gt;&lt;font color="#808080"&gt;&amp;#160;&lt;/font&gt;&lt;font color="#0000ff"&gt;class&lt;/font&gt;&lt;font color="#808080"&gt;&amp;#160;&lt;/font&gt;&lt;font color="#000000"&gt;MyWcfServiceImpl&lt;/font&gt;&lt;font color="#808080"&gt;&amp;#160;&lt;/font&gt;&lt;font color="#000000"&gt;:&lt;/font&gt;&lt;font color="#808080"&gt;&amp;#160;&lt;/font&gt;&lt;font color="#000000"&gt;IMyWcfService&lt;/font&gt;&lt;font color="#808080"&gt;&amp;#160; &lt;br /&gt;&lt;/font&gt;&lt;font color="#000000"&gt;{&lt;/font&gt;&lt;font color="#808080"&gt;&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160; &lt;/font&gt;&lt;font color="#0000ff"&gt;public&lt;/font&gt;&lt;font color="#808080"&gt;&amp;#160;&lt;/font&gt;&lt;font color="#0000ff"&gt;string&lt;/font&gt;&lt;font color="#808080"&gt;&amp;#160;&lt;/font&gt;&lt;font color="#000000"&gt;GetData(&lt;/font&gt;&lt;font color="#0000ff"&gt;int&lt;/font&gt;&lt;font color="#808080"&gt;&amp;#160;&lt;/font&gt;&lt;font color="#0000ff"&gt;value&lt;/font&gt;&lt;font color="#000000"&gt;)&lt;/font&gt;&lt;font color="#808080"&gt;&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160; &lt;/font&gt;&lt;font color="#000000"&gt;{&lt;/font&gt;&lt;font color="#808080"&gt;&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;font color="#0000ff"&gt;return&lt;/font&gt;&lt;font color="#808080"&gt;&amp;#160;&lt;/font&gt;&lt;font color="#0000ff"&gt;string&lt;/font&gt;&lt;font color="#000000"&gt;.Format(&lt;/font&gt;&lt;font color="#808080"&gt;&amp;quot;You entered: {0}&amp;quot;&lt;/font&gt;&lt;font color="#000000"&gt;,&lt;/font&gt;&lt;font color="#808080"&gt;&amp;#160;&lt;/font&gt;&lt;font color="#0000ff"&gt;value&lt;/font&gt;&lt;font color="#000000"&gt;)&lt;/font&gt;&lt;font color="#0000ff"&gt;;&lt;/font&gt;&lt;font color="#808080"&gt;&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160; &lt;/font&gt;&lt;font color="#000000"&gt;}&lt;/font&gt;&lt;font color="#808080"&gt;&amp;#160; &lt;br /&gt;&lt;/font&gt;&lt;font color="#000000"&gt;}&lt;/font&gt;&lt;font color="#808080"&gt;&amp;#160;&lt;/font&gt; &lt;/div&gt;         &lt;/code&gt;&lt;/td&gt;     &lt;/tr&gt;   &lt;/table&gt;  &lt;p&gt;This must look familiar. Now, to make sure the WSDL that is generated for the service (once you created a host) consists of only one part that resides in the specified namespace, you must take the following steps:&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Add a &lt;code&gt;ServiceBehavior&lt;/code&gt; attribute to the implementation-class, and specify the service's namespace. &lt;/li&gt;    &lt;li&gt;Add the &lt;code&gt;bindingNamespace&lt;/code&gt; attribute to all (non meta-data exchange) endpoints you configured for the service. &lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;Example of step 1:&lt;/p&gt;  &lt;table style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;" cellspacing="0" cellpadding="4"&gt;     &lt;tr&gt;       &lt;td&gt;&lt;code&gt;           &lt;div class="code"&gt;&lt;font color="#000000"&gt;[ServiceBehavior(&lt;span style="background-color:yellow;"&gt;Namespace&lt;font color="#0000ff"&gt;=&lt;/font&gt;&lt;font color="#808080"&gt;&amp;quot;urn:wcfsamples:mywcfservice&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;)&lt;/font&gt;]&lt;/font&gt; &lt;/div&gt;         &lt;/code&gt;&lt;/td&gt;     &lt;/tr&gt;   &lt;/table&gt;  &lt;p&gt;Example of step 2:&lt;/p&gt;  &lt;table style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;" cellspacing="0" cellpadding="4"&gt;     &lt;tr&gt;       &lt;td&gt;         &lt;div class="code"&gt;&lt;font color="#0000ff"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#800000"&gt;endpoint&lt;/font&gt;&lt;font color="#ff0000"&gt;&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160; address&lt;/font&gt;&lt;font color="#0000ff"&gt;=&amp;quot;&amp;quot;&lt;/font&gt;&lt;font color="#ff0000"&gt;&amp;#160;&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160; binding&lt;/font&gt;&lt;font color="#0000ff"&gt;=&amp;quot;wsHttpBinding&amp;quot;&lt;/font&gt;&lt;font color="#ff0000"&gt;&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160; contract&lt;/font&gt;&lt;font color="#0000ff"&gt;=&amp;quot;MyWcfService.IMyWcfService&amp;quot;&lt;/font&gt;&lt;font color="#ff0000"&gt;&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160; &lt;span style="background-color:yellow;"&gt;bindingNamespace&lt;font color="#0000ff"&gt;=&amp;quot;urn:wcfsamples:mywcfservice&amp;quot;&lt;/font&gt;&lt;/span&gt;/&amp;gt;&lt;/font&gt; &lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;   &lt;/table&gt;  &lt;p&gt;Finally, here's a fragment of the WSDL that is generated for the service:&lt;/p&gt;  &lt;table style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;" cellpadding="4"&gt;     &lt;tr&gt;       &lt;td&gt;         &lt;div class="code"&gt;&lt;font color="#0000ff"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#800000"&gt;xml&lt;/font&gt;&lt;font color="#ff0000"&gt; version&lt;/font&gt;&lt;font color="#0000ff"&gt;=&amp;quot;1.0&amp;quot;&lt;/font&gt;&lt;font color="#ff0000"&gt; encoding&lt;/font&gt;&lt;font color="#0000ff"&gt;=&amp;quot;utf-8&amp;quot;&lt;/font&gt;&lt;font color="#ff0000"&gt; ?&lt;/font&gt;&lt;font color="#0000ff"&gt;&amp;gt;&lt;/font&gt;&lt;font color="#000000"&gt;&amp;#160; &lt;br /&gt;&lt;/font&gt;&lt;font color="#0000ff"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#800000"&gt;wsdl:definitions&lt;/font&gt;&lt;font color="#ff0000"&gt; name&lt;/font&gt;&lt;font color="#0000ff"&gt;=&amp;quot;MyWcfServiceImpl&amp;quot;&lt;/font&gt;&lt;font color="#ff0000"&gt; &lt;span style="background-color:yellow;"&gt;targetNamespace&lt;font color="#0000ff"&gt;=&amp;quot;urn:wcfsamples:mywcfservice&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font color="#ff0000"&gt; xmlns:wsdl&lt;/font&gt;&lt;font color="#0000ff"&gt;=&amp;quot;http://schemas.xmlsoap.org/wsdl/&amp;quot;&lt;/font&gt;&lt;font color="#ff0000"&gt;&amp;#160; &lt;br /&gt;xmlns:soap&lt;/font&gt;&lt;font color="#0000ff"&gt;=&amp;quot;http://schemas.xmlsoap.org/wsdl/soap/&amp;quot;&lt;/font&gt;&lt;font color="#ff0000"&gt; xmlns:wsu&lt;/font&gt;&lt;font color="#0000ff"&gt;=&amp;quot;http:// &lt;/font&gt;&lt;font color="#000000"&gt;... &lt;/font&gt;&lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;   &lt;/table&gt;  &lt;p&gt;That's it. When you now download the meta-data for this service, you get only one .WSDL file. Exactly what I wanted.&lt;/p&gt;  &lt;p&gt;I hope you find this information useful. And remember: let's keep our WSDL tidy!&lt;/p&gt;&lt;img src="http://blogs.infosupport.com/aggbug.aspx?PostID=14204" width="1" height="1"&gt;</content><author><name>edwinw</name><uri>http://blogs.infosupport.com/members/edwinw.aspx</uri></author></entry><entry><title>Service Versioning with the Managed Service Engine</title><link rel="alternate" type="text/html" href="http://blogs.infosupport.com/blogs/edwinw/archive/2008/04/18/Service-Versioning-and-the-Managed-Service-Engine.aspx" /><id>http://blogs.infosupport.com/blogs/edwinw/archive/2008/04/18/Service-Versioning-and-the-Managed-Service-Engine.aspx</id><published>2008-04-18T10:25:00Z</published><updated>2008-04-18T10:25:00Z</updated><content type="html">&lt;p&gt;While checking out &lt;a href="http://www.microsoft.com/soa/" target="_blank"&gt;Microsoft&amp;#39;s SOA website&lt;/a&gt;, I found an application called the &lt;a href="http://www.microsoft.com/soa/solutions/soi.aspx#managed" target="_blank"&gt;Managed Services Engine&lt;/a&gt; (MSE). In the accompanying description I read that this application offers so called &amp;quot;Service Virtualization&amp;quot;. In the list of features I found one that I was particularly interested in: service versioning. So I decided to check it out. For the MSE a &lt;a href="http://www.codeplex.com/servicesengine" target="_blank"&gt;Codeplex project&lt;/a&gt; has been created where the tool can be downloaded. I downloaded the bits and installed them. It comes with a clear installation manual I followed without any problems.&lt;/p&gt;&lt;p&gt;The MSE consists of two parts:&amp;nbsp;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;Service Catalog &amp;ndash; which handles the administration of the services.&lt;/li&gt;&lt;li&gt;Service Runtime &amp;ndash; which hosts the services.&amp;nbsp;&amp;nbsp;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;Both parts are implemented as a Windows service. The service catalog can be administered using the supplied MSE management console snap-in. The idea behind the MSE is that you create and host end-points in the MSE which in turn calls existing services to handle the implementation. That&amp;rsquo;s where the term &amp;quot;virtual services&amp;quot; comes from. In this blogpost I&amp;rsquo;d like to zoom in on a killer feature: service versioning. For every service operation that you define in the MSE, multiple versions can be defined. The MSE has a &lt;em&gt;MessageBroker&lt;/em&gt; component which will call the appropriate implementation for a certain version based on the incoming message. Let&amp;rsquo;s assume the following situation:&lt;/p&gt;&lt;p&gt;&lt;img height="99" src="http://blogs.infosupport.com/photos/edwinw/images/13748/original.aspx" style="width:476px;height:99px;" width="476" /&gt;&lt;br /&gt;&lt;br /&gt;The &lt;em&gt;AddIntegers&lt;/em&gt; operation on the &lt;em&gt;CalculatorService&lt;/em&gt; expects 2 integers as arguments and returns the sum of these integers as result. The &lt;em&gt;AddIntegerArray&lt;/em&gt; operation on the &lt;em&gt;AdvancedCalculatorService&lt;/em&gt; expects an array of integers as argument and returns the sum of these integers as result. In the MSE catalog, two versions of an operation called &lt;em&gt;AddIntegers&lt;/em&gt; is defined. Obviously, the 1.0 version is handled by the &lt;em&gt;CalculatorService&lt;/em&gt; and version 1.1 is handled by the &lt;em&gt;AdvancedCalculatorService&lt;/em&gt;. &lt;br /&gt;But how can we call a specific version of the &lt;em&gt;AddIntegers&lt;/em&gt; operation? This is easy. You just call the &lt;em&gt;AddIntegers&lt;/em&gt; operation and pass it a message that corresponds with the expected schema of the version you want to call. For example: if we want to call the 1.0 version, we would sent the following message (SOAP headers have been omitted for clarity):&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&amp;lt;AddIntegers xmlns=&amp;quot;urn:infosupport-com-calculator&amp;quot;&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;lt;x&amp;gt;4&amp;lt;/x&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;lt;y&amp;gt;8&amp;lt;/y&amp;gt;&lt;br /&gt;&amp;lt;/AddIntegers&amp;gt;&lt;/code&gt;&lt;/p&gt;&lt;p&gt;But if we want to call the 1.1 version, we send the following message:&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&amp;lt;AddIntegerArray xmlns=&amp;quot;urn:infosupport-com-advancedcalculator&amp;quot;&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;lt;inputValues&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;int xmlns=&amp;quot;http://schemas.microsoft.com/2003/10/Serialization/Arrays&amp;quot;&amp;gt;4&amp;lt;/int&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;int xmlns=&amp;quot;http://schemas.microsoft.com/2003/10/Serialization/Arrays&amp;quot;&amp;gt;8&amp;lt;/int&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;int xmlns=&amp;quot;http://schemas.microsoft.com/2003/10/Serialization/Arrays&amp;quot;&amp;gt;5&amp;lt;/int&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;lt;/inputValues&amp;gt;&lt;br /&gt;&amp;lt;/AddIntegerArray&amp;gt;&lt;/code&gt;&lt;/p&gt;&lt;p&gt;This way 1.0 clients and 1.1 clients can both call the &lt;em&gt;AddIntegers&lt;/em&gt; operation and the MSE makes sure the appropriate implementation is called. In the WSDL of the service, only 1 version of a certain operation is published at a time. The MSE management console offers some cool features to configure stuff like this. For example, you can specify which versions of a method are active and which version is actually published in the WSDL, simply by setting some check-boxes and radio-buttons:&lt;/p&gt;&lt;p&gt;&lt;img height="317" src="http://blogs.infosupport.com/photos/edwinw/images/13749/425x317.aspx" style="width:425px;height:317px;" width="425" /&gt;&lt;/p&gt;&lt;p&gt;Another cool feature is the ability to retire the implementation corresponding to a specific version of an operation, while keeping the version available on the virtual service. Say - for example - we need to take down the &lt;em&gt;CalculatorService&lt;/em&gt; but we have several existing clients that call the 1.0 version of the &lt;em&gt;AddIntegers&lt;/em&gt; operation. We can make this happen by instructing the MSE to send requests for version 1.0 to the &lt;em&gt;AdvancedCalculatorService&lt;/em&gt;. Every version of an operation in MSE is equipped with a so called ChannelMoniker which specifies the address of the implementation service and the action that is to be called on this service for a specific version. By changing the address and action for version 1.0 you can make it point it to the &lt;em&gt;AddIntegerArray&lt;/em&gt; operation on the &lt;em&gt;AdvancedCalculatorService&lt;/em&gt;. Additionally we can specify an XSLT with which the MSE will automatically transform the incoming 1.0 request to an 1.1 request and do the same for the response (from 1.1 to 1.0). Once this is done, you can bring down the &lt;em&gt;CalculatorService&lt;/em&gt; but still call the 1.0 version of the &lt;em&gt;AddIntegers&lt;/em&gt; operation on the virtual service. I think that&amp;rsquo;s pretty cool.&lt;/p&gt;&lt;p&gt;In this blogpost I&amp;rsquo;ve focused on service versioning, but the MSE has more features in store. Whether you&amp;rsquo;re able to employ the MSE - as is - in your current project or you need some inspiration because you&amp;rsquo;re building some sort of service framework, I think&amp;nbsp;it&amp;rsquo;s worth investigating. &lt;/p&gt;&lt;p&gt;Have fun!&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;img src="http://blogs.infosupport.com/aggbug.aspx?PostID=13752" width="1" height="1"&gt;</content><author><name>edwinw</name><uri>http://blogs.infosupport.com/members/edwinw.aspx</uri></author><category term="WCF" scheme="http://blogs.infosupport.com/blogs/edwinw/archive/tags/WCF/default.aspx" /><category term="Service Versioning" scheme="http://blogs.infosupport.com/blogs/edwinw/archive/tags/Service+Versioning/default.aspx" /><category term="Managed Services Engine" scheme="http://blogs.infosupport.com/blogs/edwinw/archive/tags/Managed+Services+Engine/default.aspx" /></entry></feed>