我在本地 IIS 服务器上运行了 WCF 服务。我已经添加了它作为一个 C # 网站项目的服务引用,它添加了罚款,并自动生成代理类。
但是,当我尝试调用任何服务契约时,都会得到以下错误:
过程中发生未处理的异常 当前网络请求的执行。 请查看堆栈跟踪以了解更多信息 有关错误和位置的信息 源于密码。
异常详细信息: System. ServiceModel. ProtocolException: 内容类型 text/html; 响应消息的 charset = utf-8 类的内容类型不匹配 绑定(应用程序/肥皂 + xml; Charset = utf-8) 编码器,确保 方法是 首1024 字节的响应是:
功能 Bredir (d,u,r,v,c){ var w,h,wd,hd,bi; var B = false; var p = false; var 50,250,false ] ,[240,400,false ] ,[336,280,false ] ,[180,150,false ] ,[234,60,false ] ,[88,31,false ] ,[120,60,false ] ,[120,60,false ] ,[125,125,false ] ,[728,90,false ] ,[120,600,false ] ,[300,600,false ] ,[300,300,false ] ,[300,125,false ] ,[530,300,false ] ,[190,200,false ] ,[470,250,false ] ,[720,300,true ] ,[500,350,true ] ,[550,480,true ] ; 如果(typeof (document.body. offsetHeight) = = ‘ number’){ h = document.body. offsetHeight; w = document.body. offsetWidth; } for (var I = 0; i我还有一个控制台应用,可以和 WCF 服务通信,控制台应用程序可以调用方法而不会出现这个错误。
下面是我的配置文件的摘录。
WCF 服务 Web.Config:
<system.serviceModel>
<services>
<service name="ScraperService" behaviorConfiguration="ScraperServiceBehavior">
<endpoint address=""
binding="wsHttpBinding"
bindingConfiguration="WSHttpBinding_IScraperService"
contract="IScraperService" />
<endpoint address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://example.com" />
</baseAddresses>
</host>
</service>
</services>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_IScraperService"
bypassProxyOnLocal="false" transactionFlow="false"
hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="2000000" maxReceivedMessageSize="2000000"
messageEncoding="Text" textEncoding="utf-8"
useDefaultWebProxy="true" allowCookies="false">
<readerQuotas
maxDepth="2000000" maxStringContentLength="2000000"
maxArrayLength="2000000" maxBytesPerRead="2000000"
maxNameTableCharCount="2000000" />
<reliableSession
enabled="false" ordered="true" inactivityTimeout="00:10:00" />
<security mode="Message">
<message clientCredentialType="Windows"
negotiateServiceCredential="true"
algorithmSuite="Default"
establishSecurityContext="true" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="ScraperServiceBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
网站项目服务客户端 Web.Config
:
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_IScraperService"
closeTimeout="00:01:00" openTimeout="00:01:00"
receiveTimeout="00:10:00" sendTimeout="00:01:00"
bypassProxyOnLocal="false" transactionFlow="false"
hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8"
useDefaultWebProxy="true" allowCookies="false">
<readerQuotas
maxDepth="32" maxStringContentLength="8192"
maxArrayLength="16384" maxBytesPerRead="4096"
maxNameTableCharCount="16384" />
<reliableSession enabled="false"
ordered="true" inactivityTimeout="00:10:00" />
<security mode="Message">
<transport clientCredentialType="Windows"
proxyCredentialType="None" realm="" />
<message clientCredentialType="Windows"
negotiateServiceCredential="true"
algorithmSuite="Default" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint name="WSHttpBinding_IScraperService"
address="http://example.com/ScraperService.svc"
binding="wsHttpBinding"
bindingConfiguration="WSHttpBinding_IScraperService"
contract="ScraperService.IScraperService" >
<identity>
<servicePrincipalName value="host/FreshNET-II" />
</identity>
</endpoint>
</client>
</system.serviceModel>