Host-Configuration
<?xml version="1.0"?>
<configuration> <configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
</configSections> <log4net>
<root>
<level value="ALL"/>
<appender-ref ref="LogFileAppender"/>
</root>
<logger name="logInService">
<level value="DEBUG"/>
<appender-ref ref="LogFileAppender"/>
</logger>
<appender name="LogFileAppender" type="log4net.Appender.RollingFileAppender,log4net">
<param name="AppendToFile" value="true" />
<param name="RollingStyle" value="Date" />
<param name="DatePattern" value="yyyyMMdd" />
<param name="StaticLogFileName" value="false" />
<param name="File" type="" value="LogInService\\log" /> <layout type="log4net.Layout.PatternLayout">
<param name="Header" value=" =======================Header======================= " />
<param name="Footer" value="xD; =======================Footer======================= " />
<param name="ConversionPattern" value="%d [%t] %-5p %c [%x] - %m%n"/>
</layout>
</appender>
</log4net> <startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup> <system.serviceModel>
<services>
<service name="Bll.UserBll" behaviorConfiguration="serviceBehavior">
<host>
<baseAddresses>
<add baseAddress="http://localhost:2001"/>
</baseAddresses>
</host>
<endpoint name="userBllEndPoint" address="UserBll" binding="basicHttpBinding" contract="Bll.IUserBll"/>
<endpoint name="mex" binding="mexHttpBinding" contract="IMetadataExchange" address="mex"/>
</service> <service name="Bll.ExamBll" behaviorConfiguration="serviceBehavior">
<host>
<baseAddresses>
<add baseAddress="http://localhost:2002"/>
</baseAddresses>
</host>
<endpoint name="examBllEndPoint" address="ExamBll" binding="basicHttpBinding" contract="Bll.IExamBll"/>
<endpoint name="mex" binding="mexHttpBinding" contract="IMetadataExchange" address="mex"/>
</service>
</services> <behaviors>
<serviceBehaviors>
<behavior name="serviceBehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug httpHelpPageEnabled="true" includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>
Client-Configuration
<?xml version="1.0"?>
<configuration> <configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
</configSections> <log4net>
<root>
<level value="ALL"/>
<appender-ref ref="LogFileAppender"/>
</root>
<logger name="logger">
<level value="DEBUG"/>
<appender-ref ref="LogFileAppender"/>
</logger>
<appender name="LogFileAppender" type="log4net.Appender.RollingFileAppender,log4net">
<param name="AppendToFile" value="true" />
<param name="RollingStyle" value="Date" />
<param name="DatePattern" value="yyyyMMdd" />
<param name="StaticLogFileName" value="false" />
<param name="File" type="" value="log\\log" /> <layout type="log4net.Layout.PatternLayout">
<param name="Header" value=" =======================Header======================= " />
<param name="Footer" value="xD; =======================Footer======================= " />
<param name="ConversionPattern" value="%d [%t] %-5p %c [%x] - %m%n"/>
</layout>
</appender>
</log4net> <startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup> <!--WCF--> <system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="userBllEndPoint" closeTimeout="00:01:00" openTimeout="00:01:00"
receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false"
bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
<binding name="examBllEndPoint" closeTimeout="00:01:00" openTimeout="00:01:00"
receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false"
bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:2001/UserBll" binding="basicHttpBinding"
bindingConfiguration="userBllEndPoint" contract="UserBllService.IUserBll"
name="userBllEndPoint" />
<endpoint address="http://localhost:2002/ExamBll" binding="basicHttpBinding"
bindingConfiguration="examBllEndPoint" contract="ExamBllService.IExamBll"
name="examBllEndPoint" />
</client>
</system.serviceModel> </configuration>
Host-Code
static void Main(string[] args)
{
log4net.ILog log = log4net.LogManager.GetLogger(EqualsConst.GetServiceLoggerName); List<ServiceHost> hosts = new List<ServiceHost>() {
new ServiceHost(typeof(UserBll)),
new ServiceHost(typeof(ExamBll))
}; try
{
foreach (ServiceHost host in hosts)
{
host.Open();
}
Console.WriteLine(EqualsConst.OpenService);
Console.ReadLine();
foreach (ServiceHost host in hosts)
{
host.Close();
}
}
catch (Exception ex)
{
log.Error(ex.Message, ex);
}
}
Interface
[ServiceContract(Namespace="XXX")]
public interface IUserBll
{ [OperationContract]
User RetrieveUserByUserName(string userName);