Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I created a sample WCF and it works with the scenario you explained. However the code is in c#. You can try the below config and code.</p> <pre><code> namespace WCF { [ServiceContract(Namespace = "Testing")] //[ServiceContract] public interface ITestWCF { [OperationContract] [WebInvoke(Method = "POST", ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.WrappedRequest)] String HelloWorld(); } } namespace WCF { // NOTE: You can use the "Rename" command on the "Refactor" menu to change the interface name "IService2" in both code and config file together. class TestWCF : ITestWCF { public string HelloWorld() { return "Hello!!!"; } } } </code></pre> <p>Ajax call:</p> <pre><code>$.ajax({ url: "Service1.svc/rest/HelloWorld?", type: "POST", data: "{}", success: fnsuccesscallback, contentType: "application/json; charset=utf-8", error: fnerrorcallback, dataType: "json" }); </code></pre> <p>Web.config:</p> <pre><code>&lt;system.serviceModel&gt; &lt;client /&gt; &lt;bindings&gt; &lt;basicHttpBinding&gt; &lt;binding name="BasicHttpEndpointBinding"&gt; &lt;security mode="TransportCredentialOnly"&gt; &lt;transport clientCredentialType="None" /&gt; &lt;/security&gt; &lt;/binding&gt; &lt;/basicHttpBinding&gt; &lt;/bindings&gt; &lt;services&gt; &lt;service name="WCF.TestWCF" behaviorConfiguration="TestWCFBehaviour"&gt; &lt;host&gt; &lt;baseAddresses&gt; &lt;add baseAddress="http://localhost:1991/Service1.svc"/&gt; &lt;/baseAddresses&gt; &lt;/host&gt; &lt;endpoint address="rest" binding="webHttpBinding" contract="WCF.ITestWCF" behaviorConfiguration="TestWCFEndPointBehaviour" name="httpEndpoint"&gt;&lt;/endpoint&gt; &lt;endpoint address="soap" binding="basicHttpBinding" contract="WCF.ITestWCF" bindingConfiguration="BasicHttpEndpointBinding"/&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="TestWCFBehaviour"&gt; &lt;serviceMetadata httpGetEnabled="true"/&gt; &lt;serviceDebug includeExceptionDetailInFaults="false"/&gt; &lt;/behavior&gt; &lt;/serviceBehaviors&gt; &lt;endpointBehaviors&gt; &lt;behavior name="TestWCFEndPointBehaviour"&gt; &lt;!--&lt;enableWebScript/&gt;--&gt; &lt;webHttp/&gt; &lt;/behavior&gt; &lt;/endpointBehaviors&gt; &lt;/behaviors&gt; </code></pre> <p></p> <p></p> <p>Please note that i have exposed a endpoint with webHttpBinding and i have named it <strong>rest</strong></p> <p>You can also refer <a href="http://www.wcf.dotnetarchives.com/2013/12/invoking-restful-wcf-service-with_20.html" rel="nofollow">http://www.wcf.dotnetarchives.com/2013/12/invoking-restful-wcf-service-with_20.html</a></p>
    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.
    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