gpt4 book ai didi

c# - 使用 Ajax 请求使用 Wcf 服务时配置文件错误

转载 作者:行者123 更新时间:2023-11-30 17:55:37 25 4
gpt4 key购买 nike

我在使用 jquery 使用 WCF 服务时遇到了问题。我遇到错误“找不到配置绑定(bind)扩展‘system.serviceModel/bindings/webHttpbinding’。验证此绑定(bind)扩展是否已在 system.serviceModel/extensions/bindingExtensions 中正确注册并且拼写正确。”

这是我的 Web.Config 文件:

<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<bindings>
<webHttpBinding>
<binding name="webHttpBindingWithJsonP" crossDomainScriptAccessEnabled="true" />
</webHttpBinding>
</bindings>
<behaviors>
<endpointBehaviors>
<behavior name="RestfulServiceBehavior">
<webHttp helpEnabled="true"/>
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="WebServiceBehavior">

<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name="WcfService1.RestfulServiceImp" behaviorConfiguration="WebServiceBehavior">
<endpoint address="" behaviorConfiguration="RestfulServiceBehavior"
bindingConfiguration="webHttpBindingWithJsonP" binding="webHttpbinding" contract="WcfService1.IRestfulServiceImp"/>
<!--<endpoint address="mex" binding="mexHttpBinding" contract="WcfService1.IRestfulServiceImp"/>-->
<endpoint address="soap" binding="basicHttpBinding" contract="WcfService1.IRestfulServiceImp"/>
</service>
</services>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" aspNetCompatibilityEnabled="false"/>

</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<httpProtocol>
<customHeaders>
<add name="Access-Control-Allow-Origin" value="*" />
<add name="Access-Control-Allow-Headers" value="Content-Type" />
</customHeaders>
</httpProtocol>
</system.webServer>
<system.diagnostics>
<sources>
<source name="System.ServiceModel"
switchValue="Information, ActivityTracing"
propagateActivity="true">
<listeners>
<add name="xml"
type="System.Diagnostics.XmlWriterTraceListener"
initializeData="c:\log\Traces.svclog" />
</listeners>
</source>
</sources>
</system.diagnostics>

这是我的服务名称 RestfulServiceImp,我的契约(Contract)是 IRestfulServiceImp请就此提出宝贵建议。

提前致谢。

最佳答案

您的配置中存在大小写不匹配,

<bindings>
<webHttpBinding>
<binding name="webHttpBindingWithJsonP" crossDomainScriptAccessEnabled="true" />
</webHttpBinding>
</bindings>

<endpoint address="" behaviorConfiguration="RestfulServiceBehavior" 
bindingConfiguration="webHttpBindingWithJsonP" binding="webHttpbinding" contract="WcfService1.IRestfulServiceImp"/>
<!--<endpoint address="mex" binding="mexHttpBinding" contract="WcfService1.IRestfulServiceImp"/>-->
<endpoint address="soap" binding="basicHttpBinding" contract="WcfService1.IRestfulServiceImp"/>

检查 webHttpBinding 中的大小写差异。您使用的是 webHttpbinding 而不是 webHttpBinding。

关于c# - 使用 Ajax 请求使用 Wcf 服务时配置文件错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14887963/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com