Tuesday, May 19, 2009

SOAP and REST-based WCF basic settings in Web.config

This only serves my own notes because I always forget it when I switch one type of Web service to another.
SOAPREST
<system.serviceModel>
   <services>
     <service
            behaviorConfiguration="ServiceBehavior">
       <endpoint
                address=""
                binding="wsHttpBinding"
                contract=...>
       ...
       </endpoint>
       ...
     </service>
   </services>
...
</system.serviceModel>
<system.serviceModel>
   <services>
     <service
            behaviorConfiguration="ServiceBehavior">
       <endpoint
              address=""
              binding="webHttpBinding"
              behaviorConfiguration="RESTBehavior"
              contract=...>
       ...
       </endpoint>
       ...
     </service>
  </services>
  ...
  <behaviors>
    ...
     <endpointBehaviors>
         <behavior name="RESTBehavior">
             <webHttp/>
             ...
       </behavior>
     </endpointBehaviors>
  </behaviors>
  ...
</system.serviceModel>