I have a wcf service with operation contracts as below.
[OperationContract]
bool IsUserAvailable(string userName);
[OperationContract]
[WebInvoke(
Method = "GET",
ResponseFormat = WebMessageFormat.Json,
UriTemplate = "CreateUser?userId={userId}")]
bool CreateUser(string userId);
Note one is defined with webInvoke attribute. I have 2 applications that consume these methods. application 1 calls createUser method through http web request and application 2 ( wcf client ) directly calles IsUserAvailable . If I try to define both basic http binding and webhttpBinding as in the web.config below - I run into issues.(A binding instance has already been associated to listen URI 'http://localhost:xxxx/BookStore.svc'. If two endpoints want to share the same ListenUri, they must also share the same binding object instance. The two conflicting endpoints were either specified in AddServiceEndpoint() calls, in a config file, or a combination of AddServiceEndpoint() and config.)
<endpoint binding="basicHttpBinding" contract="BookStore.IBook" address=""></endpoint>
<endpoint address=""
binding="webHttpBinding"
behaviorConfiguration="webBehavior"
contract="BookStore.IBook" />
<endpoint address="mex"
binding="mexHttpBinding"
behaviorConfiguration="mexBehavior"
contract="IMetadataExchange" />
My question is - How can I have different bindings for the same contract without running into issues. If I don't specify basichttp binding, I get the error ( no endpoint listening)
You need to have differing addresses - webHttpBinding and basicHttpBinding are (as you'd expect) both on the http scheme so you need to differentiate the two endpoints by their address.