I have an ASP.NET MVC 3 application that uses a WCF service within the same project. Ideally I'd like to call out to this service using jQuery. However, I cannot seem to wrap my head around what I'm doing. Should I still create an endpoint in the configuration? Right now I receive the following exception:
Security settings for this service require 'Anonymous' Authentication but it is not enabled for the IIS application that hosts this service.
I can enable anonymous authentication for IIS but I'd prefer to use Windows. When I setup a binding configuration, since there is no endpoint, I'm not sure where to add that configuration to.
If you want to be able to reach your WCF service, you will generally need to setup an endpoint. An alternative approach would be to host your service "In-Proc" using the InProcFactory
clas, which is part of the ServiceModelEx
library from Juval Löwy available from the downloads page of his website (registration is required to download it, just search for "ServiceModelEx" and click the link). That approach would look like:
IMyService proxy = InProcFactory.CreateInstance<MyServiceClass, IMyService>();
proxy.MyMethod();
This reduces the configuration if you don't need to do any custom configuration; however, as soon as you hit a boundary with the default configuration, you'll either need to go back to using a configured endpoint, or looking for a way to programmatically update your service's configuration.