I have a WCF service running on my local IIS server. I added it as a website link for the C # Website project, and it adds a penalty and automatically generates proxy classes.
However, when I try to call any of the service contracts, I get the following error:
Description: An unhandled exception occurred during the execution of the current web request. View the stack trace for more information about the error and its occurrence in the code.
Exception Details: System.ServiceModel.ProtocolException: Content Type text / html; charset = utf-8 of the response message does not match the content type of the binding (application / soap + xml; charset = utf-8). If you use a custom encoder, make sure that the IsContentTypeSupported method is implemented correctly. The first 1024 bytes of the response were: "function bredir (d, u, r, v, c) {var w, h, wd, hd, bi; var b = false; var p = false; var s = [[300250, false ], [250,250, false], [240400, false], [336280, false], [180150, false], [468.60, false], [234.60, false], [88.31, false], [120.90, false], [120.60, false], [120240, false], [125125, false], [728.90, false], [160600, false], [120600, false], [300600 , false], [300125, false], [530300, false], [190200, false], [470250, false], [720300, true], [500350, true], [550480, true]]; if (typeof (window.innerHeight) == 'number') {h = window.innerHeight; w = window.innerWidth;} else if (typeof (document.body.offsetHeight) == 'number') {h = document. body.offsetHeight ; w = document.body.offsetWidth;} for (var i = 0; i
I also have a console application that also interacts with the WCF service, and the console application can call methods efficiently without getting this error.
The following are excerpts from my configuration files.
WCF Web.Config Service:
<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>
Website Project Service Client 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>
This is my first attempt to create WCF, so this is all very new. Any help is much appreciated.