WCF protobuf-net没有显示帮助页面

时间:2012-05-31 21:53:04

标签: wcf protobuf-net

基本WCF服务项目,包括protobuf-net .dll库。

打开网页浏览器并转到localhost / wcf / service1.svc,一切正常。

现在转到localhost / wcf / service1.svc / help,在浏览器控制台上显示400 Bad Request(如firebug)。

这是 web.config   

<bindings>
  <basicHttpBinding>
    <binding name="BasicHttpBinding1" messageEncoding="Mtom">
      <security mode="None"></security>
    </binding>
  </basicHttpBinding>
</bindings>

<behaviors>
  <serviceBehaviors>
    <behavior name="Service1Behavior">
      <serviceMetadata httpGetEnabled="true"/>
      <serviceDebug includeExceptionDetailInFaults="true"/>
    </behavior>
  </serviceBehaviors>

  <endpointBehaviors>
    <behavior name="protoEndpointBehavior">
      <protobuf />
    </behavior>
  </endpointBehaviors>
</behaviors>

<extensions>
  <behaviorExtensions>
    <add name="protobuf" type="ProtoBuf.ServiceModel.ProtoBehaviorExtension, protobuf-net"/>
  </behaviorExtensions>
</extensions>

<serviceHostingEnvironment multipleSiteBindingsEnabled="true" aspNetCompatibilityEnabled="true" />

<services>
  <service name="WcfService1.Service1" behaviorConfiguration="Service1Behavior">
    <endpoint address="" contract="WcfService1.IService1" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding1" behaviorConfiguration="protoEndpointBehavior" />
  </service>
</services>

1 个答案:

答案 0 :(得分:1)

只需要这个以查看帮助页面:

<bindings>
  <webHttpBinding>
    <binding name="WebHttpBinding1" >
      <security mode="None"></security>
    </binding>
  </webHttpBinding>
<bindings>

<behaviors>
  <endpointBehaviors>
    <behavior name="protoEndpointBehavior">
      <webHttp helpEnabled="true"/>
      <protobuf />
    </behavior>
  </endpointBehaviors>
</behaviors>

<services>
  <service name="WcfService1.Service1" behaviorConfiguration="Service1Behavior">
    <endpoint address="" contract="WcfService1.IService1" binding="webHttpBinding" bindingConfiguration="WebHttpBinding1" behaviorConfiguration="protoEndpointBehavior" />
  </service>
</services>

同样如Mark所说,basicHttpBinding允许对Mtom进行消息编码,从而提高效率。但是webHttpBinding不允许它。