在endPointBehavior中的WCF取消了metaData公开?

时间:2013-01-04 16:22:22

标签: c# wcf web-services web-config

这是我的web.config文件:

          

<bindings>
  <basicHttpBinding>
    <binding 
      name="ExtremeBinding" 
      maxBufferSize="12354000" 
      maxReceivedMessageSize="12354000" />
  </basicHttpBinding>
</bindings>

<services>
  <service name="WcfService3.Service1" behaviorConfiguration="myServiceBehaviour">
    <endpoint 
      address="" 
      binding="basicHttpBinding" 
      bindingConfiguration="ExtremeBinding"
      contract="WcfService3.IService1" 
      behaviorConfiguration="epBehavior"/>
  </service>
</services>

<behaviors>
  <endpointBehaviors>
    <behavior name="epBehavior">

    </behavior>
  </endpointBehaviors>
  <serviceBehaviors>
    <behavior name="myServiceBehaviour">
      <!-- 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="false"/>
    </behavior>
  </serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />

         

如果我保持这样,并运行WCF测试客户端,一切正常。

但是,如果我向endPoint Behavior添加任何内容,例如:

    <behavior name="epBehavior">
      <callbackDebug includeExceptionDetailInFaults="true"/>
    </behavior>

WCF测试客户端失败并显示错误:

Failed to add a service. Service metadata may not be accessible. Make sure your service is running and exposing metadata.

似乎我把它放在了什么内容并不重要。例如:

<behavior name="epBehavior">
    <webHttp/>
</behavior>

我很清楚我错过了一些基本的东西,但我无法弄清楚它是什么。 非常感谢你。

1 个答案:

答案 0 :(得分:0)

我不知道发生这种情况的确切原因,但我认为您可以通过添加serviceMetadata行为来解决此问题:

<behaviors>
 <serviceBehaviors>
  <behavior name="NewBehavior">
    <serviceMetadata httpsGetEnabled="true" 
     httpsGetUrl="https://myComputerName/myEndpoint" />
  </behavior>
 </serviceBehaviors>
</behaviors>

这是来自: http://msdn.microsoft.com/en-us/library/ms731317.aspx