I have been searching around for hours and trying different things to get this to work. I have tried so many articles on stackoverflow and either I am too stupid to get thin
I'm coming in late, but you still have some issues you'll need to resolve to get it to work. You need to change the binding for your endpoint to support the HTTP operations.
<bindings>
<webHttpBinding>
<binding name="MyWebServiceBinding" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"/>
</webHttpBinding>
</bindings>
<behaviors>
<endpointBehaviors>
<behavior name="WebHTTPEndpointBehavior">
<webHttp helpEnabled="true"/>
</behavior>
</endpointBehaviors>
</behaviors>
<services>
<service name="MyWCFServices.HelloWorldService"
behaviorConfiguration="MyServiceTypeBehaviors">
<endpoint address="" binding="webHttpBinding" bindingConfiguration="MyWebServiceBinding" behaviorConfiguration="WebHTTPEndpointBehavior"
contract="MyWCFServices.IHelloWorldService"/>
<endpoint contract="IMetadataExchange"
binding="mexHttpBinding" address="mex"/>
</service>
</services>
The maxBufferSize
and maxReceivedMessageSize
is optional.
EDIT: Oops, forgot to add your behaviorConfiguration
in.
change this line
data: {
name: "Joe"
}
to
data: JSON.stringify({name: 'Joe'});
EDIT:
Do this to your service. Add WebHttp binding in the config.
<behaviors>
<endpointBehaviors>
<behavior>
<webHttp />
</behavior>
</endpointBehaviors>
</behaviors>
Hope you know where to add this. If not let me know and I will try to provide some inputs.
EDIT:
Following up on my comment,
<behavior name="myBehaviorName">
<webHttp />
</behavior>
<service name="MyWCFServices.HelloWorldService"
behaviorConfiguration="MyServiceTypeBehaviors">
<endpoint address="" binding="webHttpBinding"
contract="MyWCFServices.IHelloWorldService" behaviorConfiguration="myBehaviorName"/>
<endpoint contract="IMetadataExchange"
binding="mexHttpBinding" address="mex"/>
</service>