<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://msmvps.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>LA.NET [EN] : WCF</title><link>http://msmvps.com/blogs/luisabreu/archive/tags/WCF/default.aspx</link><description>Tags: WCF</description><dc:language>en</dc:language><generator>CommunityServer 2008.5 SP2 (Build: 40407.4157)</generator><item><title>Re-throwing exceptions</title><link>http://msmvps.com/blogs/luisabreu/archive/2008/12/02/re-throwing-exceptions.aspx</link><pubDate>Tue, 02 Dec 2008 10:33:25 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1655543</guid><dc:creator>luisabreu</dc:creator><slash:comments>2</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/luisabreu/rsscomments.aspx?PostID=1655543</wfw:commentRss><comments>http://msmvps.com/blogs/luisabreu/archive/2008/12/02/re-throwing-exceptions.aspx#comments</comments><description>&lt;p&gt;While I was reading the &lt;a href="http://www.amazon.com/Essential-Windows-Communication-Foundation-WCF/dp/0321440064/ref=pd_bbs_sr_1?ie=UTF8&amp;amp;s=books&amp;amp;qid=1228213030&amp;amp;sr=8-1"&gt;Essential Windows Communication Foundation&lt;/a&gt; book (from &lt;a href="http://www.awprofessional.com/"&gt;Addision Wesley&lt;/a&gt;), I found the following code (on a transaction required for a WCF service context):&lt;/p&gt;  &lt;p&gt;[OperationBehavior(TransactionScopeRequired = true,    &lt;br /&gt;&amp;#160;&amp;#160; TransactionAutoComplete = true)]    &lt;br /&gt;public void Transfer( String from, String to, double amount){    &lt;br /&gt;&amp;#160; try {    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; Withdraw(from, amount);    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; Deposit( to, amount);    &lt;br /&gt;&amp;#160; }    &lt;br /&gt;&amp;#160; &lt;strong&gt;catch(Exception ex){     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; throw ex;      &lt;br /&gt;&amp;#160; }      &lt;br /&gt;&lt;/strong&gt;}&lt;/p&gt;  &lt;p&gt;Lets not even talk about why using the Exception type in a try/catch is bad (though I accept its usage in a book, but only after seeing a justification of why you should not use it in production code)…instead, lets concentrate on what is happening inside the catch block…see anything wrong there? I hope so! You should never re-throw an exception like that. In my opinion, you’ve got 2 options here:&lt;/p&gt;  &lt;p&gt;1. You’re “important” in the stack chain and then you’ll want to wrap that exception with your own specific&amp;#160; exception type (for isntance, NHibernate does something like this and wraps ADO.NET exceptions with its own exception type). Here’s what I mean:&lt;/p&gt;  &lt;p&gt;catch(Exception ex ) { //btw, don’t catch the Exception type   &lt;br /&gt;&amp;#160; //do something here…probably log it    &lt;br /&gt;&amp;#160;&amp;#160; throw new MyException(ex);    &lt;br /&gt;}&lt;/p&gt;  &lt;p&gt;2. You’re not significant, so you can just rethrow that exception after logging:&lt;/p&gt;  &lt;p&gt;catch(Exception ex ) { //btw, don’t catch the Exception type   &lt;br /&gt;&amp;#160; //do something here…probably log it    &lt;br /&gt;&amp;#160;&amp;#160; throw; //see? no ex here!    &lt;br /&gt;}&lt;/p&gt;  &lt;p&gt;Ok, so why is this important? Because when you re-throw the exception by using technique shown in point 2, you will be preserving the stack trace. When you do it like in the original code, the stack trace that the client will see ends up in your catch block. Probably not what you’ll want in most scenarios!&lt;/p&gt;  &lt;p&gt;Do notice that technique 1 will also preserve the stack chain since you’re passing the exception as the inner exception of the new exception you’re throwing. Both of these options are really better than the one shown on the initial code.&lt;/p&gt;  &lt;p&gt;I’m only writing this here because I was under the impression that this info should be well know by now, but it seems like I’m wrong…Do keep in mind that it’s not my intent to trash on this book (I’m still on page 211, but I’m liking it so far), but I was a little but surprised by seeing this code there (as always, I’ll put a review after ending it).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1655543" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/luisabreu/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://msmvps.com/blogs/luisabreu/archive/tags/WCF/default.aspx">WCF</category></item><item><title>.NET 3.5 and VS SP beta1 goodies</title><link>http://msmvps.com/blogs/luisabreu/archive/2008/05/12/net-3-5-and-vs-sp-beta1-goodies.aspx</link><pubDate>Mon, 12 May 2008 19:58:24 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1621149</guid><dc:creator>luisabreu</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/luisabreu/rsscomments.aspx?PostID=1621149</wfw:commentRss><comments>http://msmvps.com/blogs/luisabreu/archive/2008/05/12/net-3-5-and-vs-sp-beta1-goodies.aspx#comments</comments><description>&lt;p&gt;You can get them from here (VS) and &lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=23516C63-2DB2-4E7F-AABA-32B12D6E025C&amp;amp;displaylang=en"&gt;here&lt;/a&gt; (.NET). I&amp;#39;m reading what&amp;#39;s new on Brad Abrams &lt;a href="http://blogs.msdn.com/brada/archive/2008/05/05/visual-studio-2008-and-net-framework-3-5-sp1-beta.aspx"&gt;post&lt;/a&gt; and I&amp;#39;m really digging the new features:) For instance, having the format option working with JS code is simply cool! Another cool thing: the ScriptManager is able to combine scripts so there&amp;#39;s really no need for using the &lt;a href="http://msmvps.com/blogs/luisabreu/archive/2007/06/12/toolkitscriptmanager-there-s-a-new-scriptmanager-in-town.aspx"&gt;ToolkitScriptManager&lt;/a&gt; for that:)&lt;/p&gt; &lt;p&gt;Btw, i&amp;#39;m still going through the complete list but it really looks like we&amp;#39;re gonna gave lots of new stuff :)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1621149" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/luisabreu/archive/tags/MS+AJAX/default.aspx">MS AJAX</category><category domain="http://msmvps.com/blogs/luisabreu/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://msmvps.com/blogs/luisabreu/archive/tags/WPF/default.aspx">WPF</category><category domain="http://msmvps.com/blogs/luisabreu/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://msmvps.com/blogs/luisabreu/archive/tags/Trivia/default.aspx">Trivia</category><category domain="http://msmvps.com/blogs/luisabreu/archive/tags/WF/default.aspx">WF</category><category domain="http://msmvps.com/blogs/luisabreu/archive/tags/WCF/default.aspx">WCF</category></item><item><title>WCF again: the slow problem attacks again</title><link>http://msmvps.com/blogs/luisabreu/archive/2008/03/26/wcf-again-the-slow-problem-attacks-again.aspx</link><pubDate>Tue, 25 Mar 2008 23:22:10 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1553237</guid><dc:creator>luisabreu</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/luisabreu/rsscomments.aspx?PostID=1553237</wfw:commentRss><comments>http://msmvps.com/blogs/luisabreu/archive/2008/03/26/wcf-again-the-slow-problem-attacks-again.aspx#comments</comments><description>&lt;p&gt;On a different set of machines...I&amp;#39;m stumped. I mean, I though I&amp;#39;d nailed it with the &lt;a href="http://msmvps.com/blogs/luisabreu/archive/2008/03/14/wcf-client-calls-slow.aspx"&gt;proxy problem&lt;/a&gt;, but unfortunately there are still some machines where the 1st call is really really slow and removing the proxy isn&amp;#39;t helping. I&amp;#39;ve even profiled the code but&amp;nbsp; I still can&amp;#39;t see where the problem lies. &lt;a href="http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=3062805&amp;amp;SiteID=1&amp;amp;mode=1"&gt;I&amp;#39;ve written a post&lt;/a&gt; on the WCF forum, but there are still no clues on how to solve this. Anyone wants to give it a try?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1553237" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/luisabreu/archive/tags/WCF/default.aspx">WCF</category></item><item><title>WCF client calls slow</title><link>http://msmvps.com/blogs/luisabreu/archive/2008/03/14/wcf-client-calls-slow.aspx</link><pubDate>Fri, 14 Mar 2008 11:09:18 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1542739</guid><dc:creator>luisabreu</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/luisabreu/rsscomments.aspx?PostID=1542739</wfw:commentRss><comments>http://msmvps.com/blogs/luisabreu/archive/2008/03/14/wcf-client-calls-slow.aspx#comments</comments><description>Today I was able to get back to my previous &lt;a href="http://msmvps.com/blogs/luisabreu/archive/2008/03/11/wcf-windows-forms-lots-of-problems-with-some-services.aspx"&gt;WCF client problem&lt;/a&gt; that I had described &lt;a href="http://msmvps.com/blogs/luisabreu/archive/2008/03/11/wcf-windows-forms-lots-of-problems-with-some-services.aspx"&gt;here&lt;/a&gt;. After looking at the old logs again, it was clear that the delay was on the server discoverability. The problem was that pinging was really fast, so it seemed like there was no client/server communication problem. 

You can say that I&amp;#39;m a curious stubborn guy and since I thought the discovery thing was the problem, I decided to look at the IE settings. And guess what? It had the automatically detect settings of the LAN Settings option turned on. Turning it off solved the 1st time request. After knowing the problem, it was really easy to get a confirmation for it: &lt;a href="http://blogs.msdn.com/drnick/"&gt;Dr. Nicholas Allen&lt;/a&gt; had already a &lt;a href="http://blogs.msdn.com/drnick/archive/2007/06/15/slow-proxy-discovery.aspx"&gt;great entry&lt;/a&gt; which discusses this kind of problems.&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1542739" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/luisabreu/archive/tags/WCF/default.aspx">WCF</category></item><item><title>WCF+Windows Forms = lots of problems with some services</title><link>http://msmvps.com/blogs/luisabreu/archive/2008/03/11/wcf-windows-forms-lots-of-problems-with-some-services.aspx</link><pubDate>Mon, 10 Mar 2008 23:15:50 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1539474</guid><dc:creator>luisabreu</dc:creator><slash:comments>2</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/luisabreu/rsscomments.aspx?PostID=1539474</wfw:commentRss><comments>http://msmvps.com/blogs/luisabreu/archive/2008/03/11/wcf-windows-forms-lots-of-problems-with-some-services.aspx#comments</comments><description>&lt;p&gt;In these last days I&amp;#39;ve been really busy finishing an application which consists of a Windows Forms app that gets its data from serveral WCF services (which, btw, use basic HTTP binding + SSL). Now, most of the services work really smoothly, but...there are 2 which are really making me go crazy: they are SLOW when run in Windows XP Pro machines! Now, I&amp;#39;m talking about really simple services which should really execute under 300 ms!&lt;/p&gt; &lt;p&gt;As you might expect, the first thing I did was use &lt;a href="http://www.fiddlertool.com/"&gt;fiddler&lt;/a&gt; to see what was going on. According to it, the request was taking 15 seconds, which seemed to confirm my initial impression that there was something wrong with the service. The next logical step was enabling tracing on the WCF service. I couldn&amp;#39;t really believe in what my eyes were seeing: instead of seeing several seconds on processing time, the traced shown &amp;lt;300 ms. Could it be something wrong with IIS (which, btw, is IIS 6 on&amp;nbsp; Windows 2003 Server machine)? To answer this, I enabled IIS logging. Guess what: IIS logging confirms the WCF tracing entries: requests were served in &amp;lt;300 ms!&lt;/p&gt; &lt;p&gt;Maybe there something wrong with the network? Pinging revealed nothing wrong...So I went ahead and installed &lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=18b1d59d-f4d8-4213-8d17-2f6dde7d7aac"&gt;netmon&lt;/a&gt; on my machine. After filtering the traffic, I was able to see that request/response from client to server were consistent with the logging info I was getting from WCF and IIS. So, I&amp;#39;ve just went ahead and tried using &lt;a href="http://msdn2.microsoft.com/en-us/library/6t9t5wcf(VS.80).aspx"&gt;ngen&lt;/a&gt; with my client windows forms app. It didn&amp;#39;t made any difference though...it was time to try one more thing: logging on the client side.&lt;/p&gt; &lt;p&gt;The &lt;a href="http://msdn2.microsoft.com/en-us/library/ms732023.aspx"&gt;SvcTraceViewer&lt;/a&gt; tool has a really great feature: you can open several trace files at the same time. When I did this, I got the following results (just copy/paste it here: on each line you&amp;#39;ll see a description, the number of traces, the start and end time of the action):&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;000000000000 8 13s 9:21:20 9:21:34&lt;br /&gt;Construct ChannelFactory. Contract type: &amp;#39;SRA.Mercados.Servicos.IServicoUtilizador&amp;#39;. 4 328ms 9:21:20 9:21:21&lt;br /&gt;Open ChannelFactory. Contract type: &amp;#39;SRA.Mercados.Servicos.IServicoUtilizador&amp;#39;. 4 31ms 9:21:21 9:21:21&lt;br /&gt;&lt;strong&gt;Process action &amp;#39;http://sra.pt/Mercados/IServicoUtilizador/ObtemUtilizador&amp;#39;. 24 14s 9:21:21 9:21:35&lt;br /&gt;Receive bytes on connection &amp;#39;http://bksrv.sranet.local:8080/ServicosMercados/UtilizadorImpl.svc&amp;#39;. 17 437ms 9:21:34 9:21:35&lt;br /&gt;&lt;/strong&gt;Close ChannelFactory. Contract type: &amp;#39;SRA.Mercados.Servicos.IServicoUtilizador&amp;#39;. 4 0ms 9:21:34 9:21:34 &lt;p&gt;&lt;strong&gt;Construct ServiceHost &amp;#39;SRA.Mercados.ServicosImpl.ServicoUtilizador&amp;#39;. 10 109ms 9:21:34 9:21:35&lt;br /&gt;Open ServiceHost &amp;#39;SRA.Mercados.ServicosImpl.ServicoUtilizador&amp;#39;. 64 93ms 9:21:35 9:21:35&lt;/strong&gt;&lt;br /&gt;Listen at &amp;#39;http://bksrv.sranet.local:8080/ServicosMercados/UtilizadorImpl.svc&amp;#39;. 6 62ms 9:21:35 9:21:35&lt;br /&gt;Listen at &amp;#39;https://bksrv.sranet.local/ServicosMercados/UtilizadorImpl.svc/mex&amp;#39;. 4 15ms 9:21:35 9:21:35&lt;br /&gt;Processing message 1. 5 15ms 9:21:35 9:21:35&lt;br /&gt;Execute &amp;#39;SRA.Mercados.Servicos.IServicoUtilizador.ObtemUtilizador&amp;#39;. 4 265ms 9:21:35 9:21:35 &lt;p&gt;The bold lines are where the problems are happening. Now, I really don&amp;#39;t understand why it takes 13 seconds for the process action on the client to hit the server (notice that server will only start its processing at 9:21:34 and that the client opens the channel at 9:21:21!). Now, I&amp;#39;m not really an expert on WCF, but it does seem like there&amp;#39;s something wrong going on here. What&amp;#39;s bothering me is that I don&amp;#39;t know what it is :)&lt;/p&gt; &lt;p&gt;It was getting late, so I only had time for testing one more thing: using &lt;a href="http://msdn2.microsoft.com/en-us/library/aa645516(VS.71).aspx"&gt;perfmon&lt;/a&gt; and see if I can get any info from it. I&amp;#39;ve only tried seeing one thing: the % of JIT time spent on a process. Guess what: the counter goes through the roof when I call a method of one of those services that take a long time! I&amp;#39;m still trying to understand what&amp;#39;s going on with those XP machines (specially because on my Windows 2008 server everything is working out smoothly), but it seems like there&amp;#39;s something that is making the Jitter do a lot of work when one of those methods gets called. I&amp;#39;m not sure on what it is since, as I&amp;#39;ve said, it&amp;#39;s really a simple method and I&amp;#39;ve already run &lt;a href="http://msdn2.microsoft.com/en-us/library/6t9t5wcf(VS.80).aspx"&gt;ngen&lt;/a&gt; on my code.&lt;/p&gt; &lt;p&gt;If anyone has any idea on what&amp;#39;s going on here please do share it with me! I&amp;#39;m running out of them and I still don&amp;#39;t understand what&amp;#39;s going on...thanks.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1539474" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/luisabreu/archive/tags/Trivia/default.aspx">Trivia</category><category domain="http://msmvps.com/blogs/luisabreu/archive/tags/WCF/default.aspx">WCF</category></item><item><title>Syndication and WCF</title><link>http://msmvps.com/blogs/luisabreu/archive/2008/01/16/syndication-and-wcf.aspx</link><pubDate>Wed, 16 Jan 2008 15:16:17 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1466029</guid><dc:creator>luisabreu</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/luisabreu/rsscomments.aspx?PostID=1466029</wfw:commentRss><comments>http://msmvps.com/blogs/luisabreu/archive/2008/01/16/syndication-and-wcf.aspx#comments</comments><description>&lt;p&gt;The latest release of .NET has added several interesting new things. One of those is support for Syndication. The System.ServiceModel.Web assembly has several classes that you can use to expose an ATOM or RSS feed. There&amp;#39;s already a cool &lt;a href="http://msdn.microsoft.com/msdnmag/issues/08/01/WCFinOrcas/default.aspx"&gt;article&lt;/a&gt; on how to achieve this&amp;nbsp; which has been published on MSDN, so I&amp;#39;m not going to bother you with the details (you can check the &lt;a href="http://samples.netfx3.com/PictureServices/"&gt;code online&lt;/a&gt;, but don&amp;#39;t download it because it&amp;#39;s not updated; instead, &lt;a href="https://www.cloudsamples.net/ContextBar/SourceViewer/PictureServices"&gt;browse&lt;/a&gt; the online version). The only thing I&amp;#39;d like to add to what is presented on the article is how to make Firefox interpret the RSS generated as RSS (instead of interpreting it like XML).&lt;/p&gt; &lt;p&gt;The problem with FF is that it will only consider the XML to be RSS feed if it has all the mandatory elements. If you&amp;#39;re like me, you&amp;#39;re probably going to go through all the public properties of the &lt;a href="http://msdn2.microsoft.com/en-us/library/system.servicemodel.syndication.syndicationfeed.aspx"&gt;SyndicationFeed&lt;/a&gt; object and you&amp;#39;ll set those that make sense. Unfortunately, there really isn&amp;#39;t any called link (though there&amp;#39;s a Links collection property) so I didn&amp;#39;t set up that element from my code (and &amp;lt;link&amp;gt; is one of the mandatory channel elements! - ok, my fault. Should have read the specs to see which items were mandatory...).&amp;nbsp; And that&amp;#39;s why&amp;nbsp; I lost almost one hour trying to understand why FF wasn&amp;#39;t applying its default XSLT stylesheet to my RSS content. I could see the XML, but then I got that awful message that said that there wasn&amp;#39;t any stylesheet file applied to my XML document. In fact, it looks like I wasn&amp;#39;t the only one that forgot to define the RSS link element: if you try to &lt;a href="http://samples.netfx3.com/pictureservices/feed.svc/pictures"&gt;run the code presented on the sample&lt;/a&gt;, you&amp;#39;ll see something like this:&lt;/p&gt; &lt;p&gt;&lt;a href="http://msmvps.com/blogs/luisabreu/WindowsLiveWriter/SyndicationandWCF_D603/Untitled_2.jpg"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px;" height="190" alt="Untitled" src="http://msmvps.com/blogs/luisabreu/WindowsLiveWriter/SyndicationandWCF_D603/Untitled_thumb.jpg" width="244" border="0" /&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;The only thing you need to fix the code is to add a link element to the feed, which can be done with code that looks like this:&lt;/p&gt; &lt;p&gt;feed.Links.Add(SyndicationLink.CreateAlternateLink(new Uri(&amp;quot;put a valid URI here&amp;quot;)));&lt;/p&gt; &lt;p&gt;where feed is a reference to a &lt;a href="http://msdn2.microsoft.com/en-us/library/system.servicemodel.syndication.syndicationfeed.aspx"&gt;SyndicationFeed&lt;/a&gt; object. &lt;/p&gt; &lt;p&gt;Now, if I only could make it add global namespaces, then I&amp;#39;d really be a happy man! (ok, You &lt;a href="http://msdn2.microsoft.com/en-us/library/system.servicemodel.syndication.syndicationfeed.aspx"&gt;can add namespaces&lt;/a&gt; to the &amp;lt;channel&amp;gt; element, but what I want is to add those declarations on the top &amp;lt;rss&amp;gt; element)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1466029" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/luisabreu/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://msmvps.com/blogs/luisabreu/archive/tags/WCF/default.aspx">WCF</category></item><item><title>Calling a WCF service from your Silverlight application</title><link>http://msmvps.com/blogs/luisabreu/archive/2007/06/12/calling-a-wcf-service-from-your-silverlight-application.aspx</link><pubDate>Tue, 12 Jun 2007 22:43:58 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:959280</guid><dc:creator>luisabreu</dc:creator><slash:comments>12</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/luisabreu/rsscomments.aspx?PostID=959280</wfw:commentRss><comments>http://msmvps.com/blogs/luisabreu/archive/2007/06/12/calling-a-wcf-service-from-your-silverlight-application.aspx#comments</comments><description>&lt;p&gt;Yesterday I talked about &lt;a href="http://msmvps.com/blogs/luisabreu/archive/2007/06/11/calling-web-services-from-your-silverlight-alpha-app.aspx"&gt;calling a traditional ASMX web service&lt;/a&gt; from your Silverlight app. Today, I&amp;#39;ll be talking about WCF services. As I&amp;#39;ve said yesterday, in the current release, you only&amp;nbsp;have tool support for getting a proxy to an ASMX web service (well, at least I&amp;#39;ve tried getting a web reference to a WCF service and it simply didn&amp;#39;t work - maybe i&amp;#39;m doing something wrong). However, nothing prevents you from creating your own proxy to make the call to&amp;nbsp; a WCF service.&lt;/p&gt; &lt;p&gt;Since the alpha version only understands JSON when it calls ASMX services, I&amp;#39;m also assuming that is the only way you have to get info from a WCF service. That being the case, you must start by configuring your &lt;a href="http://msmvps.com/blogs/luisabreu/archive/2007/05/22/calling-your-wcf-web-service-from-an-asp-net-ajax-page.aspx"&gt;service to use JSON as its message enconding format&lt;/a&gt;. &lt;/p&gt; &lt;p&gt;After doing that, it&amp;#39;s only a matter of&amp;nbsp; creating a new proxy class. Let me illustrate this with a quick example. Lets start by creating the dummy service:&lt;/p&gt; &lt;p&gt;[ServiceContract]&lt;br /&gt;public interface ITest&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; [OperationContract]&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; S DoWork();&lt;br /&gt;} &lt;p&gt;public class Test : ITest&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public S DoWork()&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; S a = new S();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; a.Address = &amp;quot;Funchal&amp;quot;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; a.Name = &amp;quot;Luis&amp;quot;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return a;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;} &lt;p&gt;Don&amp;#39;t forget to add the svc file :) (not shown here because there really isn&amp;#39;t much to show, right). As you can see, this is really a stupid service which returns an object that only has two properties. Here&amp;#39;s the S class (just for the sake of completeness):&lt;/p&gt; &lt;p&gt;[DataContract]&lt;br /&gt;public class S&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; [DataMember(Name=&amp;quot;Name&amp;quot;)]&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; private string name = &amp;quot;Luis&amp;quot;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; [DataMember(Name=&amp;quot;Address&amp;quot;)]&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; private string address= &amp;quot;Funchal&amp;quot;;  &lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public string Name&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; get { return name; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set { name = value; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }  &lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public string Address&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; get { return address; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set { address = value; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;} &lt;p&gt;Now, the fun begins :) You must start by definig the S class in your silverlight project. You can do this in several ways:&lt;/p&gt; &lt;ul&gt; &lt;li&gt;you can add an existing&amp;nbsp;cs file and then choose the link option (instead of clickin in the add button);&lt;/li&gt; &lt;li&gt;you might have built a dll with the previous type and then add it as reference to the service and silverlight projects;&lt;/li&gt; &lt;li&gt;there&amp;#39;s always the old copy/paste approach :)&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;After doing that, you need to build a new type (the proxy) which you&amp;#39;ll be&amp;nbsp;using to communicate with the service. You must really build a new class because all the cool methods of the the SoapHttpClientProtocol class that you need to make the service calls are protected (the truth is that nothing prevents you from using the BrowserHttpWebRequest class and then using the JavaScriptSerializer to serialize/deserialize the values. If you find this funny,&amp;nbsp;then by all means, go ahead and&amp;nbsp;do it;&amp;nbsp;i&amp;nbsp;prefer to build the class&amp;nbsp;in&amp;nbsp;30 seconds and then hit the coach to watch&amp;nbsp;tv :)) &amp;nbsp;. Here&amp;#39;s a simple proxy that lets you invoke the DoWork method in a sync fashion:&lt;/p&gt; &lt;p&gt;public class MyProxy:SoapHttpClientProtocol&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public S DoWork()&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;object[] obj = this.Invoke(&amp;quot;DoWork&amp;quot;, new ServiceParameter[0], typeof(S));&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return (S)obj[0];&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;} &lt;p&gt;Do notice the new ServiceParameter[0] value passed as the 2nd parameter of the Invoke method (needed because the method doesn&amp;#39;t receive any parameters; if it expected parameters, you just need to pack them in an array and pass them to the Invoke method)...Getting the async methods is as easy as adding 2 methods which call the BeginInvoke/EndInvoke methods inherited from the base class. Using the proxy is really simple, as you&amp;nbsp; can see from the following code: &lt;p&gt;MyProxy proxy = new MyProxy();&lt;br /&gt;proxy.Url = &amp;quot;url to the service&amp;quot;;&lt;br /&gt;S aux = proxy.DoWork();&lt;br /&gt;Debug.WriteLine(aux.Name +&amp;quot;-&amp;quot;+ aux.Address);&lt;/p&gt; &lt;p&gt;And that&amp;#39;s all for today. &lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=959280" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/luisabreu/archive/tags/WCF/default.aspx">WCF</category><category domain="http://msmvps.com/blogs/luisabreu/archive/tags/Silverlight/default.aspx">Silverlight</category></item><item><title>Calling your WCF web service from an ASP.NET AJAX page</title><link>http://msmvps.com/blogs/luisabreu/archive/2007/05/22/calling-your-wcf-web-service-from-an-asp-net-ajax-page.aspx</link><pubDate>Tue, 22 May 2007 14:44:19 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:919153</guid><dc:creator>luisabreu</dc:creator><slash:comments>13</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/luisabreu/rsscomments.aspx?PostID=919153</wfw:commentRss><comments>http://msmvps.com/blogs/luisabreu/archive/2007/05/22/calling-your-wcf-web-service-from-an-asp-net-ajax-page.aspx#comments</comments><description>&lt;p&gt;The 3.5 beta version of the .NET platform lets us use&amp;nbsp;JSON as the serialization format used by a web service call. The best of all is that this means that we can now call a web service from an ASP.NET AJAX page.&lt;/p&gt; &lt;p&gt;To do this, you need to add some entries to your configuration file (on the server side). Getting a proxy on the client side is a simple as adding a service reference through the ScriptManager control. Lets start by seeing the service code (which was generated by adding a new WCF service to an AJAX futures enabled web site):&lt;/p&gt; &lt;p&gt;[ServiceContract()]&lt;br /&gt;public interface ITest&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; [OperationContract]&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; string MyOperation1(string myValue);&lt;br /&gt;} &lt;/p&gt; &lt;p&gt;public class Test : ITest&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public string MyOperation1(string myValue)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return &amp;quot;Hello: &amp;quot; + myValue;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;} &lt;p&gt;The svc file looks like this: &lt;p&gt;&amp;lt;%@ ServiceHost Language=&amp;quot;C#&amp;quot; Debug=&amp;quot;true&amp;quot; Service=&amp;quot;Test&amp;quot; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CodeBehind=&amp;quot;~/App_Code/Test.cs&amp;quot; %&amp;gt; &lt;p&gt;Now you need to add an endpoint that is able to understand JSON. In my case, I wanted to expose a mex endpoint too, so I ended up with the following definitions for my web service: &lt;p&gt;&amp;lt;services&amp;gt; &lt;br /&gt;&amp;nbsp; &amp;lt;service name=&amp;quot;Test&amp;quot; behaviorConfiguration=&amp;quot;metadataSupport&amp;quot;&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;endpoint binding=&amp;quot;webHttpBinding&amp;quot; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;strong&gt;behaviorConfiguration=&amp;quot;jsonBehavior&amp;quot; &lt;br /&gt;&lt;/strong&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; contract=&amp;quot;ITest&amp;quot; &lt;br /&gt;&lt;strong&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; bindingConfiguration=&amp;quot;jsonBinding&amp;quot;&lt;/strong&gt;/&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;endpoint address=&amp;quot;mex&amp;quot; binding=&amp;quot;mexHttpBinding&amp;quot; contract=&amp;quot;IMetadataExchange&amp;quot;/&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;lt;/service&amp;gt;&lt;br /&gt;&amp;lt;/services&amp;gt; &lt;p&gt;As you can see, i&amp;#39;m using&amp;nbsp; a WebHttpBinding and I&amp;#39;m saying that there&amp;#39;s a new jsonBinding element which configures the traditional webHttpBinding that is introduced by default by the WCF framework. In this case, we&amp;#39;re just setting the message encoding to JSON: &lt;p&gt;&amp;lt;bindings&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;lt;webHttpBinding&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;strong&gt;&amp;lt;binding name=&amp;quot;jsonBinding&amp;quot; messageEncoding=&amp;quot;Json&amp;quot;/&amp;gt;&lt;br /&gt;&lt;/strong&gt;&amp;nbsp; &amp;lt;/webHttpBinding&amp;gt;&lt;br /&gt;&amp;lt;/bindings&amp;gt; &lt;p&gt;We also need to add a new behavior that looks like this: &lt;p&gt;&amp;lt;behaviors&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;lt;serviceBehaviors&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;behavior name=&amp;quot;metadataSupport&amp;quot;&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;serviceMetadata httpGetEnabled=&amp;quot;true&amp;quot; httpGetUrl=&amp;quot;&amp;quot;/&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/behavior&amp;gt; &lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;lt;/serviceBehaviors&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &lt;strong&gt;&amp;lt;endpointBehaviors&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;behavior name=&amp;quot;jsonBehavior&amp;quot;&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;enableWebScript /&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/behavior&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/endpointBehaviors&amp;gt; &lt;br /&gt;&lt;/strong&gt;&amp;lt;/behaviors&amp;gt; &lt;p&gt;And that&amp;#39;s it! the only thing you need to do to call this WCF service from your AJAX ASP.NET page is add a reference to the web service: &lt;p&gt;&amp;lt;asp:ScriptManager ID=&amp;quot;ScriptManager1&amp;quot; runat=&amp;quot;server&amp;quot;&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;lt;Services&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;strong&gt;&amp;lt;asp:ServiceReference Path=&amp;quot;Test.svc&amp;quot; /&amp;gt;&lt;br /&gt;&lt;/strong&gt;&amp;nbsp; &amp;lt;/Services&amp;gt;&lt;br /&gt;&amp;lt;/asp:ScriptManager&amp;gt; &lt;p&gt;Doing this ends up inserting the following js code in your page: &lt;p&gt;Type.registerNamespace(&amp;#39;tempuri.org&amp;#39;);&lt;br /&gt;ITest=function() {&lt;br /&gt;ITest.initializeBase(this);&lt;br /&gt;this._timeout = 0;&lt;br /&gt;this._userContext = null;&lt;br /&gt;this._succeeded = null;&lt;br /&gt;this._failed = null;&lt;br /&gt;}&lt;br /&gt;ITest.prototype={&lt;br /&gt;MyOperation1:function(myValue,succeededCallback, failedCallback, userContext) {&lt;br /&gt;return this._invoke(ITest.get_path(), &amp;#39;MyOperation1&amp;#39;,false,{myValue:myValue},succeededCallback,failedCallback,userContext); }}&lt;br /&gt;ITest.registerClass(&amp;#39;ITest&amp;#39;,Sys.Net.WebServiceProxy);&lt;br /&gt;ITest._staticInstance = new ITest();&lt;br /&gt;ITest.set_path = function(value) { ITest._staticInstance._path = value; }&lt;br /&gt;ITest.get_path = function() { return ITest._staticInstance._path; }&lt;br /&gt;ITest.set_timeout = function(value) { ITest._staticInstance._timeout = value; }&lt;br /&gt;ITest.get_timeout = function() { return ITest._staticInstance._timeout; }&lt;br /&gt;ITest.set_defaultUserContext = function(value) { ITest._staticInstance._userContext = value; }&lt;br /&gt;ITest.get_defaultUserContext = function() { return ITest._staticInstance._userContext; }&lt;br /&gt;ITest.set_defaultSucceededCallback = function(value) { ITest._staticInstance._succeeded = value; }&lt;br /&gt;ITest.get_defaultSucceededCallback = function() { return ITest._staticInstance._succeeded; }&lt;br /&gt;ITest.set_defaultFailedCallback = function(value) { ITest._staticInstance._failed = value; }&lt;br /&gt;ITest.get_defaultFailedCallback = function() { return ITest._staticInstance._failed; }&lt;br /&gt;ITest.set_path(&amp;quot;/AJAXFuturesEnabledWebSite2/Test.svc&amp;quot;);&lt;br /&gt;ITest.MyOperation1= function(myValue,onSuccess,onFailed,userContext) {ITest._staticInstance.MyOperation1(myValue,onSuccess,onFailed,userContext); } &lt;p&gt;which really looks similar to waht you get when you add JSON support to an ASMX web service.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=919153" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/luisabreu/archive/tags/MS+AJAX/default.aspx">MS AJAX</category><category domain="http://msmvps.com/blogs/luisabreu/archive/tags/WCF/default.aspx">WCF</category></item><item><title>Creating and using a test certificate with a WCF service</title><link>http://msmvps.com/blogs/luisabreu/archive/2007/01/19/creating-and-using-a-test-certificate-with-a-wcf-service.aspx</link><pubDate>Fri, 19 Jan 2007 12:10:02 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:504336</guid><dc:creator>luisabreu</dc:creator><slash:comments>2</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/luisabreu/rsscomments.aspx?PostID=504336</wfw:commentRss><comments>http://msmvps.com/blogs/luisabreu/archive/2007/01/19/creating-and-using-a-test-certificate-with-a-wcf-service.aspx#comments</comments><description>&lt;p&gt;Since I've just lost a couple of hours trying to configure my WCF service to use SSL, I've though I'd put the steps here for self-reference.&lt;/p&gt; &lt;p&gt;The first thing you need to do is to create a test certificate. Since I'm running Vista+IIS 7 (workstation), I've used makecert with something like this:&lt;/p&gt; &lt;p&gt;makecert -sr LocalMachine -ss My -a sha1 -n "CN=url-you're-using" -sky exchange -pe&lt;/p&gt; &lt;p&gt;Basically, the previous command creates a new certificate and puts it in the Personal folder of the local machine store. It also configures the private key so that it needs to be exported.&lt;/p&gt; &lt;p&gt;After doing this, it will be necessary to export the certificate and all the certificates in the certification path - normally, one: Root Agency. Then you'll have to install them in the clients that want to use the client (normally, the root agency certificate will be installed in the trusted publishers and the test certificate should be put in the trusted people store of the local machine).&lt;/p&gt; &lt;p&gt;After performing these steps, you might still need to give access permissions to the private key&amp;nbsp; to the service running the process that hosts the WCF service (WCF sampls have a tool called FindPrivateKey that helps you in finding the file that has the private key of the service).&lt;/p&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=504336" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/luisabreu/archive/tags/WCF/default.aspx">WCF</category></item></channel></rss>