我是 WCF 世界的新手。我有一个包含 Web 应用程序的解决方案(它有对 WCF 服务应用程序的 JQuery Ajax 调用,这是解决方案中的另一个项目。经过 2 天的工作(破解)我处于能够传递请求并获得响应的状态
但是在尝试显示警报时给了我 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
});
网页配置
<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();