Skip to content

Instantly share code, notes, and snippets.

@terrancesnyder
Created February 14, 2013 01:10
Show Gist options
  • Save terrancesnyder/4949866 to your computer and use it in GitHub Desktop.
Save terrancesnyder/4949866 to your computer and use it in GitHub Desktop.
Example WCF config for content type negotation with JSON/XML AND SOAP
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<services>
<service name="Service.HelloWorldService" behaviorConfiguration="wsdl">
<endpoint address="soap" binding="basicHttpBinding" contract="Service.IHelloWorldService" />
<endpoint address="xml" binding="webHttpBinding" behaviorConfiguration="restBehavior" contract="Service.IHelloWorldServicee" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="wsdl" >
<serviceMetadata httpGetEnabled="true" /> <!-- because we want to have a wsdl -->
<serviceDebug includeExceptionDetailInFaults="true" /> <!-- because we want to know what went wrong -->
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="restBehavior">
<!-- content type negotation -->
<webHttp automaticFormatSelectionEnabled="true" helpEnabled="true" faultExceptionEnabled="true"/>
</behavior>
</endpointBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment