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

My first impression so far has been "Oh my Metro".  I am not sure if I like it yet.

image

The menus are in all CAPS.  WHY IS THE IDE YELLING AT ME?

image

The color scheme is a bit washed out.  I am still trying to get used to this but it does telegraph to the code and designer as they are where your eyes go.  I could get in to this high contrast look if it were to splash color at the portion of the UI I were currently using.

WPF Control / Element selection works well and very fast.

image

The UI is very responsive.  If you remember Visual Studio 2008 (Ugh I still have to work in VS2008) clicking on a UI element in the designer renders properties in about a minute if you are lucky (and have ReSharper disabled).  Visual Studio 2012’s new IDE is very responsive.  Thank you!

image

Visual Studio 2012 adds List as an option for your DataSources if you are a drag and drop binding kinda guy.

image

The XAML Designer has some Blend functionality built right in now.  From the left: Zoom Level, Toggle Effects, Show Snap Grid,  Snap to Grid Lines, Snap to Snaplines, Show Annotations.

Toggle Effects

This allows you to turn off the special effects bound to controls.  This helps speed up the designer a great deal.

Annotations

Allows you to view annotations about your WPF application (presumably from a sketchflow annotation).

image

The Solution Explorer looks Metrofied and adds a really useful Collapse All command and a Pending Changes filter command.

I am working on a project where I need to resize a bunch of raster images from miscellaneous sizes to fit within a certain frame.  More specifically, I need a bunch of icons for an iPhone application and I need them to fit within a 64px by 64px frame.  I found a bunch of Photo Shop scripts, some console apps, and a few spamware solutions.  I figured half an hour and I would have one that works well.  I was right.

image

So here is how the app works:

Drag and drop the graphics files you wish to resize into the application.  The files will show in the list view area.  Next, enter the Max Height and Max Width values and then click the Resize button.

The application will write the resized file next to your original with _MaxHeightxMaxWidth appended to the filename.  Original files are not modified in any way during this process. 

So if you found this blog post in hopes that you would find a quick and simple image resizer for free, here is the link to the binaries: 

A little about the application source code.  The application is a .NET 4.0 WPF application that follows the M-V-VM (MVVM) design pattern.  Since there is drag and drop support in the application there is a little code behind to support this.  The rest of the application follow the MVVM pattern.

There is a tiny image resizer class in the project that you are free to use.  This is located in the DevSQL.Imaging assembly. 

The source code can be found below.

I love this Visual Studio Extension.  Wanted to keep it in the blog so I do not forget.  Chris also wrote a notepad++ plug-in for the same thing.  Kudos.

http://visualstudiogallery.msdn.microsoft.com/7179e851-a263-44b7-a177-1d31e33c84fd

Align by… (Dialog) Ctrl + Shift + =
Align by position… (Dialog) Ctrl + =, Ctrl + backspace
Align by Equals Ctrl + =, Ctrl + =
Align by m_ Ctrl + =, Ctrl + m
Align by " Ctrl + =, Ctrl + ‘
Align by . Ctrl + =, Ctrl + .
Align by Space Ctrl + =, Ctrl + Space

Here is the snippet I am currently using to implement a basic DelegateCommand class.

CODE:

Snippet file:

Business Problem

Large companies have lots of facilities which need spare part inventory on hand.  Facility operators may not reorder parts in a timely fashion which can lead to a local shortage of equipment.  Some facilities may hoard equipment creating a local surplus of equipment.  Both extremes are costly to a company.

Solution

Provide a simple to use touch screen computer that detects when a part is leaving or entering the spare parts room.  Upon detection of the part the touch screen computer displays a ‘tag’ with information about the part.  The facility user can touch the tag on the screen and note the use of the part.  When parts come in for replenishment the facility user can notate the put away location of the part.  When are part is used inventory levels at MDSi are updated.  If the minimum stocking level is reached a reorder is automatically generated and shipped to the facility to keep the stocking level true.

Components

RFID Client (Touch screen workstation)
This is the device with which the facility users interact.

image

The client is built with Microsoft .NET Framework 4.0 and uses Windows Presentation Foundation (WPF) to present the UX.  The client leverages the Model-View-ViewModel (MVVM) architectural pattern and is written in C#.  Communication to the home office is provided via WCF services.

image

RFID Tags are read via a Motorola XR-450 tag reader.  This reader was selected because it has a built in Windows CE operating system that allows us to write Mobile Embedded .NET applications to interact with the reader and with our WCF Services.  The RFID Client Workstation has a Windows Service written in C# and .NET 4.0 which continually polls the XR-450 reader for new tags.  The service exposes a .NET Remoting service which is consumed locally by the client UI.  Multicast events are thrown and the client system can respond to new tags accordingly.

RFID WCF Services
All RFID Clients communicate to a set of centralized web servers in an NLB farm.  The WCF Services provide a data exchange layer which provides caching by leveraging the AppFabric Cache feature of Windows Server 2008 R2.  Data is stored in a SQL 2008 R2 Cluster and the data is organized through Microsoft Dynamics AX 2009.  X++ and Business Connector code was created to interface through the ERP system and pass through all of the business rules configured in the Dyanmics Ax system.  In addition to using the .NET Business Connector and custom Dynamics Ax projects to manage the data, ADO.NET, Linq and C# is used in the creation of these services.

RFID Management Display
A Network Operation Center (NOC) application was created to provide real-time node (RFID Touch Screen Client) availability data.  This data is organized on a map and allows an operator to drill in to a workstation and remotely manage the system.

image

RFID Warehouse Printing
Tools were created to interface with the Microsoft Dynamics Ax 2009 ERP system which allow a warehouse employee to print RFID labels for items being shipped out for replenishment.  This system interfaces with the Zebra RZ 400 RFID Printer.  This application was created using WPF, WCF, MVVM.

image

RFID On-Site Inventory and Auditing Tool
This application allows a warehouse specialist to audit a sparing facility.  This application is written using WPF and .NET 4.0.  The application consumes the same WCF services provided for the RFID Client to connect to the ERP system.  The application allows a specialist to print labels via a wireless Zebra RP4T RFID Label printer.  Using this application a project coordinator can determine what inventory is needed on site and what can be returned for general usage to the Distribution Center (DC).  This allows for a quick and efficient auditing process.  The warehouse specialist does not need to know anything about the product, just scan the serial number and the application tells the specialist the disposition of the part based on the Min/Max settings in the ERP system.

image

RFID Node Creation Tool
The Node Creation Tool allows a support engineer to provision a remote RFID Touch Screen Client from a central location.  A support engineer can provision all of the standard configuration settings for Development, Test, and Production from the single tool.  This application was created with WPF, C#, WCF, MVVM.

image

RFID Online Spares Management Web Application
A Silverlight application was created to provide scaled down functionality for locations that do not have the RFID Touch Screen client installed.  Some locations need the ability to consume, count and audit their inventory without an RFID client.  In this case a laser barcode scanner is used to scan the RFID barcode.  This application was written in Silverlight 4.0, uses WCF Services, and employs the MVVM architectural pattern.

image

So Web Application projects have this great new feature that allows you to use an XML Transform file to merge settings into your Web.Config file based on the build configuration.  For example, if you have a Release build configuration you might want your connectionString section to point to a production server instead of your development server.  See this link for more information on Web Config Transforms.

This is a really cool feature and it is possible to use this with non-web application projects.  You can configure your project file to support this very easily.  You do need to insert some XML into your csproj file but it is really lightweight.

First, Add an App.config file to your project if you do not already have one.

Next, close Visual Studio and open your *.csproj file in notepad.

Go to the very end of the file and insert the UsingTask and Target sections directly above the </Project> closing tag. 

 

Now find the section that has your App.config file include.  It will likely be in a <None /> tag.  Replace that tag with the following code. (Include a App.CONFIGURATION.config file for each build configuration you use.

Save your csproj file and open it up in Visual Studio again.

image

Now when you build your solution/project the XML Transforms in your App.CONFIGURATION.config file will be merged at build time.

I use these two snippets a lot for WPF and Silverlight development.  I decided to post them on the blog so that I have them available to me whenever and wherever.  I always seem to be searching through older projects for this code.

vmb

This snippet creates the ViewModelBase that I use almost everywhere.  It simply implements INotifyPropertyChanged and works in both WPF and Silverlight.  I use this for my ViewModels so that the properties on the VM are observable for databinding.  I use this in conjunction with my propsn snippet that creates a property with SafeNotify calls in the setter.

mb

This snippet is used to create the ModelBase.  Again, this is a WPF / Silverlight compatible class.  I link my model such that it compiles for WPF and Silverlight so that I can share my model between my WCF and my UI.  This class gives me INotifyPropertyChanged, SafeNotify, and a ToString implementation that uses reflection to dump a shallow representation of the class.

Hope this code helps someone.

If you have not installed the latest version of the Visual Studio Productivity Power Tools (The LATEST release that is), you are missing out on some killer functionality.

Download them here:
http://visualstudiogallery.msdn.microsoft.com/en-us/d0d33361-18e2-46c0-8ff2-4adea1e34fef

There is now a Solution Navigator:

image

Advanced object information when hovering over an object or method with your cursor:

image

image

image

Cool new color coded gradient backed tabs:

image

Pinning of tabs is still supported:

image

 

Check out more info on the Visual Studio Blog
http://blogs.msdn.com/b/visualstudio/archive/2010/07/20/solution-navigator-blog-post.aspx

Download the latest version of the Productivity Power Tools
http://visualstudiogallery.msdn.microsoft.com/en-us/d0d33361-18e2-46c0-8ff2-4adea1e34fef