1

Basic WCF service project including protobuf-net .dll library.

Open web browser and go to localhost/wcf/service1.svc, everything ok.

Now go to localhost/wcf/service1.svc/help, shows 400 Bad Request on browser console (like firebug).

Here's the 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>

SamuGG
  • 479
  • 2
  • 8
  • 20
  • first question: did that url work before you added any protobuf-net – Marc Gravell May 31 '12 at 22:00
  • second question: is anything logged as an error anywhere? – Marc Gravell May 31 '12 at 22:05
  • third question: have you tried the long form of the extension? i.e. for v2r480, try `"ProtoBuf.ServiceModel.ProtoBehaviorExtension, protobuf-net, Version=2.0.0.480, Culture=neutral, PublicKeyToken=257b51d87d2e4d67"` – Marc Gravell May 31 '12 at 22:06
  • 1. Yes, it works without behavior extension. Shows the service page. 2. Where can I look for log errors? The further I went was just opening the browser firebug, nothing more than that after seeing the blank page. 3. Just tryed right now, service page shows up, help page doesn't. – SamuGG May 31 '12 at 22:14
  • Just to mention it's the WCF sample template in VS2010 modified in web config and IService1.cs. It has GetData() and GetDataUsingDataContract() exposed methods. CompositeType was tagged with [DataContract, ProtoContract] so the class members [DataMember, ProtoMember(x)]. Method has [OperationContract, ProtoBehavior] – SamuGG May 31 '12 at 22:18
  • can you show me (screenshot) what `blah/help` UI you are seeing? I've repro'd here without protobuf-net, and the `blah/help` shows an empty screen.... – Marc Gravell May 31 '12 at 22:27
  • Got it working! Sorry, my mistake. I didn't realize basicHttpBinding don't allow the helpEnabled attribute tag. Just changed the basicHttpBinding for webHttpBinding and add before I will post the entire solution. Thanks! – SamuGG May 31 '12 at 22:53
  • 1
    as an efficiency point: enabling MTOM will make it more efficient; that is possible on basicHttpBinding but *not* (IIRC) webHttpBinding – Marc Gravell Jun 01 '12 at 05:41

1 Answers1

1

Just needed this to see help page:

<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>

Also as Mark said, basicHttpBinding allows message encoding Mtom, which increases efficiency. But webHttpBinding doesn't allow it.

James Webster
  • 31,873
  • 11
  • 70
  • 114
SamuGG
  • 479
  • 2
  • 8
  • 20