基本的 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>