What is the best way to return errors from a WCF service in a RESTful way?

With .net 4, throw a WebFaultException<T>(T errorDetail, HttpResponseCodecode) Here you set your response type to another object type, which makes sense, and also you set the ResponseCode that you want. The errorDetail must be serializable http://blogs.msdn.com/b/endpoint/archive/2010/01/21/error-handling-in-wcf-webhttp-services-with-webfaultexception.aspx

What is the WCF equivalent of HttpContext.Current.Request.RawUrl?

You can get the endpoint currently targeted and the Uri for it by doing: OperationContext.Current.RequestContext.RequestMessage.Headers.To which I think is the same thing as: OperationContext.Current.IncomingMessageHeaders.To This is a System.Uri object, and I believe you can just get the OriginalString or PathAndQuery, or whatever parts you want from it.

Correlate MSMQ End-to-End trace with WCF Trace and application level logging

You sounds like you’re on the right track. However you could bump up a bit with this: Using SvcConfigEditor.exe Configure WCF Verbose Tracing for Propagate ACtiveity and Activity tracing Configure WCF MessageLogging for “Malformed Messages, Service Messages, Transport Messages” Use LogEntireMessage In End to End, trace it All Make sure you enable these *.config on … Read more

WCF – Faults / Exceptions versus Messages

This however carries overhead as throwing exceptions in .NET can be quite costly. You’re serializing and de-serializing objects to XML and sending them over a slow network.. the overhead from throwing an exception is negligable compared to that. I usually stick to throwing exceptions, since they clearly communicate something went wrong and all webservice toolkits … Read more

OData $filter with items in a $expand

The query you’ll need to write depends on the cardinality of the expanded collection. Here are some examples that use the public sample OData Northwind service, provided by odata.org. An order is always done by exactly one customer. Find the orders made by a customer with a specific name: http://services.odata.org/V3/Northwind/Northwind.svc/Orders?$expand=Customer&$filter=Customer/CompanyName eq ‘Vins et alcools Chevalier’. … Read more

WCF Unit Test

As aku says, if you’re testing service methods (ie code behaviour) then you can unit test that directly and bypass the WCF infrastructure. Of course, if your code depends on WCF context classes (like OperationContext) then I suggest introducing wrappers much like ASP.NET MVC does for HttpContext. For testing connectivity, it will depend on the … Read more