Config for WCF with multiple endpoints
Posted
by vdh_ant
on Stack Overflow
See other posts from Stack Overflow
or by vdh_ant
Published on 2010-04-26T00:12:11Z
Indexed on
2010/04/26
0:23 UTC
Read the original article
Hit count: 655
Hi guys
I'm new to WCF and am trying to get some ideas I have off the ground.
Basically I have a web WCF Application project with the following in its web.config:
<system.serviceModel>
<services>
<service name="WcfService1.ServiceContract.IDirectorySearchService" behaviorConfiguration="defaultServiceBehavior">
<endpoint name="restxml" address="xml" binding="webHttpBinding" contract="WcfService1.ServiceContract.IDirectorySearchServiceXml" behaviorConfiguration="xmlRestBehavior"/>
<endpoint name="restjson" address="json" binding="webHttpBinding" contract="WcfService1.ServiceContract.IDirectorySearchServiceJson" behaviorConfiguration="jsonRestBehavior"/>
<endpoint name="soap" address="soap" binding="basicHttpBinding" contract="WcfService1.ServiceContract.IDirectorySearchService"/>
<endpoint name="mex" address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="defaultServiceBehavior">
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="xmlRestBehavior">
<webHttp/>
</behavior>
<behavior name="jsonRestBehavior">
<enableWebScript/>
</behavior>
</endpointBehaviors>
</behaviors>
</system.serviceModel>
My interfaces look like this:
[ServiceContract]
public interface IDirectorySearchServiceXml
{
[OperationContract]
[WebGet(UriTemplate = "Search/")]
SearchResults Search();
}
[ServiceContract]
public interface IDirectorySearchServiceJson
{
[OperationContract]
[WebGet(UriTemplate = "Search/")]
SearchResults Search();
}
[ServiceContract]
public interface IDirectorySearchService
{
[OperationContract]
SearchResults Search(int? sportId, int? instituteId, DateTime? startDate, DateTime? endDate);
}
Now the part I am having a little trouble with is what else I need to get this up and running... Like given this what .svc files do I need and do I have the config right... Also what addresses do I need to use to get this running either through the browser or through the WCF test client. Note I am currently using 3.5.
Cheers Anthony
© Stack Overflow or respective owner