I have a very simple WCF Welcome Service, as shown below. When I call it through the asp.net project, adding a link to the web service, it works fine. But when I call it using jQuery or a standard js-ajax call (using XMLHttpRequest ), it calls the success function, but returns null data.
When I tried to access it through the Firefox browser using this address: http://localhost:8282/Test/TestService.svc/HelloWorld
He returned an error with the code "a: ActionNotSupported" and the error detail as
A message with an action "cannot be processed at the receiver due to a ContractFilter mismatch in the EndpointDispatcher. This may be due to a contract mismatch (action mismatch between the sender and the recipient) or a binding / security mismatch between the sender and the recipient. Make sure the sender and recipient have the same contract and the same binding (including security requirements, such as message, transport, no).
If I change the binding to wsHttpBinding , then it does not return anything even in Firefox.
Here is the code:
File "Test / ITestService.svc":
[ServiceContract(Namespace = "http://localhost:8282/")] public interface ITestService { [OperationContract] string HelloWorld(); }
File "Test / TestService.svc":
public class TestService : ITestService { public string HelloWorld() { return "This is echo from server. Hello World"; } }
File "web.config"
<system.serviceModel> <services> <service name="radMLRPC.Test.TestService" behaviorConfiguration="radMLRPC.Test.TestServiceBehavior" <endpoint address="HelloWorld" binding="webHttpBinding" contract="radMLRPC.Test.ITestService"> <identity> <dns value="localhost"/> </identity> </endpoint> <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/> </service> </services> <behaviors> <serviceBehaviors> <behavior name="radMLRPC.Test.TestServiceBehavior"> <serviceMetadata httpGetEnabled="true"/> <serviceDebug includeExceptionDetailInFaults="true"/> </behavior> </serviceBehaviors> </behaviors> </system.serviceModel>
Adeem source share