我一直在 fx3.5 上使用 WCF 学习和构建 JSONP Web 服务。你可以阅读我在以下网站进行的一些试验.NET ASMX - 返回纯 JSON? https://stackoverflow.com/questions/1903022/net-asmx-returning-pure-json我终于得到了一个运行的示例,但现在我正在将它放入我的应用程序中。
- RivWorks.Web - 网站 - 位于http://dev.example.com http://dev.example.com
- RivWorks.Web.Service - 新的 JSONP 服务 - 位于http://dev.example.com/services/ http://dev.example.com/services/- 服务的 web.config 位于此处。
该服务的 web.config:
<system.serviceModel>
<behaviors>
<endpointBehaviors>
<behavior name="JsonpServiceBehavior">
<webHttp />
</behavior>
</endpointBehaviors>
</behaviors>
<services>
<service name="RivWorks.Web.Service.CustomerService">
<endpoint address=""
binding="customBinding"
bindingConfiguration="jsonpBinding"
behaviorConfiguration="JsonpServiceBehavior"
contract="RivWorks.Web.Service.ICustomerService" />
</service>
<service name="RivWorks.Web.Service.NegotiateService">
<endpoint address=""
binding="customBinding"
bindingConfiguration="jsonpBinding"
behaviorConfiguration="JsonpServiceBehavior"
contract="RivWorks.Web.Service.INegotiateService" />
</service>
</services>
<bindings>
<customBinding>
<binding name="jsonpBinding" >
<jsonpMessageEncoding />
<httpTransport manualAddressing="true"/>
</binding>
</customBinding>
</bindings>
<extensions>
<bindingElementExtensions>
<add name="jsonpMessageEncoding"
type="RivWorks.Web.Service.JSONP.JsonpBindingExtension
, RivWorks.Web.Service
, Version=1.0.0.0
, Culture=neutral
, PublicKeyToken=null"/>
</bindingElementExtensions>
</extensions>
</system.serviceModel>
我收到以下错误,并且我已尝试了所有我能想到的方法来修复它。发现我的代码中散布着一些拼写错误(服务而不是服务)。我正在使用位于以下位置的示例代码MSDN http://msdn.microsoft.com/en-us/library/cc716898.aspx。这是错误:
Configuration Error Description:** An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.
Parser Error Message: The type 'RivWorks.Web.Service.JSONP.JsonpBindingExtension
, RivWorks.Web.Service
, Version=1.0.0.0
, Culture=neutral
, PublicKeyToken=null' registered for extension 'jsonpMessageEncoding' could not be loaded.
Source Error:
Line 58: <customBinding>
Line 59: <binding name="jsonpBinding">
Line 60: <jsonpMessageEncoding />
Line 61: <httpTransport manualAddressing="true" />
Line 62: <binding>
Source File: C:\RivWorks\dev\services\web.config Line: 60
Version Information: Microsoft .NET Framework Version:2.0.50727.3603; ASP.NET Version:2.0.50727.3082
有人知道我还可以检查什么吗?有一个名为 RivWorks.Web.Service.dll 的 DLL,它正在构建并复制到网站的 bin 目录中。服务 Web.config 正在复制到网站的 Services 目录。我的网站的 web.config 中没有任何冲突。我已经检查了所有拼写问题。