0

我想发布一个带有 basicHttpBinding 配置的 Web 服务。我正在使用 basicHttpBinding 配置来增加 65536 字节的默认消息大小。我遇到的问题是,当我使用如下所示的 web.config 设置时,出现错误:

此服务的元数据发布当前已禁用。

我的主要目标是能够增加默认消息大小并能够将二进制文件保存在数据库中,因此欢迎任何其他配置,但是我试图使其尽可能简单以避免进一步的问题。

你能发现我的配置有什么问题吗?Service.config 代码如下..

<system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="basicHttpEndpointBinding" closeTimeout="01:01:00"
          openTimeout="01:01:00" receiveTimeout="01:10:00" sendTimeout="01:01:00"
          allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
          maxBufferSize="2147483646" maxBufferPoolSize="2147483646" maxReceivedMessageSize="2147483646"
          messageEncoding="Mtom" textEncoding="utf-8" transferMode="StreamedRequest"
          useDefaultWebProxy="true">
          <readerQuotas maxDepth="2147483646" maxStringContentLength="2147483646" maxArrayLength="2147483646"
            maxBytesPerRead="2147483646" maxNameTableCharCount="2147483646" />
          <security mode="None">
            <transport clientCredentialType="None" proxyCredentialType="None"
              realm="" />
            <message clientCredentialType="UserName" algorithmSuite="Default" />
          </security>
        </binding>
      </basicHttpBinding>
    </bindings>
     <services>
        <service name="WITSService.WITSService"  behaviorConfiguration="DragDrop.Service.ServiceBehavior" >
            <endpoint address="" binding="basicHttpBinding" bindingConfiguration="basicHttpEndpointBinding" contract="DragDrop.Service.IService">
                <identity>
                    <dns value="localhost"/>
                </identity>
            </endpoint>
            <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
        </service>
    </services>
    <!--<services>
      <service name="WITSService.WITSService">
        <endpoint address="" binding="basicHttpBinding" contract="WITSService.WITSService">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint address="mex" binding="basicHttpBinding" contract="IMetadataExchange" />
      </service>
    </services>-->

    <behaviors>
      <serviceBehaviors>
        <behavior name="DragDrop.Service.ServiceBehavior">
          <serviceMetadata httpGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="false"/>
          <dataContractSerializer maxItemsInObjectGraph="2147483646"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>

    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
  <system.webServer>
    <security>
      <requestFiltering>
        <requestLimits maxAllowedContentLength="500000000" />
      </requestFiltering>
    </security>
    <modules runAllManagedModulesForAllRequests="true" />
  </system.webServer>
4

1 回答 1

0

将此配置放在您的 web.config 中。

<?xml version="1.0"?>
<configuration>
  <system.web>
    <httpRuntime executionTimeout="4800" maxRequestLength="2097150"/>
    <compilation debug="true"/>
  </system.web>
  <system.serviceModel>
    <bindings>
      <basicHttpBinding/>
      <customBinding>
        <binding name="LargeSilverlight" closeTimeout="00:21:00" openTimeout="00:20:00" receiveTimeout="00:20:00" sendTimeout="00:50:00">
          <textMessageEncoding maxReadPoolSize="2147483647" maxWritePoolSize="2147483647">
            <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
          </textMessageEncoding>
          <httpTransport maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647"/>
        </binding>
      </customBinding>
    </bindings>
    <client/>
    <!--SERVICE-->
    <services>
      <service name="WITSService.WITSService" behaviorConfiguration="SilverlightWCFLargeDataApplication">
        <endpoint address="" binding="customBinding" bindingConfiguration="LargeSilverlight" behaviorConfiguration="SilverlightWCFLargeDataApplication" contract="DragDrop.Service.IService"/>
      </service>
    </services>
    <!--BEHAVIOR-->
    <behaviors>
      <serviceBehaviors>
        <behavior name="SilverlightWCFLargeDataApplication">
          <serviceMetadata httpGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="false"/>
          <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
        </behavior>
      </serviceBehaviors>
      <endpointBehaviors>
        <behavior name="SilverlightWCFLargeDataApplication">
          <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
        </behavior>
      </endpointBehaviors>
    </behaviors>
  </system.serviceModel>
  <system.webServer>
    <security>
      <requestFiltering>
        <requestLimits maxAllowedContentLength="500000000"/>
      </requestFiltering>
    </security>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>
</configuration>
于 2012-12-31T08:16:02.207 回答