Calender
<<  September 2010  >>
MoTuWeThFrSaSu
303112345
6789101112
13141516171819
20212223242526
27282930123
45678910
Posted by: Jason | Created on: 06/07/2010, 21:37

This is one of those errors that is misleading because it obfuscates the REAL issue.  I realized today that I forgot to add a namespace to my WCF project.  So I dutifully went back and add it.  Then I got this error.  

WCF Service Host cannot find any service metadata

Turns out that this broke the references to the contracts in my app.config (or web.config.)  All I had to do was right click on my app.config and click "Edit WCF Configuration" and troll through the tree of settings and re-set my contract fields.  By clicking the ellipses and browsing to the DLL and then the interface, it would refresh the setting with the appropriate namespace in the value.  Alternatively you can just type the namespace in the config file directly of course, but I rather like using the tool.

Today I had a strange issue with my WCF service.  I was getting an error in the wcftestclient after I made a change to a method and published it.  The odd part is there was no "exception" information at all.  Everything was null, but I did have a stacktrace that ended with:

System.ServiceModel.Channels.ServiceChannel.ThrowIfFaultUnderstood ... 

I googled this problem only to find lots of people having this issue but no one offered up the real cause, and I had to discover it myself.  The reason is so simple it made me feel pretty dumb but on the flip side, I've managed to work with WCF for this long without making this mistake so ... there is that.

Turns out I simply WASN'T catching an exception.  WCF can not raise an exception past the service boundary of course.  I think for grins I actually tried to serialize an exception once and it wasn't pretty, but anyway ... to resolve this, I simply wrote an Error object that has everything I need about the exception and added it to my response object that the service method returns. If an exception occurs, I capture the information into the Error object and make sure my WCF service returns the response regardless.  On the client side you simply have to check the error object to see if its' not null, and react appropriately.  This is 101 stuff but I thought I'd mention it just in case it may help someone. 

If anyone reading this knows of a slicker way, please post a comment with a link to further reading!

 

j

 


Posted by: Jason | Created on: 11/01/2010, 22:27

I overloaded a method in my WCF service that compiled fine, but exploded in my face at runtime.   A bit of digging around later and I discovered you can get around this "limitation" by using the "name" attribute in your OperationContract tag of the ServiceContract.

Here is an example I found and the link to the original article where I found the answer:

[ServiceContract]
public interface ICalendarService
{
   [OperationContract(Name = "GetScheduledEventsByDate")]
   ScheduledEvent[] GetScheduledEvents(DateTime date);

   [OperationContract(Name = "GetScheduledEventsByDateRange")]
   ScheduledEvent[] GetScheduledEvents(DateTime start, DateTime end);
}

http://jeffbarnes.net/blog/post/2006/09/20/Overloading-Methods-in-WCF.aspx