Blog

Beware of RequestUri when exposing WCF REST services through HTTPS

By: Alejandro Villarreal   We recently implemented a WCF REST service which authenticates the caller before executing any of the operations it exposes. It also has help page (so users can see the supported operations and the expected inputs) which we want to expose to any user, regardless of authentication. In principle this is very easy: we just needed to identify requests to the “help” section of our service (http://myServiceUrl/help) and allow them to go through without further validation.   We have a method that returns “true” for requests that should go through, and “false” for those that shouldn’t, so originally our code to solve the problem looked like this:   if (requestUri....

Deploying a Message Queue WCF Service

By David E.  The following guide was the created installing MSQueue and configuring a WCF using a Windows 7 OS. 1.       Verify IIS is installed on the server machine where the WCF is going to be hosted.   2.       Install MS Queue by following the instructions specified on this link:   http://msdn.microsoft.com/en-us/library/aa967729.aspx            3.    Install or verify the following Windows Features : 4.       Verify the following services are running: a.       Message Queuing b.      Net.Msmq Listener Adapter c.       Windows Process Activation Service   5.       Create a Web application inside IIS. For this example, the application name used is FGMQService. The ap...

How to Handle the WCF Error on Silverlight

By David Espino. When sending a call to a WCF service from a Silverlight application and the service returns an error, the Silverlight client backs up only a very generic error: The remote server returns an error: NotFound This message does not help to know the exact error neither for the user nor the developer. Even more, it is necessary for more security to make a division of the error information: one message for the user and one detailed message for the system administrator or developer. The first part of the error dedicated to the application administrator consists on writing the exception that the code generates on a detailed way. There are a lot of tools that allows tomake th...

WCF service in IIS with multiple host-headers

By Alejandro Villarreal Hosting WCF services in IIS is usually a very straightforward process with no weird configuration settings or obscure errors. You create a site in IIS, publish your service in the site’s folder, and you’re ready to go. However, things start to get a bit complicated in more advanced scenarios like the one I encountered some days ago: if your site in IIS answers to multiple host-headers, then when you try to access the service through a web browser, instead of seeing the usual page with the service description you will receive a screen indicating a Runtime Error, and you should be able to find an Error entry in Window’s Event Viewer (under “Windows Logs”/Applicatio...

How to Set up WCF Services to work with large amount of data.

When you are working with WCF Services, sooner or later you will need to either send or receive a large message, like a picture or a pdf document or maybe an object with a complex structure. If you add a new service to your solution in Visual Studio, by default it is created with a limited message size of 64KB or less. Few pictures or documents will pass through such a small buffer and, if what you are doing is a photo sharing site, it will have little use, if any at all. Fortunately it is very easy to make our services handle large messages properly.First on the Server’s web.config you must make sure to include the node dataContractSerializer inside the service behavior. You should add ...