<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Technical Weblog of Eric Charran : Windows Communication Foundation</title><link>http://blogs.msdn.com/echarran/archive/tags/Windows+Communication+Foundation/default.aspx</link><description>Tags: Windows Communication Foundation</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>HOWTO: Properly Utilize a WCF Service Proxy Class in Code</title><link>http://blogs.msdn.com/echarran/archive/2008/05/22/howto-properly-utilize-a-wcf-service-proxy-class-in-code.aspx</link><pubDate>Thu, 22 May 2008 20:32:01 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8532686</guid><dc:creator>echarran</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/echarran/comments/8532686.aspx</comments><wfw:commentRss>http://blogs.msdn.com/echarran/commentrss.aspx?PostID=8532686</wfw:commentRss><wfw:comment>http://blogs.msdn.com/echarran/rsscomments.aspx?PostID=8532686</wfw:comment><description>&lt;p&gt;One critical thing when using proxy classes is to be aware of how to properly call methods and then close the proxy.&amp;#160; Because the proxy makes HTTP requests, (assuming your service is housed within IIS), unless you call .Close() on the proxy, those requests will be held open in IIS and threads will remain dedicated to them.&amp;#160; Thus, without closing your proxy, you will soon have sopped up IIS resources with repeated calls to the service from your application.&amp;#160; Eventually, you will see an error with text similar to the following:&lt;/p&gt;  &lt;p&gt;&amp;quot;TimeoutException was Unhandled&amp;quot; &lt;/p&gt;  &lt;p&gt;The request channel timed out while waiting for a reply after &amp;lt;Insert Time Interval Here&amp;gt;&lt;/p&gt;  &lt;p&gt;The best practice is to call .Close() on your service proxy after each call.&amp;#160; Call it in a finally block and ensure to check to see if the state on the proxy is .Opened first.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8532686" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/echarran/archive/tags/Windows+Communication+Foundation/default.aspx">Windows Communication Foundation</category><category domain="http://blogs.msdn.com/echarran/archive/tags/WCF+Development/default.aspx">WCF Development</category></item><item><title>How to Arrange a Solution using the WCF Service Library and WCF Service Application Templates</title><link>http://blogs.msdn.com/echarran/archive/2007/09/18/how-to-arrange-a-solution-using-the-wcf-service-library-and-wcf-service-application-templates.aspx</link><pubDate>Wed, 19 Sep 2007 04:19:51 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:4990052</guid><dc:creator>echarran</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/echarran/comments/4990052.aspx</comments><wfw:commentRss>http://blogs.msdn.com/echarran/commentrss.aspx?PostID=4990052</wfw:commentRss><wfw:comment>http://blogs.msdn.com/echarran/rsscomments.aspx?PostID=4990052</wfw:comment><description>&lt;p&gt;In Visual Studio 2008 (Beta 2), there are two WCF application templates.&lt;/p&gt; &lt;p&gt;The WCF Service Library is a class library that defines a WCF service, that can be exposed through a variety of WCF hosting options (i.e., IIS, a custom built WCF host, or a Windows Service).&amp;nbsp; This WCF class library defines the service, operation and data contracts and implements the service specification.&amp;nbsp; The WCF class library also contains a app.config file which also has the settings that any host would need to expose the services endpoints, behaviors, etc.&amp;nbsp; In fact, if you set the WCF class library as a start up project in Visual Studio 2008, it will host the service in a web application and launch the WCF Test Client (part of VS 2008) to allow inspection and test execution of the WCF class library's methods.&lt;/p&gt; &lt;p&gt;The WCF Service Application is a template that assumes you are building a service that will only be hosted within IIS.&amp;nbsp; Thus, it defines the service, equips the project with a web.config and places the details about the endpoints, behaviors, etc. in that file.&amp;nbsp; When set as a startup project, it will host the service in the development web server and listen for calls.&amp;nbsp; &lt;/p&gt; &lt;p&gt;Observing the differences between these two templates is important because it might have ramifications on how WCF applications are developed.&amp;nbsp; If you want to have your WCF application code hosted in eventually multiple hosts (i.e., IIS, custom built or Windows Service) the best approach is to place your service definition and implementation in a WCF class library.&amp;nbsp; If your service will only ever need to be exposed as an IIS service (i.e., if its a front-end service wrapping some business logic/functionality that you exposed to external business trading partners via the Internet), then baking the code into the host like the WCF Service Application template does makes sense.&amp;nbsp; In fact, at a later date, you can migrate the code into a WCF class library and "hallow out" the IIS host by point it to the library.&amp;nbsp; &lt;/p&gt; &lt;p&gt;The trick I recently did is to place my service implementation in a WCF class library template, but expose it to a consuming application in the same solution.&amp;nbsp; When adding a service reference to a WCF client, Visual Studio 2008 allows you to automatically discover services within the same solution.&amp;nbsp; However, because a WCF class library has no host, it isn't visible as a service that can be added to a client.&amp;nbsp; What is required is a host for the WCF class library.&lt;/p&gt; &lt;p&gt;To allow the WCF client to see the WCF class library as a service, I added a WCF Service Application project template to the solution and followed these steps:&lt;/p&gt; &lt;ol&gt; &lt;li&gt;Add a project reference to the WCF class library project  &lt;li&gt;Rename the Service1.svc file to the service name of my choice  &lt;li&gt;Deleted the Service1.svc.cs code behind file as we won't have any WCF Service implementation in this project  &lt;li&gt;Viewed the markup of the Service1.svc file and altered it accordingly to refer to the types referenced from the WCF class library  &lt;p&gt;&amp;lt;@ServiceHost&lt;/a&gt; Language="C#" Debug="true" Service="ProjectName.Service.Library.ProjectNameService"%&amp;gt;&lt;br&gt;&amp;lt;@Assembly Name="ProjectName.Service.Library" %&amp;gt;  &lt;p&gt;&amp;nbsp; Note that Service is the namespace of the referenced WCF class library dll and that the assembly is the name of the referenced assembly&lt;/p&gt; &lt;li&gt;Altered the web.config, replacing any mention of Service1 with the correct service name from the referenced assembly.  &lt;ol&gt; &lt;li&gt;Note that an approach to this is to compare the web.config with the app.config of the WCF class library to make sure the service name and behavior between the files are equal&lt;/li&gt;&lt;/ol&gt; &lt;li&gt;Build the WCF Service Application and test the wsdl by visiting the Service1.svc file and clicking on the wsdl link  &lt;li&gt;Right click your WCF Client application project file in Visual Studio (in my case a Windows Forms project) and select Add Service Reference  &lt;li&gt;Click the discover button and select to discover services within the solution  &lt;li&gt;Assign the service a proper namespace&lt;/li&gt;&lt;/ol&gt; &lt;p&gt;At this point, you should have a separate WCF class library that can be hosted anywhere (i.e., Windows Service, IIS, or custom-built host) and that can be debugged and tested by the built in WCF Service test harness.&amp;nbsp; You also should have a wrapping IIS host for the WCF Service that can be discovered by potential WCF Service clients in the solution.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=4990052" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/echarran/archive/tags/Windows+Communication+Foundation/default.aspx">Windows Communication Foundation</category><category domain="http://blogs.msdn.com/echarran/archive/tags/WCF+Development/default.aspx">WCF Development</category></item><item><title>Guidance for Hosting and Consuming WCF Services</title><link>http://blogs.msdn.com/echarran/archive/2007/04/04/guidance-for-hosting-and-consuming-wcf-services.aspx</link><pubDate>Wed, 04 Apr 2007 22:10:12 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:2026806</guid><dc:creator>echarran</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/echarran/comments/2026806.aspx</comments><wfw:commentRss>http://blogs.msdn.com/echarran/commentrss.aspx?PostID=2026806</wfw:commentRss><wfw:comment>http://blogs.msdn.com/echarran/rsscomments.aspx?PostID=2026806</wfw:comment><description>&lt;p&gt;Here is a great article&amp;nbsp;on how to host and consume WCF Services.&amp;nbsp; The great thing about this article is that provides prescriptive guidance on where to put the WCF Service once authored.&amp;nbsp; Based on the establishment of enterprise environments, B2B and B2C or EAI models, the paper promotes a "Why not IIS (7.0)?" philosophy.&lt;/p&gt; &lt;p&gt;As many of you may know,&amp;nbsp;a WCF Service is conceptually similar&amp;nbsp;to breaking a Web Service out of IIS and making access to it&amp;nbsp;nearly ubiquitous.&amp;nbsp; Essentially, once the service, data and operation contracts and implementation have been built, developers can look at requirements to figure out how to make their service available.&amp;nbsp; IIS 6.0 and 7.0 are convincing WCF host providers since they already provide start and stop functionality and hosting over http.&amp;nbsp; IIS 7.0 includes windows activation services (WAS) which equips IIS 7.0 with the ability to service WCF requests on multiple protocols (i.e. TCP, MSMQ).&amp;nbsp; Both implementations provide state management for requests from clients.&amp;nbsp; &lt;/p&gt; &lt;p&gt;The paper outlines other choices for hosting.&amp;nbsp; The only other significant method of hosting might be a Windows Service when you don't want to use IIS (i.e., like in a packaged software server product) or if you need 2 applications on a desktop to talk to each other (self hosting).&lt;/p&gt; &lt;p&gt;&lt;a title="http://msdn2.microsoft.com/en-us/library/bb332338.aspx" href="http://msdn2.microsoft.com/en-us/library/bb332338.aspx"&gt;http://msdn2.microsoft.com/en-us/library/bb332338.aspx&lt;/a&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=2026806" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/echarran/archive/tags/Windows+Communication+Foundation/default.aspx">Windows Communication Foundation</category></item></channel></rss>