How to configure web.config for WCF service to support both POST and GET
-
Tuesday, December 14, 2010 10:00 PM
I have a WCF service application.. it's a simple web service -- 3 services actually. I'd like to be able to call my service with an http GET and a POST. Currently, it works with a GET, but when I initiate a POST, i get a 404. here is my serviceModel block in my web.config:
<system.serviceModel> <serviceHostingEnvironment multipleSiteBindingsEnabled="true" /> <!-- behaviors --> <behaviors> <serviceBehaviors> <behavior name="Default"> <serviceMetadata httpGetEnabled="true"/> <serviceDebug includeExceptionDetailInFaults="false"/> </behavior> </serviceBehaviors> <endpointBehaviors> <behavior name="webBehavior"> <webHttp /> </behavior> </endpointBehaviors> </behaviors> <!-- services --> <services> <service behaviorConfiguration="Default" name="MyProject.Authorization"> <endpoint address="ws" binding="wsHttpBinding" contract="MyProject.IAuthorization" /> <endpoint address="" behaviorConfiguration="webBehavior" binding="webHttpBinding" contract="MyProject.IAuthorization" /> <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> </service> <service behaviorConfiguration="Default" name="MyProject.Internal.Admin"> <endpoint address="ws" binding="wsHttpBinding" contract="MyProject.Internal.IAdmin" /> <endpoint address="" behaviorConfiguration="webBehavior" binding="webHttpBinding" contract="MyProject.Internal.IAdmin" /> <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> </service> <service behaviorConfiguration="Default" name="MyProject.Internal.Status"> <endpoint address="ws" binding="wsHttpBinding" contract="MyProject.Internal.IStatus" /> <endpoint address="" behaviorConfiguration="webBehavior" binding="webHttpBinding" contract="MyProject.Internal.IStatus" /> <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> </service> </services> </system.serviceModel>
What am I missing? Thank you!
All Replies
-
Tuesday, December 14, 2010 10:14 PM
Also, for what it's worth, here is my interface for my authorization service:
namespace MyProject { using System.ServiceModel; using System.ServiceModel.Web; [ServiceContract] public interface IAuthorization { [OperationContract] [WebGet] string Authorize(string applicationName, string url); } }
-
Wednesday, December 15, 2010 12:41 AM
I was able to fix my problem. Both POST and GET are working now. Here's my new serviceModel block:
<system.serviceModel> <behaviors> <endpointBehaviors> <behavior name="RestBehavior"> <webHttp /> </behavior> </endpointBehaviors> <serviceBehaviors> <behavior name="MetadataBehavior"> <serviceMetadata httpGetEnabled="true" /> </behavior> </serviceBehaviors> </behaviors> <services> <service behaviorConfiguration="MetadataBehavior" name="MyProject.Authorization"> <endpoint address="Soap" binding="basicHttpBinding" bindingConfiguration="" name="Soap" contract="MyProject.IAuthorization" /> <endpoint behaviorConfiguration="RestBehavior" binding="webHttpBinding" bindingConfiguration="" name="REST" contract="MyProject.IAuthorization" /> </service> <service behaviorConfiguration="MetadataBehavior" name="MyProject.Internal.Admin"> <endpoint address="Soap" binding="basicHttpBinding" bindingConfiguration="" name="Soap" contract="MyProject.Internal.IAdmin" /> <endpoint behaviorConfiguration="RestBehavior" binding="webHttpBinding" bindingConfiguration="" name="REST" contract="MyProject.Internal.IAdmin" /> </service> <service behaviorConfiguration="MetadataBehavior" name="MyProject.Internal.Status"> <endpoint address="Soap" binding="basicHttpBinding" bindingConfiguration="" name="Soap" contract="MyProject.Internal.IStatus" /> <endpoint behaviorConfiguration="RestBehavior" binding="webHttpBinding" bindingConfiguration="" name="REST" contract="MyProject.Internal.IStatus" /> </service> </services> </system.serviceModel>
- Marked As Answer by BaggaDonuts Wednesday, December 15, 2010 12:42 AM
-
Saturday, October 13, 2012 5:56 PMthank you so much

