Blog

Go Back
  • Limiting time for Discovery Part II

    Previously, I had thought I found a way to speed up discovery by limiting the search time. It turns out that there are better ways to achieve the same goal. When limiting duration, you are trying to find all endpoints implementing a given contract within a specific period of time. However, you may have other criteria, like you just want an endpoint that implements a contract. As soon as you find that endpoint, you are happy. This is pretty simple to do as well. On your FindCriteria object, just tell it you want it to stop when it finds 1 instance OR times out. Instead of setting the duration, set the MaxResults property to 1: FindCriteria criteria = new FindCriteria(typeof(ITest)); criteria.MaxResults = 1; That’s all there is to it!

    Comments0

    Full story

  • First Experiences with WS-Discovery

    I was digging into WCF’s implementation of WS-Discovery today and was somewhat appalled by how long it took to discover a service from a client when both endpoints lived on the same machine. I setup tracing and message logging to dig into why things were taking so long. Inside the messages, I found this nugget in the WS-Discovery probe messages:<s:Body> <Probe xmlns="http://docs.oasis-open.org/ws-dd/ns/discovery/2009/01"> <d:Types xmlns:d="http://docs.oasis-open.org/ws-dd/ns/discovery/2009/01" xmlns:dp0="http://tempuri.org/">dp0:ITest</d:Types> <Duration xmlns="http://schemas.microsoft.com/ws/2008/06/discovery"> PT20S</Duration> </Probe> </s:Body>   I thought to myself, “That looks like a TimeSpan. I wonder how I can set it.” If you haven’t used WS-Discovery on the client in WCF, let me walk you through the basic few lines of code that get things set up. You need a DiscoveryClient which knows how to send ...

    Comments2

    Full story

  • Iowa Code Camp November 2009 Slides Up

    I want to send out a big thank you to the team who put together the Iowa Code Camp. You people did an awesome job!!! I had a great time giving my talks and really enjoyed hanging out with the crowd in Iowa. For those of you who attended my talks, or just want to see the materials, I’ve posted things. WCF Diagnostics Talk and Materials WinDBG Talk and Materials See you next year…

    Comments0

    Full story

  • New F#/WCF Article up at InformIT

    My article on programming REST services with F# and WCF went up at InformIT. Please go read it! http://www.informit.com/articles/article.aspx?p=1394625

    Comments0

    Full story

  • Calling an STA COM Object from a WCF Operation

    One of the things that many people are still doing is making use of old COM objects that run in STA (single threaded apartment) threads. Back in October, 2006, Jeff Prosise wrote how to do this from ASMX. Not too long after that, I had a chance to teach for Wintellect and Jeff asked me to show him how to do the same in WCF. That information went up on a post for a consulting company that didn’t make it through the latest recession. For better or worse, that post was referenced a fair number of times and now, folks are writing to me, asking for the code again. In general, any time you receive a message via WCF, the message itself will be processed on a MTA (multi-threaded apartment) thread. Normally, this is just fine. Sometimes, you might be calling out to a COM object. COM objects will ...

    Comments2

    Full story

  • System.ServiceModel.Channels

    I was digging through the .NET 4.0 assemblies and started with a group that is near and dear to my heart: System.ServiceModel.*. I know—that’s the super cool but really hard thing to understand in .NET, at least, that’s what I seem to see all the time. Last night, I poked around in System.ServiceModel.Channels—a new assembly in .NET 4.0. This assembly contains two interesting features: The ability to send messages in process. The ability to send blobs as is. The in process channel was frequently asked for by users back in the Indigo beta days. As a matter of fact, this was typically the first channel that the channel team would write to make sure that the latest iteration of the channel model still worked and made sense. Then, the channel was checked into the build verification tests (BVTs), but never into the product. Finally, with .NET 4.0, that class has ...

    Comments0

    Full story

  • AJAX and WCF

    Most of the information in this post applies to .NET 3.5. Code examples are in F# because I’m teaching myself F#. If you want C#, wait until I post the same material on Azure or buy my Effective REST Services via .NET book. I’m currently working on the finishing touches of an Amazon Web Services version of my PhotoWeb application. Because EC2 supports Windows, I’m building the whole thing for IIS, using F# as the programming language. One of the features of this application is that it uses AJAX to update metadata about the images on the screen. To handle AJAX, one commonly uses either ASMX or WCF. In .NET 3.5, the WCF team added some functionality to make AJAX a no-brainer via a ServiceHostFactory-derived class that just does the right thing and a few new attributes. This means no updates to web.config in order to get your service ...

    Comments0

    Full story

  • WCF + Azure October 2008 SDK = Time to upgrade

    Around the beginning of January, 2009, I began my experimentation with Azure. This meant installing the October 2008 SDK. Being a WCF geek, I tried writing a service a few minutes after I got Hello World working. Complete FAIL. No matter what binding I tried, I would get a message about having issues with config not allowing partially trusted assemblies. I tried all sorts of things to get the service working, and I eventually got something going by writing custom ServiceHostFactory (no config) that also stripped out the multiple HTTP endpoints appearing when the web site tried to create the service. Not exactly a happy experience. On January 14, a new version dropped. Now, I am reduced to using the basicHttpBinding, but I don't need to use the custom ServiceHostFactory to diagnose things.

    Comments0

    Full story

  • Misunderstood: Add Service Reference

    Every so often, I get into a discussion about whether Add Service Reference is required in an application if the application owns both the service and one consumer. The short answer is No. But, you probably want to know Why? To understand that, we need to look at what Add Service Reference actually does and why you can do the same for yourself. For the purposes of our discussion, the work actually being done by the service is unimportant. Let us assume the following interface:     1 using System.ServiceModel;     2      3 namespace BlogWCF     4 {     5     [ServiceContract]     6     public interface ISimpleService     7     {     8         [OperationContract]     9         string SayHello(string name);    10     }    11 } The implementation of the interface is then     1 namespace BlogWCF...

    Comments2

    Full story

  • F# does a WCF Service

    I spent a large portion of my career working with WS-*/SOAP. So, once I understood how F# attributes worked, I thought it would be cool to see if I could write a WCF service. Nothing complex-- I just wanted to see if I could get HelloWorld up and running. Given that one can get a class running as a service with the right config and .svc file, this seemed like an easy task. First, I'll present the solution, then I'll talk about a couple of issues I ran into along the way to the solution. In F#, one adds attributes by placing a [<Attribute>] before the type or member. For WCF, we need the ServiceContractAttribute and OperationContractAttribute on the type and any exposed functions. The HelloWorld service can be written like this:       1 #light     2      3 namespace Service     4     ...

    Comments0

    Full story

  • Effective REST Services via .NET Getting Closer

    Kenn Scribner and I are busy getting our book, Effective REST Services via .NET, ready for publication. We've already written all the content and received the technical reviews. This past weekend, Kenn spent some serious time making sure that the voice in the book was consistent. Today, the editors get there hands on the manuscript in order to fix punctuation and English. That's right, the folks with degrees in English will fix our prose. It's exciting to know that this book is getting closer to being on bookshelves and available for ordering from Amazon. Unlike the other .NET REST titles out there, we don't spend 300+ pages talking about WCF and how cool it is. Instead, this book walks through all the different ways that a .NET developer has created to expose and consume REST services. IHttpModule, MVC, Azure, ADO.NET Data Services, JavaScript, XMLHttpRequest...

    Comments3

    Full story