0

So today I decided I wanted to remove the .svc file from the WCF service, and started looking online.

Here is the step by step process of what I did:

Step 1: I added the global.asax

void Application_Start(object sender, EventArgs e) 
{
    RouteTable.Routes.Add(new ServiceRoute("Authorization", new WebServiceHostFactory(), typeof(Authenticator)));
    RouteTable.Routes.Add(new ServiceRoute("Miscellaneous", new WebServiceHostFactory(), typeof(Misc)));
}

Note: Authenticator and Misc are my interface implementation

Step 2: I enabled asp.net compatibility

<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />

Step 3: I added [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)] to each of my interface implementation.

Step 4: I had to add [WebInvoke(BodyStyle = WebMessageBodyStyle.WrappedRequest)] to every method in my interface. I don't know what this does, but it was erroring out without it.

Now it "works" but when I navigate to root/Authorization (Authorization being the name of my first service) it tells me no endpoints are found.

My endpoints are specified in my web.config as such:

        <service name="AuthenticatorService.Authenticator">
            <endpoint address="auth" binding="basicHttpBinding" name="AuthEndpoint"
              contract="AuthInterface.IAuthenticator" />
            <endpoint address="mex" binding="mexHttpBinding" name="MetadataEndpoint"
              contract="IMetadataExchange" />
        </service>

I'm very new to WCF so it's probably some stupid mistake.

TheGateKeeper
  • 4,420
  • 19
  • 66
  • 101
  • Um, why did you want to remove the .svc file? – DOK Apr 01 '12 at 17:25
  • Because I read that you can, and I didn't like it there. – TheGateKeeper Apr 01 '12 at 17:26
  • 1
    Sometimes it is easier to learn a new technology the normal way before you start trying to deviate from the standard practice. Especially if you don't have a well-founded reason for your choice (more than just not liking it). If you're feeling stubborn, you could peruse the "Related" links at the right, where you will find [WCF removing .svc extention](http://stackoverflow.com/questions/7354616/wcf-removing-svc-extention), among others. – DOK Apr 01 '12 at 17:33
  • You are right, I decided not to do it. No real gain was in it for me. – TheGateKeeper Apr 01 '12 at 17:42

1 Answers1

3

You're mixing two technologies here - in your config, you define basicHttpBinding which is a SOAP service - yet, in your service route, you pass in a WebServiceHost which is used for the REST services in WCF (based on the webHttpBinding).

Try this - just use the "regular" (SOAP-oriented) ServiceHostFactory in your global.asax file:

void Application_Start(object sender, EventArgs e) 
{
    RouteTable.Routes.Add(
       new ServiceRoute("Authorization", 
                        new ServiceHostFactory(), typeof(Authenticator)));
    RouteTable.Routes.Add(
       new ServiceRoute("Miscellaneous", 
                        new ServiceHostFactory(), typeof(Misc)));
}
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459