I have been working in .NET for a while, but I am new to WCF. I am trying to create my first WCF service using JSON. I thought that I would start really, very simply, and then I would build from there. But I somehow managed to spoil even the simplest services. Here is what I still have.
Web.Config:
<?xml version="1.0"?> <configuration> <system.web> <compilation debug="true" targetFramework="4.0" /> </system.web> <system.serviceModel> <services> <service name="MarathonInfo.MarathonInfoService"> <endpoint address="http://localhost:10298/MarathonInfoService.svc" binding="webHttpBinding" contract="MarathonInfo.IMarathonInfo" /> </service> </services> <behaviors> <serviceBehaviors> <behavior> <serviceMetadata httpGetEnabled="true"/> <serviceDebug includeExceptionDetailInFaults="false"/> </behavior> </serviceBehaviors> </behaviors> <serviceHostingEnvironment multipleSiteBindingsEnabled="false" /> </system.serviceModel> <system.webServer> <modules runAllManagedModulesForAllRequests="true"/> </system.webServer> </configuration>
Then in the service file:
namespace MarathonInfo { public class MarathonInfoService : IMarathonInfo { public String GetData() { return "Hello World"; } } }
And in the interface:
namespace MarathonInfo { [ServiceContract] public interface IMarathonInfo { [OperationContract] [WebInvoke(Method = "GET", UriTemplate = "/GetData", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)] String GetData(); } }
So, when I go to this URL:
http:
I get this error:
A message with To 'http: // localhost: 10298 / MarathonInfoService.svc / GetData' cannot be processed at the receiver due to an AddressFilter mismatch on the EndpointDispatcher. Make sure the sender and receiver of the Endpoint Addresses agree.
I can run the service just fine through Visual Studio in debug mode. But in the browser, I get only this error.
What am I doing wrong?
Thanks!
Casey
source share