WCF错误:此服务的元数据发布当前已禁用

时间:2012-12-31 07:52:23

标签: asp.net .net wcf c#-4.0 web-config

我想发布一个带有basicHttpBinding配置的Webservice。我使用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>

1 个答案:

答案 0 :(得分: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>