2012-12-31 48 views
0

我想用basicHttpBinding配置發佈Web服務。我正在使用basicHttpBinding配置來增加65536字節的默認消息大小。我遇到的問題是,當我使用的web.config設置,如下圖所示,我得到一個錯誤:WCF錯誤:當前禁用此服務的元數據發佈

Metadata publishing for this service is currently disabled.

我的主要目標是能夠增加默認郵件大小,並能保存二進制文件在數據庫中,因此任何其他配置是受歡迎的,但我試圖保持它儘可能簡單,以避免進一步的問題。

你能否指出我的配置有什麼問題? 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> 

回答

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> 
+0

感謝Sanjeetharan。什麼類型的設置,我需要把web.config..means客戶端的web.config – MindFresher

+0

你不必把任何東西。一旦你添加了引用,它將被自動創建。 – Sajeetharan

+0

無法正常工作。再次發現相同的錯誤 – MindFresher

相關問題