2011-06-09 31 views
2

我想發佈帶有自定義綁定配置的Web服務。我正在使用自定義綁定配置來增加65536字節的默認消息大小。我遇到的問題是,當我使用如下所示的web.config設置時,出現錯誤:解決WCF錯誤:當前禁用此服務的元數據發佈

此服務的元數據發佈當前已禁用。

我的主要目標是能夠增加默認消息大小,因此歡迎任何其他配置,但我試圖儘可能簡化以避免出現更多問題。

你能否指出我的配置有什麼問題?

<bindings> 
    <basicHttpBinding>   
     <binding name="NewBinding0" closeTimeout="00:10:00" openTimeout="01:10:00" 
    receiveTimeout="01:10:00" sendTimeout="01:10:00" maxBufferSize="99536" 
    maxBufferPoolSize="5242880" maxReceivedMessageSize="99536"> 
     <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" 
      maxArrayLength="99536" maxBytesPerRead="99536" maxNameTableCharCount="2147483647" /> 
     <security> 
      <transport clientCredentialType="Basic" /> 
     </security> 

    </binding> 
    </basicHttpBinding> 
</bindings> 
<behaviors> 
    <serviceBehaviors> 
    <behavior name="MeterReadingOrderWSBehaviors"> 
     <serviceMetadata httpsGetEnabled="true" />   
    </behavior> 
    </serviceBehaviors> 

</behaviors> 
<services> 
    <service name="MeterReadingOrderWS.IMeterReadingOrderWS" behaviorConfiguration="MeterReadingOrderWSBehaviors"> 
    <host> 
     <baseAddresses> 
     <add baseAddress="http://localhost:3440/MeterReadingOrderWS.svc"/> 
     </baseAddresses> 
    </host> 
    <endpoint address="" contract="MeterReadingOrderWS.IMeterReadingOrderWS" binding="basicHttpBinding" bindingConfiguration="NewBinding0" /> 
    <endpoint address="mex" contract="IMetadataExchange" binding="mexHttpsBinding" /> 
    </service> 
</services> 

回答

1

添加行爲爲您服務,讓

httpGetEnabled=true

這樣的:

<behavior name="MyService.Service1Behavior"> 
    <serviceMetadata httpGetEnabled="true" /> 
</behavior> 
+0

嗨,我補充說,但它並沒有解決它:( – 2011-06-09 09:10:39

0
<serviceMetadata httpsGetEnabled="true" /> 

您已通過https啓用元數據服務,但是您有一個http mexHttpsBinding的endpoin。 你必須爲你的終端地址使用https。


編輯

您使用mexHttpsBinding所以它的正確使用httpsGetEnabled。如果您不希望https使用httpGetEnabled並將綁定類型從mexHttpsBinding更改爲mexHttpBinding。

<endpoint address="mex" contract="IMetadataExchange" binding="mexHttpBinding" /> 
    <!--- ......- --> 
    <serviceBehaviors> 
     <behavior name="MeterReadingOrderWSBehaviors"> 
      <serviceMetadata httpGetEnabled="true" />   
     </behavior> 
    </serviceBehaviors> 

如果你想使用https元數據考慮到按您的MEX終結

<endpoint address="https://localhost:3440/MeterReadingOrderWS.svc/mex" contract="IMetadataExchange" binding="mexHttpsBinding" /> 
+0

我已經改變了httpsGetEnabled到httpGetEnabled,但沒有奏效 – 2011-06-09 09:12:54

+0

您使用mexHttpsBinding,因此使用httpsGetEnabled是正確的。 如果您不希望使用https進行元數據使用httpG etEnabled並將mex的綁定類型從mexHttpsBinding更改爲mexHttpBinding。 – LoSciamano 2011-06-09 09:17:48

+0

我編輯的答案,以更好地解釋 – LoSciamano 2011-06-09 10:13:28

2

請注意,您的問題似乎與元數據行爲有關,在此之前您必須在以下代碼中檢查服務名稱 (即WebApplication1.MyService); 這應該是在相同的順序命名空間。服務

<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/> 
    </service> 
</services> 
<behaviors> 
    <serviceBehaviors> 
    <behavior name="MyServiceBebavior"> 
     <serviceMetadata httpGetEnabled="true" /> 
     <serviceDebug includeExceptionDetailInFaults="false" /> 
    </behavior> 
    </serviceBehaviors> 
</behaviors> 
<!--<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />--> 

+0

這似乎是tibco ems-wcf相關綁定.. – hB0 2014-06-20 06:19:56