Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to call simple WCF service using jQuery or simple js
    primarykey
    data
    text
    <p>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 <code>XMLHttpRequest</code>) it calls back the success function but returns null data.</p> <p>When I tried to access it via firefox browser using this address: <code>http://localhost:8282/Test/TestService.svc/HelloWorld</code></p> <p>It returned an error with code "a:ActionNotSupported" and error detail as</p> <blockquote> <p>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).</p> </blockquote> <p>If I change binding to <code>wsHttpBinding</code> then it returns nothing even in Firefox.</p> <p>Here is the code:</p> <p>File "Test/ITestService.svc":</p> <pre><code>[ServiceContract(Namespace = "http://localhost:8282/")] public interface ITestService { [OperationContract] string HelloWorld(); } </code></pre> <p>File "Test/TestService.svc":</p> <pre><code>public class TestService : ITestService { public string HelloWorld() { return "This is echo from server. Hello World"; } } </code></pre> <p>File "web.config"</p> <pre><code>&lt;system.serviceModel&gt; &lt;services&gt; &lt;service name="radMLRPC.Test.TestService" behaviorConfiguration="radMLRPC.Test.TestServiceBehavior" &lt;endpoint address="HelloWorld" binding="webHttpBinding" contract="radMLRPC.Test.ITestService"&gt; &lt;identity&gt; &lt;dns value="localhost"/&gt; &lt;/identity&gt; &lt;/endpoint&gt; &lt;endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/&gt; &lt;/service&gt; &lt;/services&gt; &lt;behaviors&gt; &lt;serviceBehaviors&gt; &lt;behavior name="radMLRPC.Test.TestServiceBehavior"&gt; &lt;serviceMetadata httpGetEnabled="true"/&gt; &lt;serviceDebug includeExceptionDetailInFaults="true"/&gt; &lt;/behavior&gt; &lt;/serviceBehaviors&gt; &lt;/behaviors&gt; &lt;/system.serviceModel&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload