I'm following this answer from a different question, trying to get my WCF service to only handle GET requests. I've added the [WebGet]
to my operation, added an endpoint behavior with the <webHttp />
, changed my default endpoint to use said behavior, and changed the default endpoint's binding to webHttpBinding
.
web.config's system.servicemodel looks like:
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="webBehavior">
<webHttp />
</behavior>
</endpointBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"
multipleSiteBindingsEnabled="true" />
<services>
<service name="TestServiceLibrary.TestService">
<endpoint behaviorConfiguration="webBehavior"
address=""
binding="webHttpBinding"
contract="TestServiceLibrary.ITestService" />
<endpoint
address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange" />
</service>
</services>
</system.serviceModel>
This makes my service callable like: TestService.svc/GetData?value=x
and that works great. Now I want to add a Service Reference to a client project. When I do that, the client project's app.config file does not get the binding and client endpoint configured. If I remove my behavior webBehavior
above, change the default endpoint binding back to wsHttpBinding
, and re-add the client's service reference - the client binding and endpoint are added successfully but I've lost GET support.
I realize I could leave the default endpoint using wsHttpBinding
and add an endpoint with a different address set to binding webHttpBinding
and a behavior with <webHttp />
, but I would really like the client app to be using GET.
EDIT:
I'm also interested in why the config fails to update in this situation. I'm wanting to allow consumption of this service to be low-friction (add the service reference through visual studio and then start making calls), so manually setting up the client config file is not ideal.