Click here to Skip to main content
15,896,063 members
Articles / Web Development / ASP.NET

How to Build Flexible and Reusable WCF Services

Rate me:
Please Sign up or sign in to vote.
4.85/5 (13 votes)
6 May 2013GPL313 min read 77.2K   1.9K   126  
Design Patterns and best practices for building flexible and reusable WCF services.
<?xml version="1.0"?>
<configuration>
	<appSettings/>
	<connectionStrings>
		<add name="AdvWorksEntities" connectionString="metadata=res://*/EntityModel.csdl|res://*/EntityModel.ssdl|res://*/EntityModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=(local);Initial Catalog=AdventureWorks;Integrated Security=True;MultipleActiveResultSets=True&quot;" providerName="System.Data.EntityClient"/>
	</connectionStrings>
	<system.web>
		<!-- 
            Set compilation debug="true" to insert debugging 
            symbols into the compiled page. Because this 
            affects performance, set this value to true only 
            during development.
        -->
		<compilation debug="true" targetFramework="4.0">
		</compilation>
		<!--
            The <authentication> section enables configuration 
            of the security authentication mode used by 
            ASP.NET to identify an incoming user. 
        -->
		<authentication mode="Windows"/>
		<!--
            The <customErrors> section enables configuration 
            of what to do if/when an unhandled error occurs 
            during the execution of a request. Specifically, 
            it enables developers to configure html error pages 
            to be displayed in place of a error stack trace.

        <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
            <error statusCode="403" redirect="NoAccess.htm" />
            <error statusCode="404" redirect="FileNotFound.htm" />
        </customErrors>
        -->
		<sessionState mode="InProc" cookieless="false" regenerateExpiredSessionId="true" timeout="20"/>
		<pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID"/></system.web>
	<!-- 
        The system.webServer section is required for running ASP.NET AJAX under Internet
        Information Services 7.0.  It is not necessary for previous version of IIS.
    -->
	<system.serviceModel>
		<serviceHostingEnvironment/>
		<behaviors>
			<serviceBehaviors>
				<behavior name="AdventureWorksServiceBehavior">
					<serviceMetadata httpGetEnabled="true"/>
					<serviceDebug includeExceptionDetailInFaults="false"/>
				</behavior>
			</serviceBehaviors>
			<endpointBehaviors>
				<behavior name="BasicInstanceBehavior">
					<HttpSessionInstanceBehavior/>
				</behavior>
			</endpointBehaviors>
		</behaviors>
		<bindings>
			<basicHttpBinding>
				<binding name="BasicBinding" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647"/>
			</basicHttpBinding>
		</bindings>
		<services>
			<service behaviorConfiguration="AdventureWorksServiceBehavior" name="AdventureWorks.Services.StateProvinceService">
				<endpoint address="" binding="basicHttpBinding" contract="AdventureWorks.Services.IStateProvinceService">
					<identity>
						<dns value="localhost"/>
					</identity>
				</endpoint>
				<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
			</service>
			<service behaviorConfiguration="AdventureWorksServiceBehavior" name="AdventureWorks.Services.EmployeeService">
				<endpoint address="" binding="basicHttpBinding" bindingConfiguration="BasicBinding" contract="AdventureWorks.Services.IEmployeeService" behaviorConfiguration="BasicInstanceBehavior">
					<identity>
						<dns value="localhost"/>
					</identity>
				</endpoint>
			</service>
		</services>
		<extensions>
			<behaviorExtensions>
				<add name="HttpSessionInstanceBehavior" type="Xomega.Framework.Services.HttpSessionInstanceBehavior, Xomega.Framework, Version=1.2.0.0, Culture=neutral, PublicKeyToken=null"/>
			</behaviorExtensions>
		</extensions>
	</system.serviceModel>
</configuration>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The GNU General Public License (GPLv3)


Written By
Architect Xomega.Net
United States United States
Xomega Team is striving to increase productivity and development quality by utilizing Model Driven Development coupled with Code Generation and the best design practices for application development.
We provide MDD tools, code generators and frameworks for Visual Studio and .Net development.
Visit us at http://www.xomega.net
This is a Organisation

1 members

Comments and Discussions