This problem has been solved and answered many different ways but none of the answers seem to propose a complete basic or step by step solution.  This article is my attempt to consolidate the answer into one concise how to article.

Executive Summary

For those of you that want the answers quickly, here are the steps necessary to properly use WebGet methods in a WCF Service:

  1. Use the WebGet attribute and specify a UriTemplate.
  2. Use the webBinding binding type in your web.config.
  3. Create an endpoint behavior that specifies webHttp in your web.config.
  4. Reference the endpoint behavior in the service endpoint configuration section.
  5. Set the binding in the service endpoint configuration to webHttpBinding (or to the name of the binding configuration that specifies webHttpBinding).

How-To / Step by Step

In this section we will go through the process of creating a simple service with Visual Studio 2010 that performs a simple WebGet operation.

Create a new WCF Service Application project.

image

I am going to leave the default Service1 class and interface names intact for simplicity.

Open the IService1.cs code file and change it so that it looks like this:

Note the WebGet attribute in the interface definition.  Now we are going to modify the Service1.cs file to implement the AddNumbers method.

This implements the method.

Compile the project and make sure it builds. Next we are going to update the web.config file so this actually works.

In Visual Studio click Tools | WCF Service Configuration Editor, Load the web.config file for this new project.

image

You will see the WCF Config Editor.

Now we are going to create a Service Endpoint and an Endpoint Behavior.

Click the Services configuration node and click Create a New Service.

Click Browse to find the service type.  You are going to navigate to the DLL that implements your WCF service (hint, it should be in your /bin folder).

image

After clicking Open you will be allowed to choose the class that implements your service.  Click it and then click Open.

image

After clicking Open you will click Next.  This will bring you to the service contract screen.  This screen is asking you what the interface is that describes your service.  Typically this will be automatically detected and filled out for you.

image

Click Next.

image

Choose HTTP and click Next.

image

Choose Basic Web Services interoperability and click Next.

For the Endpoint Address enter / and click Next then on the summary page click Finish.

image

You will now have a service configured in your Web.config file.

image

Now we will create an endpoint behavior.  Expand Advanced, Right Click on Endpoint Behaviors and choose New Endpoint Behavior.

image

Click Add, Choose webHttp and click Add.

image

The new behavior configuration screen will now look like this:

image

Change the Binding to webHttpBinding and select the NewBehavior0 behavior configuration.

image

Click Save and exit from the WCF Service Configuration tool.

Now you should be able to start your WCP project and navigate to the web method in your browser and see a result like below.

image

Note that the URL contains your .svc file and then the UriTemplate property of the WebGet attribute kicks in. 

Source code for this project: WebGetTest.zip

I am building a ‘smart TextBox’ that allows additional data to be presented along with the actual data in the textbox.  I will detail the creation of this new TextBox in this blog entry. 

I started with a TextBox, a ‘smart indicator’, and a panel that will slide out of the textbox when the mouse enters the smart indicator area.  I used the following XAML to accomplish this.

The following movie clip shows the action.

TODO:

  • Make into user control.

  • Make configurable (1 – ?) possible smart indicators each with it’s own panel.

  • Make panel have a content panel so it can be XAML’ized.

  • Make it look pretty.

  • Provide example of use.

Dear Visual Studio 2012 developer that put in the registry entry to remove the ALL CAPS metro menu item ‘feature’.  I owe you a frosty cold beer.

[image%255B6%255D.png]

Here is the fictional transcript of the SCRUM meeting at the Visual Studio team:

Program Manager: Guys, marketing wants the IDE to represent the metro look and feel.

Developers: OMG are you kidding?  The development community is going to roast us for having the UI yell at them all day.

Program Manager: Well we need to eat our own dog food.

Developers: Fine, if we have to. (Thinks to himself: I am making this configurable.  I just know this is not going to fly in the real world.)

Hence: http://www.richard-banks.org/2012/06/how-to-prevent-visual-studio-2012-all.html