我是新來的WCF世界。我有一個解決方案,其中包含Web應用程序(其中有JQuery的Ajax調用WCF服務應用程序,這是解決方案中的另一個項目。工作2天后(破解)我處於一種狀態,我可以通過請求並獲得響應Jquery調用wcf服務給200解析器錯誤
但在試圖說明,在警報給了我200解析錯誤。
任何幫助將是非常讚賞
進一步參考
$.ajax({
async: true,
type: 'GET', //GET or POST or PUT or DELETE verb
url: 'http://localhost:61057/Service1.svc/GetCustomer', // Location of the service
dataType: 'jsonp', //Expected data format from server
success: function (data) {//On Successfull service call
ServiceSucceeded(data);
},
error: function() { ServiceFailed(Data); } // When Service call fails
});
Web.conf IG
<system.serviceModel>
<services>
<service name="FIN.Services.Service1" behaviorConfiguration="DefaultBehavior">
<endpoint address="http://localhost:61057/service1.svc" binding="webHttpBinding" contract="FIN.Services.IService1" behaviorConfiguration="AjaxBehavior">
<identity>
<dns value="locahost"/>
</identity>
</endpoint>
<endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex"/>
</service>
</services>
<bindings>
<webHttpBinding>
<binding name="webBinding">
<security mode="None">
</security>
</binding>
</webHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="DefaultBehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="AjaxBehavior">
<enableWebScript/>
</behavior>
</endpointBehaviors>
</behaviors>
</system.serviceModel>
服務接口:
[WebInvoke(ResponseFormat = WebMessageFormat.Json, Method = "GET", BodyStyle = WebMessageBodyStyle.WrappedRequest, RequestFormat = WebMessageFormat.Json)]
[OperationContract]
string GetCustomer();
既然你跳端口,看看這裏: http://stackoverflow.com/questions/7234599/cors-support-within-wcf-rest-services/7770206#7770206 – granadaCoder