我需要使用GET和POST ajaxcall来使用WCF服务。通过使用下面的代码我可以实现POST方法,现在我想使用GET方法使用wcf服务。我在哪里需要更改代码。
JS -
var para = { "ID": "87268" };
$.ajax({
url: 'http://localhost/Service/Review.svc/GetList',
data: para,
type: "POST",
dataType: "json",
contentType: "application/json; charset=utf-8",
success: function (result) { }
})
WCF服务 -
[OperationContract]
[WebInvoke(Method = "POST", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json,BodyStyle=WebMessageBodyStyle.WrappedRequest)]
string GetList(int ID);
WEB.CONFIG
<services>
<service name="Service.Reviews" behaviorConfiguration="ServiceBehaviour">
<endpoint address="" binding="webHttpBinding" contract="Service.IReviews" behaviorConfiguration="web">
</endpoint>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehaviour">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="web">
<webHttp />
</behavior>
</endpointBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
答案 0 :(得分:0)
你所拥有的每个地方&#34; POST&#34;你需要改为&#34; GET&#34;,没有?