I had to write a WCF service for a project and I hadn’t created a WCF service for a while.
I was trying to write mine to fit in with the rest of the projects but I was totally confused because I was looking at the other WCF services in the project and looking to copy the shell and modify (like all good developers do:-))
I could see there was a SVC file, I could see the code but in the web.config there was no service xml section for the WCF service.
I trying to look at the url for the SVC to see if I could see the wsdl but when I did I got the message no endpoint found.
WHAT WAS GOING ON.
Sometimes as a developer, when you haven’t worked on an area for a while, you have a horrible feeling they have changed the way it worked to some completely new method and framework a bit like the way web services were replaced with WCF. but this wasn’t the case, it was CRM 2011 project (not that makes any difference calling a WCF service).
I asked a developer and he said it must be a factory service, I must have had a completely blank look on my face because he then offered to show me. A good tip is if you don’t understand something ask someone to point you in the right direction because you can save yourself days of puzzling.
Not only had I never heard of using WebServiceHostFactory to create a WCF but I had never come across it in any of the code I have worked with.
I was interested to learn a bit more about it, It’s a way to dynamically create services and it automatically creates the endpoints for the service and was added in .NET 3.5
Here is MSDN class
this flashcard gives a good quick explanation
WebServiceHostFactoryclass and how is it used?
When hosting a web service in IIS, the
WebServiceHostFactory class can be used to automatically configure the endpoints for the service. Endpoints will be configured to use
WebServiceHostFactory class will automatically create a
WebServiceHost class when the web service is activated. The following example demonstrates how to reference the
WebServiceHostFactory in a .svc file:
<%@ ServiceHost Service="OrderService" Factory="System.ServiceModel.Activation.WebServiceHostFactory" %>
Here are some simple tutorials if you want to learn more
Picture from http://daarken.com/blog/2012/08/11/lotr-magic-and-other-news/
2 thoughts on “WCF with no service xml or endpoints? What is this magic?”