I have a very simple hello world WCF service as given below. When I call it via asp.net project by adding web service reference it works perfectly fine. But when I call it using jQuery or standard js ajax call (using XMLHttpRequest) it calls back the success function but returns null data.
When I tried to access it via firefox browser using this address: http://localhost:8282/Test/TestService.svc/HelloWorld
It returned an error with code "a:ActionNotSupported" and error detail as
The message with Action '' cannot be processed at the receiver, due to a ContractFilter mismatch at the EndpointDispatcher. This may be because of either a contract mismatch (mismatched Actions between sender and receiver) or a binding/security mismatch between the sender and the receiver. Check that sender and receiver have the same contract and the same binding (including security requirements, e.g. Message, Transport, None).
If I change binding to wsHttpBinding then it returns nothing 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>