0

这是我的 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>

我很清楚我错过了一些基本的东西,但我不知道它是什么。非常感谢。

4

1 回答 1

0

I don't know the exact reason why this happens, but I think you can fix this by adding a serviceMetadata behavior:

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

This is from: http://msdn.microsoft.com/en-us/library/ms731317.aspx

于 2013-01-04T17:02:59.183 回答