This blog has moved: http://larswilhelmsen.com/

Hi,

 Just want you to know that I've moved my blogging to http://larswilhelmsen.com/ .

 Update your Feed reader.
 

Posted by larsw | with no comments

Controlling WebHttpBinding output format - Custom WebContentTypeMapper

In order to control the output type from a service that is set up with the WebHttpBinding (the new "REST" binding in .NET 3.5 / WCF), you will have to switch to a customBinding in the configuration, create a class that derives from System.ServiceModel.Channels.WebContentTypeMapper (and implement the GetMessageFormatForContentType() abstract method.

This isn't documented particularly well anywhere in the MSDN documentation - or anywhere else, for that matter.

Only the relevant part of the configuration file is included for brevity.

<system.ServiceModel>
  <bindings>
    <customBinding>
      <binding name="myCustomBinding">
        <webMessageEncoding webContentTypeMapperType="Service.CustomContentTypeMapper, Service" />
        <httpTransport manualAddressing="true" />
      </binding>
    </customBinding>
  </bindings>
  <behaviors>
    <endpointBehaviors>
      <behavior name="webBehavior">
        <webHttp />
      </behavior>
    </endpointBehaviors>
  </behaviors>
  <endpoint binding="customBinding" bindingConfiguration="myCustomBinding" behaviorConfiguration="webBehavior" />
</system.ServiceModel>
namespace Service
{
    public class CustomContentTypeMapper : WebContentTypeMapper
    {
        public override WebContentFormat GetMessageFormatForContentType(string contentType)
        {
            // check the contentType and return the right WebContentFormat accordingly.
            return WebContentFormat.Raw;
        }
    }
}
kick it on DotNetKicks.com
Posted by larsw | 1 comment(s)
Filed under: , ,

How to resolve a "... cannot be processed at the receiver, due to an AddressFilter mismatch at the EndpointDispatcher. ..." fault

I'm currently hacking together a replacement for Microsoft Symbol Server (symsrv.dll / symproxy) with WCF / .NET 3.5, and is currently checking out the REST capabilities in System.ServiceModel.Web.

I threw together a simple service contract and an implementation - hit F5 - and tried to access the service from Internet Explorer (doing a HTTP GET).

The operation is decorated with [WebGet] with an appropriate UriTemplate for the input parameters (fileName, hash, symbolName).

Entered http://localhost:8731/foobar.pdb/43274328743/foobar.bab in the address bar and hit enter.

Bam! This is what the response looked like:

<Fault xmlns="http://schemas.microsoft.com/ws/2005/05/envelope/none">
<
Code>
<
Value>Sender</Value>
<
Subcode>
<
Value xmlns:a="http://schemas.microsoft.com/ws/2005/05/addressing/none">a:DestinationUnreachable</Value>
</
Subcode>
</
Code>
<
Reason>
<
Text xml:lang="nb-NO">The message with To 'http://localhost:8731/foobar.pdb/43274328743/foobar.bab' cannot be processed at the receiver, due to an AddressFilter mismatch at the EndpointDispatcher. Check that the sender and receiver's EndpointAddresses agree.</Text>
</
Reason>
</
Fault>

My first thought was that the UriTemplate syntax was wrong, but after a bit Googling, I found out that I had forgot to add an EndpointBehavior turning on <webHttp /> ...

When this was wired up, the invocation worked like a charm.

 


 

del.icio.us Tags: , ,
kick it on DotNetKicks.com

Posted by larsw | 1 comment(s)
Filed under: , ,

Upgrade a Visual Studio 2008 class library project to support the WCF Test Client

Let's say you "forgot" to use the new WCF Service Library template when you created your new service project - or that you simply upgraded from a Visual Studio 2005 project (or whatever).

Problem: If you try to hit F5 (When the class library is set as the current startup project) - you will get the usual message that you can't run a class library.

In order to "upgrade" a class library project to support the WCF Test Client, you'll have to do two things:

  • [Project properties] Put "/client:"WcfTestClient.exe" in the Command Line Arguments text box in the Debug tab.
  • Open the project file (.csproj) in notepad (or another text editor) and add the following line to the first <PropertyGroup> section of the file:

    <ProjectTypeGuids>{3D9AD99F-2412-4246-B90B-4EAA41C64699};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>

And that's about it. Open the solution/project in Visual Studio 2008 (beta 2 at the moment)  compile - and hit F5. You can now use the WCF Test Client to test your services.

Enjoy. 

kick it on DotNetKicks.com

Microsoft eScrum for Team Foundation Server: Ouch!

Through Mike Gunderoy's The Daily Grind today (1163) I found out that Microsoft has released both a VSTS Process Template for Scrum and an extension / web-based scrum tool called Microsoft eScrum for TFS 1.0, that can be downloaded here.

So I downloaded the last one and fired up the installer on the Team Foundation Server. Everything goes allright, until the last screen of the installer, where I get a LOOONG description of manual configuration steps ahead of me. That isn't actually something that scares me, but in the instruction you are instructed to download AJAX for ASP.NET 1.0 and the AJAX Control Toolkit manually and insert the assemblies into the right directory.

Well, that doesn't stop me either - but hey! there's something else written between two parantheses; It's buildt against the 10301 release of the AJAX Control Toolkit.

The development of the Control Toolkit is community-driven, and hosted on Codeplex. Guest what?

The  10301 release is no longer available on the project site!

Down at the bottom of the instructions, in the troubleshooting section, there's a section describing how you can add a redirection section to your configuration file - so that the eScrum Web Site will resolve the Control Toolkit assembly correctly.

-------

I'm not done with the installation yet - heck, I've just begun, and I've already wandered off to do something else instead; rant about the really really horrible installation experience for this 1.0 release.

The last couple of years, Microsoft has open up their development projects, and released a large amount of CTPs / RC etc. to the community - something that I enjoy very much. Why isn't this a CTP - when the installation procedure is really lacking a lot of the things you'll expect from stable shipment of software?

I'll probably write up a summary when I've completed the 10000 line installation instruction.

Arrrgh.

Update

The 10301 release isn't available on any Microsoft site (If you know of a place, please let me know), but I found it on Softwarepedia.com. But even if the release is available somewhere on the internet, the installation procedure is IMHO still lacking.

Update #2

If you go for the latest release (Today it's 10606) and you cut'n'paste in the assembly redirection section into your web.config; The quotes in culture="neutral" is of the wrong type! Change them out with normal "-quotes (The shift-2 kind).

Paste it in anywhere under the <configurationSections> section - otherwise you'll get an exception that says that the web.config isn't according to the given XSD.

You will also have to change out the xxxxx in the newVersion attribute of bindingRedirect with the right version number.

Update #3

It's working! The first impression is that it looks quite neat - and at least better than the Scrum for VSTS from Conchango that has been around some time!

The conclusion: Read the (damn) installation instruction thoroughly, be sure to set the right permissions on the AppPool / WebSite, add the Sharepoint templates before you try to import the process template - and remember the quirk with the assembly redirection configuration section.

Good night!

Share this post :

Is it CS 2007 or WLW that mess up the posting time?

Notice the two first post on this blog after the re-launch; the first post is now listed after the second one - even if the posting time in the Web blog dashboard is set to before. The displayed posting time is today, June 6th, even if I wrote it yesterday...

Posted by larsw | with no comments

I'm a DHSB... figures.

Your programmer personality type is:
DHSB

You're a Doer.
You are very quick at getting tasks done. You believe the outcome is the most important part of a task and the faster you can reach that outcome the better. After all, time is money.
You like coding at a High level.
The world is made up of objects and components, you should create your programs in the same way.
You work best in a Solo situation.
The best way to program is by yourself. There's no communication problems, you know every part of the code allowing you to write the best programs possible.
You are a liBeral programmer.
Programming is a complex task and you should use white space and comments as freely as possible to help simplify the task. We're not writing on paper anymore so we can take up as much room as we need.

What is your programmer personality? Take the test here.

Posted by larsw | with no comments

First Post!

Hi,

 I've just got Community Server 2007 Express installed sral.org, and will use the next couple of days to tweak the look and feel of it.

 Please stay tuned for more relevant content on software development using Microsoft .NET and friends.

 --larsw

Posted by larsw | with no comments
Filed under:

Second post - from Windows Live Writer 1.0 Beta (12.0.1183.516)

The version number is a bit WTF - but apart from that, WLW is a kickass blogging tool. With the growing amount of cool plugins that you can download, I believe that WLW will take a market position as one of the leading tools.

Right now I've installed a couple of plugins - the most useful ones (so far):

The last one is for cut'n'pasting source code with the right syntax highlighting from Visual Studio - a feature I've greatly missed in tools / blog engines I've used earlier.

WLW also support the blog feature in Microsoft Office Sharepoint Server 2007 - something we're in the middle of implementing in our IT infrastructure at work.

Posted by larsw | with no comments
More Posts