WCF Service Client: el tipo de contenido text / html; charset = utf-8 del mensaje de respuesta no coincide con el tipo de contenido del enlace
Tengo un servicio WCF ejecutándose en mi servidor IIS local. Lo agregué como referencia de servicio a un proyecto de sitio web de C # y agrega muy bien y genera las clases proxy automáticamente.
Sin embargo, cuando intento llamar a cualquiera de los contratos de servicio, aparece el siguiente error:
Descripción Se produjo una excepción no controlada durante la ejecución de la solicitud web actual. Revise el seguimiento de la pila para obtener más información sobre el error y dónde se originó en el código.
Detalles de excepción: System.ServiceModel.ProtocolException: el tipo de contenido text / html; charset = utf-8 del mensaje de respuesta no coincide con el tipo de contenido del enlace (application / soap + xml; charset = utf-8). Si usa un codificador personalizado, asegúrese de que el método IsContentTypeSupported se implemente correctamente. Los primeros 1024 bytes de la respuesta fueron: 'función bredir (d, u, r, v, c) {var w, h, wd, hd, bi; var b = falso; var p = falso; var s = [[ 300,250, falso], [250,250, falso], [240,400, falso], [336,280, falso], [180,150, falso], [468,60, falso], [234,60, falso], [88,31, falso], [120,90, falso], [120,60, falso], [120,240, falso], [125,125, falso], [728,90, falso], [160,600, falso], [120,600, falso] , [300,600, falso], [300,125, falso], [530,300, falso], [190,200, falso], [470,250, falso], [720,300, verdadero], [500,350, verdadero], [550,480, verdadero]]; 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;} para (var i = 0; i
También tengo una aplicación de consola que también se comunica con el servicio WCF y la aplicación de consola puede llamar a los métodos correctamente sin obtener este error.
Abajo hay extractos de mis archivos de configuración.
WCF Service 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>
Cliente de servicio de proyecto de sitio webWeb.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>
Este es mi primer intento de crear un WCF, así que todo es muy nuevo. Cualquier ayuda es muy apreciada