Настройка зверя - PullRequest
       26

Настройка зверя

2 голосов
/ 24 июня 2011

Кто-нибудь может мне помочь с настройкой WCF, я получаю ошибки (400) Плохой запрос , и программа просмотра трассировки сказала мне, что:

"Максимальная квота размера сообщения для входящихсообщений (65536) было превышено. Чтобы увеличить квоту, используйте свойство MaxReceivedMessageSize для соответствующего элемента привязки. "

Я посмотрел на app.config моего клиента и изменил свойства соответственно, нопроблема осталась, потом я посмотрел на web.config сервера, где я обнаружил, что тега <service>...</service> нет вообще, поэтому я щелкнул правой кнопкой мыши web.config и выбрал Edit WCF configuration окно, всплывающее при нескольких щелчкахи моя конфигурация службы wcf готова, НО он начал выдавать

"Сервер не дал значимого ответа; это может быть вызвано несоответствием контракта, преждевременным завершением сеанса или внутренней ошибкой сервера"

Средство просмотра трассировки показывает 3 предупреждения:

"Не удалось открыть System.ServiceModel.ServiceHost"

"Ошибкаed System.ServiceModel.ServiceHost "

" ServiceHost Failed "

Вот мой сервер web.configs:

Версия0 (работает, но с ограничениями):

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.diagnostics>
    <sources>
      <source name="System.ServiceModel" switchValue="Information, ActivityTracing" propagateActivity="true">
        <listeners>
          <add name="traceListener" type="System.Diagnostics.XmlWriterTraceListener" initializeData="c:\log\Traces1.svclog" />
        </listeners>
      </source>
    </sources>
  </system.diagnostics>
  <connectionStrings>
    <add name="PopulizerConnectionString" connectionString="Data Source=VM-LU4\SQLSERVER;Initial Catalog=Populizer;Integrated Security=True" providerName="System.Data.SqlClient" />
  </connectionStrings>
  <system.web>
    <compilation debug="true" targetFramework="4.0">
      <assemblies>
        <add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
      </assemblies>
    </compilation>
  </system.web>
  <system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
          <serviceMetadata httpGetEnabled="true" />
          <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true" />
  </system.webServer>
</configuration>

И тот, который показывает 3 предупреждения:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.diagnostics>
    <sources>
      <source name="System.ServiceModel" switchValue="Information, ActivityTracing" propagateActivity="true">
        <listeners>
          <add name="traceListener" type="System.Diagnostics.XmlWriterTraceListener" initializeData="c:\log\Traces1.svclog" />
        </listeners>
      </source>
    </sources>
  </system.diagnostics>
  <connectionStrings>
    <add name="PopulizerConnectionString" connectionString="Data Source=VM-LU4\SQLSERVER;Initial Catalog=Populizer;Integrated Security=True" providerName="System.Data.SqlClient" />
  </connectionStrings>
  <system.web>
    <compilation debug="true" targetFramework="4.0">
      <assemblies>
        <add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
      </assemblies>
    </compilation>
  </system.web>
  <system.serviceModel>
    <services>
      <service name="NewServiceType">
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:1948/Commander.svc" />
          </baseAddresses>
        </host>
      </service>
      <service name="Populator.Commander">
        <endpoint address="http://localhost:1948/Commander.svc" binding="basicHttpBinding"
          bindingConfiguration="" name="CommanderEndpoint" contract="Private.ICommander" />
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
          <serviceMetadata httpGetEnabled="true" />
          <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true" />
  </system.webServer>
</configuration>

РЕДАКТИРОВАТЬ

Это версия # 3 моей веб-конфигурации, которая по-прежнему показывает те же три предупреждения в TraceViewer

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.diagnostics>
    <sources>
      <source name="System.ServiceModel" switchValue="Information, ActivityTracing" propagateActivity="true">
        <listeners>
          <add name="traceListener" type="System.Diagnostics.XmlWriterTraceListener" initializeData="c:\log\Traces.svclog" />
        </listeners>
      </source>
    </sources>
  </system.diagnostics>
  <connectionStrings>
    <add name="PopulizerConnectionString" connectionString="Data Source=VM-LU4\SQLSERVER;Initial Catalog=Populizer;Integrated Security=True" providerName="System.Data.SqlClient" />
  </connectionStrings>
  <system.web>
    <compilation debug="true" targetFramework="4.0">
      <assemblies>
        <add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
      </assemblies>
    </compilation>
  </system.web>
  <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="httpBasicBinding_Service01" closeTimeout="00:10:00"
          openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00"
          maxBufferSize="655360000"
          maxBufferPoolSize="655360000" maxReceivedMessageSize="655360000">
          <readerQuotas maxDepth="655360000" maxStringContentLength="655360000"
            maxArrayLength="655360000" maxBytesPerRead="655360000" maxNameTableCharCount="655360000" />
        </binding>
      </basicHttpBinding>
    </bindings>
    <services>
      <service name="NewServiceType">
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:1948/Commander.svc" />
          </baseAddresses>
        </host>
      </service>
      <service name="Populator.Commander">
        <endpoint address="http://localhost:1948/Commander.svc" binding="basicHttpBinding"
          bindingConfiguration="httpBasicBinding_Service01" name="CommanderEndpoint" contract="Private.ICommander" />
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
          <serviceMetadata httpGetEnabled="true" />
          <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true" />
  </system.webServer>
</configuration>

Ответы [ 3 ]

0 голосов
/ 24 июня 2011

Вам необходимо установить конфигурацию привязки.

Где вы написали:

bindingConfiguration = ""

вы должны написать:

bindingConfiguration="httpBasicBinding_Service01"

и затем настройте:

<basicHttpBinding>
    <binding name="httpBasicBindingService 01" closeTimeout="00:10:00"
      openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00"
      maxBufferSize="655360000"
      maxBufferPoolSize="655360000" maxReceivedMessageSize="655360000">
      <readerQuotas maxDepth="655360000" maxStringContentLength="655360000"
        maxArrayLength="655360000" maxBytesPerRead="655360000" maxNameTableCharCount="655360000" />
    </binding>
  </basicHttpBinding>
0 голосов
/ 27 июня 2011

Помогло пошаговое конфигурирование с рабочей на нерабочую версию конфигурации. Вот файл web.config сервера:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.diagnostics>
    <sources>
      <source name="System.ServiceModel" switchValue="Information, ActivityTracing" propagateActivity="true">
        <listeners>
          <add name="traceListener" type="System.Diagnostics.XmlWriterTraceListener" initializeData="c:\log\Traces.svclog" />
        </listeners>
      </source>
    </sources>
  </system.diagnostics>
  <connectionStrings>
    <add name="PopulizerConnectionString" connectionString="Data Source=VM-LU4\SQLSERVER;Initial Catalog=Populizer;Integrated Security=True" providerName="System.Data.SqlClient" />
  </connectionStrings>
  <system.web>
    <compilation debug="true" targetFramework="4.0">
      <assemblies>
        <add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
      </assemblies>
    </compilation>
  </system.web>
  <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding  name="ICommander_BindingConfiguration"
                  closeTimeout="01:00:00"
                  openTimeout="00:01:00"
                  receiveTimeout="00:10:00"
                  sendTimeout="00:01:00"
                  allowCookies="false"
                  bypassProxyOnLocal="false"
                  hostNameComparisonMode="StrongWildcard"
                  maxBufferSize="1048576"
                  maxBufferPoolSize="524288"
                  maxReceivedMessageSize="1048576"
                  messageEncoding="Text"
                  textEncoding="utf-8"
                  transferMode="Buffered"
                  useDefaultWebProxy="true"
        >
          <readerQuotas
              maxDepth="32"
              maxStringContentLength="1048576"
              maxArrayLength="1048576"
              maxBytesPerRead="4096"
              maxNameTableCharCount="1048576"
          />
          <security mode="None">
            <transport clientCredentialType="None" proxyCredentialType="None" realm="" />
            <message clientCredentialType="UserName" algorithmSuite="Default" />
          </security>
        </binding>
        <binding
          name="ICommunicator_BindingConfiguration"
          closeTimeout="01:00:00"
          openTimeout="00:01:00"
          receiveTimeout="00:10:00"
          sendTimeout="00:01:00"
          allowCookies="false"
          bypassProxyOnLocal="false"
          hostNameComparisonMode="StrongWildcard"
          maxBufferSize="1048576"
          maxBufferPoolSize="524288"
          maxReceivedMessageSize="1048576"
          messageEncoding="Text"
          textEncoding="utf-8"
          transferMode="Buffered"
          useDefaultWebProxy="true"
        >
          <readerQuotas
              maxDepth="32"
              maxStringContentLength="1048576"
              maxArrayLength="1048576"
              maxBytesPerRead="4096"
              maxNameTableCharCount="1048576"
          />
          <security mode="None">
            <transport clientCredentialType="None" proxyCredentialType="None" realm="" />
            <message clientCredentialType="UserName" algorithmSuite="Default" />
          </security>
        </binding>
      </basicHttpBinding>
    </bindings>
    <services>
      <service name="Populator.Commander">
        <endpoint contract="Private.ICommander" binding="basicHttpBinding" bindingConfiguration="ICommander_BindingConfiguration" />
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="CommanderBehavior">
          <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
          <serviceMetadata httpGetEnabled="true" />
          <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true" />
  </system.webServer>
</configuration>
0 голосов
/ 24 июня 2011

Какова максимальная кавычка в обязательном элементе в конфигурации server ?Посмотрите пример ниже, пожалуйста.

<wsHttpBinding>
    <binding name="WSHttpBinding_ISomeService" 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 ordered="true" inactivityTimeout="00:10:00"
        enabled="false" />
      <security mode="Message">
        <transport clientCredentialType="Windows" proxyCredentialType="None"
          realm="" />
        <message clientCredentialType="Windows" negotiateServiceCredential="true"
          algorithmSuite="Default" establishSecurityContext="true" />
      </security>
    </binding>
  </wsHttpBinding>
...