У меня есть служба WCF, работающая на моем локальном сервере IIS. Я добавил его в качестве ссылки на сайт для проекта С# Website, и он добавляет штраф и автоматически генерирует классы прокси.
Однако, когда я пытаюсь вызвать любой из контрактов на обслуживание, я получаю следующую ошибку:
Описание: Необработанное исключение возникло во время выполнения текущего веб-запроса. Просмотрите трассировку стека для получения дополнительной информации об ошибке и ее возникновении в коде.
Сведения об исключении: System.ServiceModel.ProtocolException: тип содержимого text/html; charset = utf-8 ответного сообщения не соответствует типу содержимого привязки (application/soap + xml; charset = utf-8). Если вы используете пользовательский кодер, убедитесь, что метод IsContentTypeSupported реализован правильно. Первые 1024 байта ответа были: "function bredir (d, u, r, v, c) {var w, h, wd, hd, bi; var b = false; var p = false; var s = [[ 300250, ложный], [250250, ложный], [240400, ложный], [336280, ложный], [180150, ложный], [468,60, ложный], [234,60, ложный], [88,31, ложь], [120,90, ложный], [120,60, ложный], [120240, ложный], [125125, ложный], [728,90, ложный], [160600, ложный], [120600, ложный], [300600, ложный], [300125, ложный], [530300, ложный], [190200, ложный], [470250, ложный], [720300, верно], [500350, верно], [550480, правда]]; 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 я = 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>
  Веб-сайт 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>
 Это моя первая попытка создать WCF, так что все это очень новое. Буду признателен за любую оказанную помощь.

