Well, your current problem is caused by the fact that WebInvokewhen you do not specify a parameter Method, the default will be "POST". Your jQuery code issues a "GET" request, so a "method not allowed" error is expected.
GET , . Windows http://localhost:8766, , - `http://localhost:8766. :
"" , ( ) TCP HTML, script. , .
JSON, GET, JSONP. , . jQuery :
$.ajax({
url: "http://localhost:8766/Test",
dataType: "jsonp",
processData: false,
type: "GET",
success: function (msg) {
console.log(msg);
}
});
WebInvoke, WebHttpBinding BasicHttpBinding. WebInvoke , WebHttpBinding. WebHttpBinding, , JSONP. , :
<system.serviceModel>
<bindings>
<webHttpBinding>
<binding name="webHttpBindingWithJsonP" crossDomainScriptAccessEnabled="true" />
</webHttpBinding>
</bindings>
<behaviors>
<endpointBehaviors>
<behavior name="webHttpBehavior">
<webHttp />
</behavior>
</endpointBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="ServiceConfig" name="MyServices">
<endpoint address="srv" binding="webHttpBinding" contract="Operations" bindingConfiguration="webHttpBindingWithJsonP" behaviorConfiguration="webHttpBehavior" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8766" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceConfig">
<serviceMetadata httpGetEnabled="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
</system.serviceModel>
post, .
, !