【发布时间】:2012-05-31 21:53:04
【问题描述】:
包含 protobuf-net .dll 库的基本 WCF 服务项目。
打开浏览器,进入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>
【问题讨论】:
-
第一个问题:在添加任何 protobuf-net 之前,该 url 是否有效
-
第二个问题:是否有任何地方记录为错误?
-
第三个问题:你尝试过长格式的扩展吗?即对于 v2r480,请尝试
"ProtoBuf.ServiceModel.ProtoBehaviorExtension, protobuf-net, Version=2.0.0.480, Culture=neutral, PublicKeyToken=257b51d87d2e4d67" -
1.是的,它无需行为扩展即可工作。显示服务页面。 2. 在哪里可以查看日志错误?我走得更远只是打开浏览器萤火虫,在看到空白页面后仅此而已。 3. 刚刚试了下,服务页面出现了,帮助页面没有。
-
作为一个效率点:启用 MTOM 会提高效率;这在 basicHttpBinding 上是可能的,但 not (IIRC) webHttpBinding
标签: wcf protobuf-net