TheGateKeeper
TheGateKeeper

Reputation: 4530

Removing .svc from WCF service results in no endpoints found

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.

Upvotes: 0

Views: 721

Answers (1)

marc_s
marc_s

Reputation: 754468

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)));
}

Upvotes: 3

Related Questions