<?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>DotNetDude.com</title>
  <link rel="alternate" type="text/html" href="http://www.dotnetdude.com/" />
  <link rel="self" href="http://www.dotnetdude.com/SyndicationService.asmx/GetAtom" />
  <logo>http://www.dotnetdude.com/feed-icon-24x24.gif</logo>
  <icon>favicon.ico</icon>
  <updated>2010-07-28T11:48:36.933187-05:00</updated>
  <author>
    <name>Miguel A. Castro</name>
  </author>
  <subtitle>Miguel A. Castro's Blog</subtitle>
  <id>http://www.dotnetdude.com/</id>
  <generator uri="http://dasblog.info/" version="2.3.9074.18820">DasBlog</generator>
  <entry>
    <title>A Cool Technique For Reporting WCF Operation Calls On Your Host Console (dev-only of course)</title>
    <link rel="alternate" type="text/html" href="http://www.dotnetdude.com/2010/07/28/ACoolTechniqueForReportingWCFOperationCallsOnYourHostConsoleDevonlyOfCourse.aspx" />
    <id>http://www.dotnetdude.com/PermaLink,guid,7f97d63e-24c6-4455-a7c8-6452e0b23b19.aspx</id>
    <published>2010-07-27T21:57:11.96225-05:00</published>
    <updated>2010-07-28T11:47:20.2442981-05:00</updated>
    <category term="Dev Stuff" label="Dev Stuff" scheme="http://www.dotnetdude.com/CategoryView,category,DevStuff.aspx" />
    <category term="WCF" label="WCF" scheme="http://www.dotnetdude.com/CategoryView,category,WCF.aspx" />
    <author>
      <name>Miguel A. Castro</name>
    </author>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <strong>
            <font color="#ff0000">Note: Using a Console app for hosting should be done
for development only !</font>
          </strong>
        </p>
        <p>
Now that the disclaimer is out of the way, I currently doing some development work
for a customer and I had the need to know every time any of my services receives a
call.  Since I do my development using a console application for service hosting,
it was easy enough to write out to the console from each service operation. 
Of course, putting code in every method was possible but not only would it be time
consuming, to turn it off later would be a pain.  The answer needed to be something
that gets hit on every operation.  Since WCF is essentially one giant inversion
of control container, I knew there was a point I could tap into before any operation
call.
</p>
        <p>
Enter behaviors !
</p>
        <p>
This turned out to be a multi-step process but once it’s in my library of WCF stuff,
I can reuse it and it actually turned out to be quite cool.  I’ll explain each
step and the reasons for the step.<br /></p>
        <p>
          <strong>
            <font size="2">Step 1 – Write a custom Parameter Inspector</font>
          </strong>
        </p>
        <p>
The first class you need to write is one that implements the <strong>IParameterInspector</strong> which
is in the <strong>System.ServiceModel.Dispatcher</strong> namespace.  This class
will later be installed in such a way that it gets hit on every operation call. 
The operation name is one of the arguments you have access to, as well as all the
operation arguments which I don’t need in this case.
</p>
        <p>
The methods in this implementation are <strong>BeforeCall</strong> and <strong>AfterCall</strong>,
and it is the <strong>BeforeCall</strong> that I’m interested in.  The code I’ll
place in this method very simply outputs something out to the console using <strong>Console.Writeline</strong>.
</p>
        <p>
Unfortunately the name of the service is not passed into this method so I need to
get that into this class using a custom constructor; you’ll see how I’ll get it to
the class later.
</p>
        <p>
Here’s the code for my <strong>ConsoleReportInspector</strong> class:
</p>
        <p>
 
</p>
        <pre class="brush: csharp;">public class ConsoleReportInspector : IParameterInspector
{
    public ConsoleReportInspector(string serviceName)
    {
        _ServiceName = serviceName;
    }

    string _ServiceName = string.Empty;

    void IParameterInspector.AfterCall(string operationName, object[] outputs, object returnValue, object correlationState)
    {
    }

    object IParameterInspector.BeforeCall(string operationName, object[] inputs)
    {
        Console.WriteLine(string.Format("{0} - '{1}.{2}' operation called.", DateTime.Now.ToLongTimeString(), _ServiceName, operationName));

        return null;
    }
}

</pre>
        <p>
          <br />
 
</p>
        <p>
          <font size="2">
            <strong>Step 2 – Install the class using an Operation Behavior</strong>
          </font>
        </p>
        <p>
In order to install the parameter inspector, I’ll need to write a custom operation
behavior class.  This is a class that implements the <strong>IOperationBehavior</strong> interface. 
You need to remove the throw to <strong>NotImplementedException</strong> from all
the methods; and the method of concern here is <strong>ApplyDispatchBehavior</strong>.
</p>
        <p>
The name of the service being called is accessible through the <strong>Parent</strong> property
of the <strong>dispatchOperation</strong> argument.  I need to instantiate my <strong>ConsoleReportInspector</strong> class
and send the service name into the constructor I added earlier.  Afterward, I
just need to add my parameter inspector class to the list of parameter inspectors
accessible in this behavior. 
</p>
        <p>
I also inherited this class from the <strong>System.Attribute</strong> class so I
can use it as an operation behavior attribute on individual operations if I wanted. 
This is just for flexibility since I plan on hooking this into a service so it affects
all operations.
</p>
        <p>
Here’s the code for my <strong>ConsoleReportOperationBehaviorAttribute</strong> class:
</p>
        <p>
 
</p>
        <pre class="brush: csharp;">[AttributeUsage(AttributeTargets.Method)]
public class ConsoleReportOperationBehaviorAttribute : Attribute, IOperationBehavior
{
    void IOperationBehavior.AddBindingParameters(OperationDescription operationDescription, BindingParameterCollection bindingParameters)
    {
    }

    void IOperationBehavior.ApplyClientBehavior(OperationDescription operationDescription, ClientOperation clientOperation)
    {
    }

    void IOperationBehavior.ApplyDispatchBehavior(OperationDescription operationDescription, DispatchOperation dispatchOperation)
    {
        string serviceName = dispatchOperation.Parent.Type.Name;
        dispatchOperation.ParameterInspectors.Add(new ConsoleReportInspector(serviceName));
    }

    void IOperationBehavior.Validate(OperationDescription operationDescription)
    {
    }
}

</pre>
        <br />
        <p>
As-is, I can simply decorate a service operation with [ConsoleReportOperationBehavior]
and if hosted on a console application, you’ll see output to the console when the
decorated operation is called.
</p>
        <p>
 
</p>
        <p>
          <strong>
            <font size="2">Step 3 – Install the operation behavior on all operations using
a Service Behavior</font>
          </strong>
        </p>
        <p>
Next I need to write a service behavior.  This is a behavior that gets installed
when the service loads (the host is opened).  The job of this behavior is to
install my operation behavior on all the service operations.  A service behavior
is a class that implement the <strong>IServiceBehavior</strong> interface.  Like
before, I’ll remove the exception calls and once again the method I’m interested in
is <strong>ApplyDispatchBehavior</strong>.
</p>
        <p>
I’m going to iterate through all the endpoints of this service, which are accessible
through the serviceDescription argument, and for each endpoint I will iterate through
the operations of the contract of each endpoint.  To each operation I will add
an instance of my ConsoleReportOperationBehaviorAttribute class.
</p>
        <p>
This class too I will inherit from <strong>Attribute</strong> so I can use it to decorate
a service in the case that I wanted to take this approach at some time.  
</p>
        <p>
Here’s the code for my <strong>ConsoleReportServiceBehaviorAttribute</strong> class:
</p>
        <p>
 
</p>
        <pre class="brush: csharp;">[AttributeUsage(AttributeTargets.Class)]
public class ConsoleReportServiceBehaviorAttribute : Attribute, IServiceBehavior
{
    void IServiceBehavior.AddBindingParameters(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase, System.Collections.ObjectModel.Collection&lt;ServiceEndpoint&gt; endpoints, BindingParameterCollection bindingParameters)
    {
    }

    void IServiceBehavior.ApplyDispatchBehavior(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase)
    {
        foreach (ServiceEndpoint endpoint in serviceDescription.Endpoints)
            foreach (OperationDescription operation in endpoint.Contract.Operations)
                operation.Behaviors.Add(new ConsoleReportOperationBehaviorAttribute());
    }

    void IServiceBehavior.Validate(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase)
    {
    }
}

</pre>
        <p>
 
</p>
        <p>
          <font size="2">
            <strong>Step 4 – Apply the service behavior to any service I want programmatically
at the host</strong>
          </font>
        </p>
        <p>
Whatever approach you take to hosting, all you need to do is access each instance
of <strong>ServiceHost</strong> and add the service behavior to the list of behaviors
in the host.  I have my own techniques for hosting which include some custom
declarative stuff to allow me to turn hosting on and off at will through config. 
I also like to separate the accumulation of my <strong>ServiceHost</strong> instances
from the actual application that will do the hosting.  This way I can move it
to a Windows Service when I’m ready to go to production.
</p>
        <p>
Here’s the code that installs the behavior:
</p>
        <p>
 
</p>
        <p>
 
</p>
        <pre class="brush: csharp;">ConsoleReportServiceBehaviorAttribute behavior = serviceHost.Host.Description.Behaviors.Find&lt;ConsoleReportServiceBehaviorAttribute&gt;();
if (behavior == null)
    host.Description.Behaviors.Add(new ConsoleReportServiceBehaviorAttribute());
</pre>
        <br />
        <p>
 
</p>
        <p>
The <strong>host</strong> variable is an instance of <strong>ServiceHost</strong>. 
I perform the code above in between a config check so I can toggle it off at will.
</p>
        <p>
The end result is quite cool since when turned on, every call to any of your services
will be shown on the console.
</p>
        <p>
 
</p>
        <h3>
          <em>Until next time…</em>
        </h3>
        <img width="0" height="0" src="http://www.dotnetdude.com/aggbug.ashx?id=7f97d63e-24c6-4455-a7c8-6452e0b23b19" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Announcing DevsForWendy, a benefit event for Wendy Friedlander!</title>
    <link rel="alternate" type="text/html" href="http://www.dotnetdude.com/2010/07/03/AnnouncingDevsForWendyABenefitEventForWendyFriedlander.aspx" />
    <id>http://www.dotnetdude.com/PermaLink,guid,1a7b7691-d00a-4a1c-9320-0ff7d93d36ab.aspx</id>
    <published>2010-07-03T16:18:06.117-05:00</published>
    <updated>2010-07-28T11:47:41.8340403-05:00</updated>
    <category term="Speaking Events" label="Speaking Events" scheme="http://www.dotnetdude.com/CategoryView,category,SpeakingEvents.aspx" />
    <author>
      <name>Miguel A. Castro</name>
    </author>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <em>
            <strong>The following text was originall written by Rachel Appel, Developer Evangelist
for the NY region:</strong>
          </em>
        </p>
        <p>
          <br />
On July 7th, 2010 at 7pm in Manhattan the NYC area developer community will be holding
an event to benefit NYC-area .NET software developer Wendy Friedlander.<br /><br />
Wendy is a 30 year old software agilista from Long Island. She's a strong WPF developer
and a firm believer in the agile method of development including pair programming
and TDD. Wendy is wife and mother of a beautiful girl named Kaylee who will be 2 in
August of this year. In August of 2009 Wendy learned that she had a rare and aggressive
pediatric cancer called aveolar rhabdomyosarcoma. Her treatment consists of high dose
chemotherapy and radiation. She has had to leave her job, and her husband has been
forced into part time work in order to care for their daughter.<br />
Come and be part of something special!<br /><br />
We are very pleased to be able to announce that the evening will include a unique
presentation by noted .NET luminary and author Charles Petzold on an obscure (but
interesting) chapter in the history of computing with appearances (in chronological
order) by Cicero, Galileo, Kepler, Newton, Fourier, Charles Darwin, Lord Kelvin, Madame
Curie, and Albert Einstein.<br /><br />
In addition, Miguel Castro has volunteered to provide a very special talk for the
attendees where he promises to demonstrate some of his own pet software development
projects for us!<br /><br />
In addition to the opportunity to see these unique talks, every attendee will be given
a free unlimited 30-day subscription to TekPub (<a href="http://www.tekpub.com)/">http://www.tekpub.com)</a>,
the video screencasting site with hours and hours of screencasts on topics including
Silverlight, Entity Framework, NHibernate, JQuery, Ruby-on-Rails, developing for the
iPhone, and developing for Android. Everyone who attends the event is guaranteed this
free subscription just for their cost of attending.<br /><br />
Other SWAG that will be raffled off to attendees includes multiple software licenses
for the following products:<br />
* JetBrains Resharper, DotTrace, and DotCover!<br />
* Developer Express CodeRush, Refactor! Pro, and DXperience Suite (every control they
make!)<br />
* Telerik RAD Controls!<br />
* TypeMock Isolator!<br />
* Visual Studio MSDN Ultimate i-year Subscriptions!<br />
* ...and more!<br /><br />
Specific details for this event including location, RSVP links, and more can be found
at the site:<br /><a href="http://www.DevsForWendy.com">http://www.DevsForWendy.com</a><br /><br />
For more details about the event, please see this comprehensive blog post by Steve
Bohlen:<br /><a href="http://unhandled-exceptions.com/blog/index.php/2010/06/30/devsforwendy/">http://unhandled-exceptions.com/blog/index.php/2010/06/30/devsforwendy/</a><br /><br />
Attendance is $75 per person with all proceeds going to Wendy and her family. Since
dinner will consist of pizza and soda, you can be assured that more than $65 of that
attendance fee will go to benefit the Friedlanders directly!<br /><br />
Even if you cannot attend the benefit event itself, please consider using the [Donate]
link on the site (<a href="http://devsforwendy.com/donate.html">http://devsforwendy.com/donate.html</a>)
to make a contribution directly to Wendy and her family. Any amount you may be able
to spare would be very much appreciated -- whether $1, $5, $10, $50, or more it all
adds up and it all goes to a great cause!<br /><br />
If there are any questions, please do not hesitate to email either Sara Chipps (<a href="mailto:sarajchipps@gmail.com">sarajchipps@gmail.com</a>)
or Steve Bohlen (<a href="mailto:sbohlen@gmail.com">sbohlen@gmail.com</a>) directly.<br />
Otherwise, please consider either attending the event, making a direct donation, or
both!
</p>
        <img width="0" height="0" src="http://www.dotnetdude.com/aggbug.ashx?id=1a7b7691-d00a-4a1c-9320-0ff7d93d36ab" />
      </div>
    </content>
  </entry>
  <entry>
    <title>WCF Firestarter Post-Brief</title>
    <link rel="alternate" type="text/html" href="http://www.dotnetdude.com/2010/06/21/WCFFirestarterPostBrief.aspx" />
    <id>http://www.dotnetdude.com/PermaLink,guid,b91b3c87-684b-4e83-8846-256e0243a29c.aspx</id>
    <published>2010-06-21T12:42:35.819375-05:00</published>
    <updated>2010-07-28T11:47:57.9248033-05:00</updated>
    <category term="Speaking Events" label="Speaking Events" scheme="http://www.dotnetdude.com/CategoryView,category,SpeakingEvents.aspx" />
    <author>
      <name>Miguel A. Castro</name>
    </author>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
Wow, what a day!
</p>
        <p>
The first ever WCF Firestarter event was yesterday at the New York City Microsoft
offices and it was awesome.  The agenda was simple and to-the-point.
</p>
        <p>
I started the day with the first two sessions, introducing everyone to WCF an then
segueing them into more advanced binding and behavior configurations by showing the
most commonly used configuration scenarios.  Seems that transaction handling
was the more popular one there.  After lunch, one of our local DEs, <a href="http://blogs.msdn.com/b/peterlau/" target="_blank">Peter
Laudati</a> took the stage to talk about WCF REST capabilities.  After which, <a href="http://www.donxml.com" target="_blank">Don
Demsak</a> introduced everyone to WCF Data Services, rounding out the capability set
of this technology.  I came back on at the end of the day to talk about the new
WCF 4 stuff and it seems that routing capabilities was the highlight on that one. <a href="http://www.dotnetdude.com/content/binary/WindowsLiveWriter/WCFFirestarterPostMordem_BFCA/DSC00290.jpg"><img style="border-right-width: 0px; margin: 0px 0px 20px 20px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="" border="0" alt="" align="right" src="http://www.dotnetdude.com/content/binary/WindowsLiveWriter/WCFFirestarterPostMordem_BFCA/DSC00290_thumb.jpg" width="244" height="184" /></a></p>
        <p>
          <a href="http://www.dotnetdude.com/content/binary/WindowsLiveWriter/WCFFirestarterPostMordem_BFCA/DSC00280.jpg">
            <img style="border-right-width: 0px; margin: 0px 20px 0px 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="" border="0" alt="" align="left" src="http://www.dotnetdude.com/content/binary/WindowsLiveWriter/WCFFirestarterPostMordem_BFCA/DSC00280_thumb.jpg" width="244" height="184" />
          </a> 
Peter and Don did an awesome job, as always.  As for my performance, I was happy
but I’ll let others blog about what they thought.  All in all, I was comfortable
with the outcome and I think the crowd was pleased.  We had about 200 attendees
in the room and another 108 on LiveMeeting.  The event brought in people from
around the country and world I think.  I put out a call for listeners to send
me an email telling me where they are and immediately I received one from a listener
in Southern Australia.  Kudos goes out to Coral who was listening in the middle
of the night, down under.
</p>
        <p>
 
</p>
        <p>
 
</p>
        <p>
When I took a poll at the beginning as to how many WCF users I had in the room, the
count was extremely low (about 10) so I think this was definitely the target audience.
</p>
        <p>
          <a href="http://www.dotnetdude.com/content/binary/WindowsLiveWriter/WCFFirestarterPostMordem_BFCA/WCFFS_Crowd_2.jpg">
            <img style="border-right-width: 0px; margin: 0px 0px 20px 20px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="" border="0" alt="" align="right" src="http://www.dotnetdude.com/content/binary/WindowsLiveWriter/WCFFirestarterPostMordem_BFCA/WCFFS_Crowd_thumb.jpg" width="353" height="132" />
          </a>
          <a href="http://www.dotnetdude.com/content/binary/WindowsLiveWriter/WCFFirestarterPostMordem_BFCA/DSC00313.jpg">
            <img style="border-right-width: 0px; margin: 0px 20px 0px 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="" border="0" alt="" align="left" src="http://www.dotnetdude.com/content/binary/WindowsLiveWriter/WCFFirestarterPostMordem_BFCA/DSC00313_thumb.jpg" width="244" height="184" />
          </a>Thank
you to Peter for getting Microsoft behind this event and for handling all the logistics,
and thanks for letting me spearhead the agenda and content for the event.  I
had a great time doing it.  O’Reilly was awesome and sent me 5 copies of Michele’s
book and 5 of Juval’s to give away.  Also thanks to <a href="http://www.devexpress.com" target="_blank">Developer
Express</a> and <a href="http://www.telerik.com" target="_blank">Telerik</a> for donating
product licenses for the event.  Both those companies can always be counted on
to support these kind of events and their giveaways were the first ones to disappear. 
Also, we had a tech out in Redmond with us every step of the way, monitoring the live
feed and standing by in case of problems and we couldn’t have been more grateful to
Erik Ostrowski for his help and for being there at 3am his time, to help us out.
</p>
        <p>
As a goof, I have away a couple of “What Would Miguel Do?” t-shirts that a client
of mine made for me.  I couldn’t believe it when one of the guys put it on and
wore it for the entire event.  It was certainly flattering a very cool gesture.
</p>
        <p>
 
</p>
        <p>
 
</p>
        <p>
 
</p>
        <p>
I think that Danny, the DE down in the Philly market wants to put this event on in
his territory so I guess that’s where we’ll be taking it next.
</p>
        <p>
Thanks again to Microsoft, the local DEs, Don, and all the attendees and listener
for help making it a great event.
</p>
        <h3>
          <em>Until next time…</em>
        </h3>
        <img width="0" height="0" src="http://www.dotnetdude.com/aggbug.ashx?id=b91b3c87-684b-4e83-8846-256e0243a29c" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Awesome book on public speaking</title>
    <link rel="alternate" type="text/html" href="http://www.dotnetdude.com/2010/05/31/AwesomeBookOnPublicSpeaking.aspx" />
    <id>http://www.dotnetdude.com/PermaLink,guid,92bb2d03-ced5-434e-b2aa-98eadfaf4b12.aspx</id>
    <published>2010-05-31T10:23:36.4565-05:00</published>
    <updated>2010-05-31T10:23:36.4565-05:00</updated>
    <author>
      <name>Miguel A. Castro</name>
    </author>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <a href="http://www.dotnetdude.com/content/binary/WindowsLiveWriter/Awesomebookonpublicspeaking_A018/book-cps-sm_2.png">
            <img style="border-bottom: 0px; border-left: 0px; display: inline; margin-left: 0px; border-top: 0px; margin-right: 0px; border-right: 0px" title="book-cps-sm" border="0" alt="book-cps-sm" align="right" src="http://www.dotnetdude.com/content/binary/WindowsLiveWriter/Awesomebookonpublicspeaking_A018/book-cps-sm_thumb.png" width="104" height="135" />
          </a>I
just zoomed through <a href="http://www.scottberkun.com" target="_blank">Scott Berkun’s</a> book,
“<a href="http://www.amazon.com/Confessions-Public-Speaker-Scott-Berkun/dp/0596801998/ref=pd_bxgy_b_img_b" target="_blank">Confessions
of a Public Speaker</a>”, which was recommended to me by my friend <a href="http://www.donxml.com" target="_blank">Don
Demsak</a>.  I can’t recommend this book enough to those of you who like me are
already public speakers, as well as to those of you who want to break into speaking. 
Scott delivers his point in an extremely entertaining way while actually sticking
to it; which is exactly what the book preaches to do when speaking.  The book
is written in a first-person form and like the author, I agree this is a great way
of keeping a reader engaged.  I found it gratifying that a lot of points he recommends
in his book are techniques I use today, but more importantly I found so many where
I plan to improve that I’m actually excited about my upcoming Tech-Ed presentation
and already have ideas for bettering my delivery using stuff I learned here. 
</p>
        <p>
The book is a quick read, not only because it’s only a couple of hundred pages but
because I found it so entertaining and interesting, it was hard to put down. 
Check this one out cause you won’t regret it.
</p>
        <h3>
          <em>Until next time…</em>
        </h3>
        <img width="0" height="0" src="http://www.dotnetdude.com/aggbug.ashx?id=92bb2d03-ced5-434e-b2aa-98eadfaf4b12" />
      </div>
    </content>
  </entry>
  <entry>
    <title>What I learned the hard way about WCF REST Services Caching</title>
    <link rel="alternate" type="text/html" href="http://www.dotnetdude.com/2010/05/24/WhatILearnedTheHardWayAboutWCFRESTServicesCaching.aspx" />
    <id>http://www.dotnetdude.com/PermaLink,guid,6f2ef28b-fbd6-4f3c-b978-b999b4c230c4.aspx</id>
    <published>2010-05-24T15:50:14.468-05:00</published>
    <updated>2010-07-28T11:48:36.933187-05:00</updated>
    <category term="Dev Stuff" label="Dev Stuff" scheme="http://www.dotnetdude.com/CategoryView,category,DevStuff.aspx" />
    <category term="WCF" label="WCF" scheme="http://www.dotnetdude.com/CategoryView,category,WCF.aspx" />
    <author>
      <name>Miguel A. Castro</name>
    </author>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
WCF 4.0 incorporates the features previously only obtainable via the REST Starter
kit for .NET 3.5.  Among the features included is the ability to cache REST requests
using a similar technique to caching ASP.NET pages.
</p>
        <p>
The 4.0 version of the <strong>System.ServiceModel.Web</strong> assembly includes
an attribute called <a href="http://msdn.microsoft.com/en-us/library/system.servicemodel.web.aspnetcacheprofileattribute.aspx" target="_blank">AspNetCacheProfile</a> which
takes a string as an argument.  The attribute is to be used on a service contract
operation as follows:
</p>
        <pre class="brush: csharp; ruler: true;">[OperationContract]
[WebGet(UriTemplate = "/{name}/getGreeting.xml",
        BodyStyle = WebMessageBodyStyle.Bare,
        RequestFormat = WebMessageFormat.Xml,
        ResponseFormat = WebMessageFormat.Xml)]
[AspNetCacheProfile("CacheFor10Seconds")]
string GetGreetingXml(string name);
</pre>
        <p>
 
</p>
        <p>
The string points to a cache profile to be defined in the <strong><system.web></system.web></strong>config section as follows:
</p>
        <pre class="brush: xml; ruler: true;">
          <caching>
            <outputcachesettings>
              <outputcacheprofiles>
                <add varybyparam="format" duration="10" name="CacheFor10Seconds" />
              </outputcacheprofiles>
            </outputcachesettings>
          </caching>
        </pre>
        <p>
 
</p>
        <p>
As you can see, this is pretty much identical to setting up cache profiles for ASPX
pages.  The effect is pretty much what you would expect, the caching of a REST
request.  This can be proven and tested by implementing the above contract as
such:
</p>
        <pre class="brush: csharp; ruler: true;">public string GetGreetingXml(string name)
{
    return string.Format("Hello {0}.  The time is {1}", name, DateTime.Now.ToLongTimeString());
}
</pre>
        <p>
 
</p>
        <p>
Now you can refresh the request and you’ll see the same time for 10 seconds before
it changes; once again, the same effect as in caching an ASPX page.
</p>
        <p>
So what did I learn the hard way you ask?  Well, common sense dictates that the
request go through ASP.NET in order to use its caching capability.  This not
only means that you have to host in IIS or WAS, but also that you need to turn on
ASP.NET compatibility mode.  This shifts the processing of the REST request over
to an HTTP handler that also sets an HTTP Context for you, something not normally
done with conventional IIS hosting for REST services.  To turn this on, you must
enable it in the <strong><servicehostingenvironment></servicehostingenvironment></strong>section under the <strong><system.servicemodel></system.servicemodel></strong>section using the <strong>aspNetCompatibilityEnabled</strong> attribute. 
Not only that, but you have to “allow” it on the service using the <a href="http://msdn.microsoft.com/en-us/library/system.servicemodel.activation.aspnetcompatibilityrequirementsattribute.aspx" target="_blank">AspNetCompatibilityRequirements</a> attribute.
</p>
        <p>
This part was not a surprise for me since I was already familiar with this technique
and the added scope your service receives because it.  I’m referring to the entire
HTTP Context including session, application, cache, etc.  Keep in mind that this
is not for everything and should be used in very specific scenarios as it ties the
service to the hosting style quite tightly.
</p>
        <p>
What drove me crazy is something I’m surprised I did not notice in the past and that
is the fact that your REST requests will not work while using the Visual Studio development
server.  Meaning you need to create an application in IIS and run it that way. 
No big deal but it drove me a little crazy since the meta data exposure worked fine,
and so did the new HTML Help pages (another new feature in WCF 4.0 For REST). 
But the second I tried to request one of my URLs, it bombed out.  Once I set
up my application under IIS, everything was fine.
</p>
        <p>
I have to give credit where it’s due and thank Jon Flanders.  I found the answer
in his book <a href="http://www.amazon.com/RESTful-NET-Build-Consume-Services/dp/0596519206/ref=sr_1_1?ie=UTF8&amp;s=books&amp;qid=1274734177&amp;sr=1-1" target="_blank">Restful
.NET</a> from O’Reilly press.
</p>
        <h3>
          <em>Until next time…</em>
        </h3>
        <img width="0" height="0" src="http://www.dotnetdude.com/aggbug.ashx?id=6f2ef28b-fbd6-4f3c-b978-b999b4c230c4" />
      </div>
    </content>
  </entry>
  <entry>
    <title>NYC WCF Firestarter – Saturday June 19, 2010</title>
    <link rel="alternate" type="text/html" href="http://www.dotnetdude.com/2010/05/18/NYCWCFFirestarterSaturdayJune192010.aspx" />
    <id>http://www.dotnetdude.com/PermaLink,guid,6ddef1f4-fe6a-4e1e-b207-3af8bf4290dc.aspx</id>
    <published>2010-05-18T15:25:36.611-05:00</published>
    <updated>2010-05-24T15:57:07.53125-05:00</updated>
    <category term="Speaking Events" label="Speaking Events" scheme="http://www.dotnetdude.com/CategoryView,category,SpeakingEvents.aspx" />
    <category term="WCF" label="WCF" scheme="http://www.dotnetdude.com/CategoryView,category,WCF.aspx" />
    <author>
      <name>Miguel A. Castro</name>
    </author>
    <content type="html">&lt;p&gt;
&lt;a href="https://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032452076&amp;Culture=en-US"&gt;&lt;img style="display: block; float: none; margin-left: auto; margin-right: auto" title="WCFFirestarterNYC" border="0" alt="WCFFirestarterNYC" src="http://blogs.msdn.com/blogfiles/peterlau/WindowsLiveWriter/NYCWCFFirestarterSaturdayJune192010_E10F/WCFFirestarterNYC_1.png" width="737" height="76"&gt;&lt;/a&gt;
&lt;br&gt;
&lt;/p&gt;
&lt;p&gt;
Stop starting new projects with ASMX Web Services or .NET Remoting! OK, now that we
have your attention, let’s get serious. These two
&lt;/p&gt;
&lt;p&gt;
technologies are so 2002! You need to start learning Windows Communication Foundation
(WCF) if you haven't already. This is &lt;i&gt;the &lt;/i&gt;platform for connected applications
on the Windows platform going forward, and you know what? It's easier to use than
you may think. 
&lt;p&gt;
Even if you've been tinkering with writing basic services in WCF for a while but haven't
dived into anything more advanced, you should come in for the &lt;a href="https://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032452076&amp;Culture=en-US"&gt;NYC
WCF Firestarter&lt;/a&gt;. 
&lt;p&gt;
Join us for a full day of nothing but WCF sessions. Ranging from an introductory so
you can hit the ground running, and with best practices, continuing with topics involving
the most important features of WCF, and ending with some cutting edge material on
REST &amp; Microsoft's new service bus and Azure technology in .NET 4.0. 
&lt;p&gt;
We’ve got a great line up of speakers! Presenting at the &lt;a href="https://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032452076&amp;Culture=en-US"&gt;NYC
WCF Firestarter&lt;/a&gt; will be &lt;a href="http://dotnetdude.com/"&gt;Miguel Castro&lt;/a&gt;, &lt;a href="http://www.donxml.com"&gt;Don
Demsak&lt;/a&gt;, and myself (&lt;a href="http://www.peterlaudati.com"&gt;Peter Laudati&lt;/a&gt;). 
&lt;p&gt;
&lt;a href="http://www.bing.com/maps/default.aspx?v=2&amp;cp=40.76059~-73.97855&amp;lvl=15&amp;style=r&amp;sp=aN.40.76085_-73.9794_Microsoft%2520NYC%2520Office_1290%2520Ave%2520Of%2520The%2520Americas&amp;mkt=en-us&amp;FORM=LLWR"&gt;&lt;img style="display: inline; margin-left: 0px; margin-right: 0px" alt="Microsoft NYC Office - 1290 Ave of the Americas - 6th Floor" align="right" src="http://blogs.msdn.com/blogfiles/peterlau/WindowsLiveWriter/NYCWCFFirestarterSaturdayJune192010_E10F/map-8028836e8932.jpg" width="320" height="240"&gt;&lt;/a&gt;
&lt;br&gt;
Microsoft NYC Office - 1290 Ave of the Americas - 6th Floor 
&lt;h5&gt;Event Details
&lt;/h5&gt;
&lt;p&gt;
&lt;strong&gt;Event Date:&lt;/strong&gt; Saturday June 19&lt;sup&gt;th&lt;/sup&gt;, 2010 
&lt;p&gt;
&lt;b&gt;Event Location:&lt;/b&gt; 
&lt;p&gt;
Microsoft NYC Offices&lt;br&gt;
1290 Ave of the Americas 6&lt;sup&gt;th&lt;/sup&gt; Floor&lt;br&gt;
New York, NY 10104 
&lt;h3&gt;&lt;a href="https://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032452076&amp;Culture=en-US"&gt;REGISTER
HERE!&lt;/a&gt;
&lt;/h3&gt;
&lt;h5&gt;Event Agenda
&lt;/h5&gt;
&lt;p&gt;
Doors open 8:30am. Sessions run from 9:00am – 5:00pm. Lunch will be served. 
&lt;ul&gt;
&lt;li&gt;
Session 1: Keynote – Intro to SOA &amp; WCF 
&lt;li&gt;
Session 2: Most Common WCF Usage Scenarios 
&lt;li&gt;
LUNCH 
&lt;li&gt;
Session 3: REST Programming with WCF 
&lt;li&gt;
Session 4: WCF Made Easy – Data &amp; RIA Services 
&lt;li&gt;
Session 5: What’s New With WCF 4.0&lt;/li&gt;
&lt;/ul&gt;
&lt;h5&gt;Session Details
&lt;/h5&gt;
&lt;blockquote&gt; 
&lt;p&gt;
&lt;b&gt;Intro to SOA &amp; WCF&lt;/b&gt; 
&lt;p&gt;
Jump right in to understanding what service orientation is and how WCF is the preferred
technology for this architecture. You'll see how services get written in WCF from
scratch and using best practices from the beginning. 
&lt;p&gt;
&lt;b&gt;Most Common WCF Usage Configurations&lt;/b&gt; 
&lt;p&gt;
WCF has many characteristics, each with several options. There are however some optimal
settings for the most common scenarios. In this session you'll learn the whys and
hows for configuring WCF services to work optimally in the areas of instantiation,
concurrency, transactions, security, and bindings. 
&lt;p&gt;
&lt;b&gt;REST Programming With WCF&lt;/b&gt; 
&lt;p&gt;
With .NET 3.5 came the addition of the System.Service.Web assembly and the addition
of REST capabilities to WCF. REST is an HTTP-based messaging protocol that is common
in web applications today and even more common in non-.NET services that expose API
(think Twitter &amp; Google). In this session, you'll learn how to expose your services
using REST and also how to consume non-.NET REST APIs using WCF. 
&lt;p&gt;
&lt;b&gt;WCF Made Easy - Data &amp; RIA Services&lt;/b&gt; 
&lt;p&gt;
You have seen all the various ways you can leverage WCF, but what if all you want
to do is expose your data via HTTP? In that case, you can simplify your development,
by using WCF Data Services or WCF RIA Services. In this session we will learn how
to easily expose your data using Entity Framework in a RESTful fashion using WCF Data
Services, how to consume WCF Data Services, and then dive into WCF RIA Services.&lt;br&gt;
&lt;b&gt;
&lt;br&gt;
What's New With WCF 4.0&lt;/b&gt; 
&lt;p&gt;
No Day-Of-WCF would be complete without letting you know what's new with .NET 4.0
and Visual Studio 2010. This session will give you a heads up on several new and powerful
features introduced in WCF 4.0. Among these are "Configuration-less Hosting", "Discovery",
"Routing", and an intro to the new Azure Service Bus.
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;h5&gt;Swag &amp; Prizes
&lt;/h5&gt;
&lt;p&gt;
We hope you come to attend the &lt;a href="https://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032452076&amp;Culture=en-US"&gt;NYC
WCF Firestarter&lt;/a&gt; for the unique content, providing a FREE opportunity to advance
your skills by learning a new technology. However, like many events, we’ll have some
fun stuff to giveaway at the end. If you stick around, you will have the chance TO
BE THE LUCKY WINNER OF A MICROSOFT ZUNE! YOU MUST BE PRESENT TO WIN. &lt;img width="0" height="0" src="http://www.dotnetdude.com/aggbug.ashx?id=6ddef1f4-fe6a-4e1e-b207-3af8bf4290dc" /&gt;</content>
  </entry>
  <entry>
    <title>DevExpress works with Habitat for Humanity in New Orleans</title>
    <link rel="alternate" type="text/html" href="http://www.dotnetdude.com/2010/04/30/DevExpressWorksWithHabitatForHumanityInNewOrleans.aspx" />
    <id>http://www.dotnetdude.com/PermaLink,guid,c3eedcd4-e3a8-4746-863b-9f28490d91e3.aspx</id>
    <published>2010-04-30T11:55:31.327-05:00</published>
    <updated>2010-05-24T15:56:53-05:00</updated>
    <category term="Speaking Events" label="Speaking Events" scheme="http://www.dotnetdude.com/CategoryView,category,SpeakingEvents.aspx" />
    <author>
      <name>Miguel A. Castro</name>
    </author>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
This is certainly worth blogging about. <a href="http://www.devexpress.com" target="_blank">DevExpress</a>,
whom we all know are famous for their component suites and of course CodeRush, is
working with <a href="http://www.habitat-nola.org/" target="_blank">Habitat for Humanity
in New Orleans</a>. Rather than regurgitate their description on this posting, go <a href="http://community.devexpress.com/blogs/thinking/archive/2010/04/27/teched-2010-new-orleans-let-s-not-forget-the-rebuild-the-big-easy.aspx" target="_blank">here</a> to
read all about it.
</p>
        <p>
Way to go guys !
</p>
        <img width="0" height="0" src="http://www.dotnetdude.com/aggbug.ashx?id=c3eedcd4-e3a8-4746-863b-9f28490d91e3" />
      </div>
    </content>
  </entry>
  <entry>
    <title>NYC User Group Debrief</title>
    <link rel="alternate" type="text/html" href="http://www.dotnetdude.com/2010/04/16/NYCUserGroupDebrief.aspx" />
    <id>http://www.dotnetdude.com/PermaLink,guid,8a767200-d3f7-44aa-b21a-a2bec67129b2.aspx</id>
    <published>2010-04-16T17:14:34.819-05:00</published>
    <updated>2010-05-24T15:57:44.609375-05:00</updated>
    <category term="Speaking Events" label="Speaking Events" scheme="http://www.dotnetdude.com/CategoryView,category,SpeakingEvents.aspx" />
    <author>
      <name>Miguel A. Castro</name>
    </author>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
The user group in New York City last night was great. The turn out was around 85 people
and the response, attentiveness, and questions were very good. This talk is a hell
of a memory dump since I cover so many things.
</p>
        <p>
The name of the session was “Integrating Search: An Adventure in Dependency Injection”
and I cover not only the APIs of the three major search engines, Bing, Google, and
Yahoo (soon to use Bing), but also some provider design, dependency injection, and
custom controls (both windows and web).
</p>
        <p>
I also showed off my new FluentSearch DSL which I’ll have on this site very soon.
I talked about this session and the FluentSearch DSL in a previous posting regarding
the Philly Code Camp, so you can go <a href="http://www.dotnetdude.com/2010/04/03/PhillyCodeCampComing20101ComingUp.aspx">there</a> to
read more.
</p>
        <p>
I want to cover an answer to one of the questions last night since I wasn’t able to
answer it off the cuff and gave the attendee an honest, “I’m not sure”. The question
was regarding the <a href="http://msdn.microsoft.com/en-us/library/system.servicemodel.web.webgetattribute.aspx">WebGet</a> attribute
that I used to decorate the operations in my service contracts in order to consume
the REST APIs of both Google and Bing. The <strong>ResponseFormat</strong> argument
of this attribute had the optional settings of either <strong>XML</strong> or<strong> JSON.</strong> This
determined the format for the data that the search engine API would return and instruct
WCF how to decode it. The exact question was regarding the <strong>RequestFormat</strong> argument
of the attribute and what it would be used for in this scenario. The answer is that
it wouldn’t be used so its value wouldn’t matter. The <strong>RequestFormat</strong> argument
determines the format used when the operation is used to expose a service, not to
consume it. In all my usage for this talk, I was using this service contract for consumption
of the external API so <strong>ResponseFormat</strong> is all that was important.
If I was actually writing a service to implement my service contract and would provide
my own implementation of that operation, then the <strong>RequestFormat</strong> would
determine what format of data I would expose through that operation. But once again,
I was only using my service contract to map to a REST URL that was exposed by another
API so it was only in the context of a proxy-based consumption.
</p>
        <p>
My sincere apologies for not having the answer to this question off the top of my
head. This talk covered so much that when the question was asked, I guess my head
was elsewhere. Thank you to whoever it was that asked it because it is definitely
information that I should have covered in more detail.
</p>
        <p>
As always, kudos to <a href="http://www.brustblog.com/">Andrew Brust</a> for running
a great group and inviting me to once again be a part of it.
</p>
        <p>
You can get the session material from the <a href="http://www.dotnetdude.com/downloads">Downloads</a> section
of this site.
</p>
        <h3>
          <em>Until next time…</em>
        </h3>
        <img width="0" height="0" src="http://www.dotnetdude.com/aggbug.ashx?id=8a767200-d3f7-44aa-b21a-a2bec67129b2" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Philly Code Camp Review And Upcoming NYC User Group Presentation</title>
    <link rel="alternate" type="text/html" href="http://www.dotnetdude.com/2010/04/13/PhillyCodeCampReviewAndUpcomingNYCUserGroupPresentation.aspx" />
    <id>http://www.dotnetdude.com/PermaLink,guid,66928228-5f41-438c-a4c6-71610841e3cc.aspx</id>
    <published>2010-04-13T11:25:30.566-05:00</published>
    <updated>2010-05-24T15:57:28.203125-05:00</updated>
    <category term="Speaking Events" label="Speaking Events" scheme="http://www.dotnetdude.com/CategoryView,category,SpeakingEvents.aspx" />
    <author>
      <name>Miguel A. Castro</name>
    </author>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
The Philly Code Camp this last weekend was awesome as always. The talk I did was <strong>“Integrating
Search: Adventure In Dependency Injection”</strong>, and I was extremely pleased by
the turnout. I was a bit nervous about this one because I gave it in <a href="http://www.devconnections.com" target="_blank">DevConnections</a> last
year and had a very small turnout. Though the people that did show up loved it, I
set out to make some modifications here and there and tried again in Philly. I think
there were over 75 people in the room and the response and feedback was awesome.
</p>
        <p>
The material for the session can be found in the <a href="http://www.dotnetdude.com/downloads" target="_blank">Downloads</a> section
of this site.
</p>
        <p>
I’m looking forward to doing this talk again this Thursday in the <a href="http://www.nycdotnetdev.com" target="_blank">NYC
.NET User Group</a>. The New York group is run by Andrew Brust, Stephen Forte, and
William Zack and has been around for a very long time. It’s at this group where I
first met my friend Carl Franklin (host of <a href="http://www.dotnetrocks.com" target="_blank">.NET
Rocks!</a>), and the group was also the second .NET user group in which I ever spoke.
Though I’ve remained an active attendee at this group, I’m looking forward to returning
this Thursday as a speaker once again.
</p>
        <p>
If you want to see a brief on the upcoming talk, see my <a href="http://www.dotnetdude.com/2010/03/23/TheSagaOfOffice30.aspx" target="_blank">posting</a> prior
to the Philly Code Camp.
</p>
        <h3>
          <em>Until next time…</em>
        </h3>
        <img width="0" height="0" src="http://www.dotnetdude.com/aggbug.ashx?id=66928228-5f41-438c-a4c6-71610841e3cc" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Introducing Russ’ Toolshed Network</title>
    <link rel="alternate" type="text/html" href="http://www.dotnetdude.com/2010/04/08/IntroducingRussToolshedNetwork.aspx" />
    <id>http://www.dotnetdude.com/PermaLink,guid,748a200b-02e1-4feb-80de-e6f57837269f.aspx</id>
    <published>2010-04-07T21:48:14.5864108-05:00</published>
    <updated>2010-04-08T09:03:28.723125-05:00</updated>
    <author>
      <name>Miguel A. Castro</name>
    </author>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
I’m sure many of you out there have either known for a while or have at least heard
of the very popular site <a href="http://www.russtoolshed.net/">Russ’ Toolshed</a>. 
The creator of that site, Russ Fustino was a long time evangelist for Microsoft and
also someone I’m proud to call a personal friend.  Russ has some great news for
us in the introduction of what many of us hope to be a very successful startup, <a href="http://www.russtoolshed.net/">Russ’
Toolshed Network</a>.
</p>
        <p>
Put simply, RTN is going to be an Internet TV network where not only will Russ host
programs and videos but more to the point, will be able to host your channels with
your own content.  The business model is still being finalized and anyone interested
should contact Russ on that site (no emails here, sorry spammers).
</p>
        <p>
RTN just published its fist professional production in the way of a video on the <a href="http://www.russtoolshed.net/videos.aspx">Speaker
Idol Florida Finals</a>.
</p>
        <p>
Congratulation to Russ on his new venture.  He tells me that business is picking
up and things look like they’re going in a great direction.
</p>
        <p>
I for one hope to one day host a channel with RTN.  On what?  Well, that
would be the topic for a future posting.
</p>
        <h3>
          <em>Until next time…</em>
        </h3>
        <img width="0" height="0" src="http://www.dotnetdude.com/aggbug.ashx?id=748a200b-02e1-4feb-80de-e6f57837269f" />
      </div>
    </content>
  </entry>
</feed>