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);

WCF-Configuration的更多相关文章

  1. 编写WCF服务时右击配置文件无“Edit WCF Configuration”(编辑 WCF 配置)远程的解决办法

    原文:编写WCF服务时右击配置文件无“Edit WCF Configuration”远程的解决办法 今天在看<WCF揭秘>书中看到作者提出可以在一个WCF Host应用程序的App.Con ...

  2. WCF中Service Configuration Editor的使用方法

    1.在App.config文件上右击,选择Edit WCF Configuration.... 或者打开Program Files\Microsoft Visual Studio 8\Common7\ ...

  3. WCF学习系列一【WCF Interview Questions-Part 1 翻译系列】

    http://www.topwcftutorials.net/2012/08/wcf-faqs-part1.html WCF Interview Questions – Part 1 This WCF ...

  4. 使用WCF的Trace与Message Log功能

      原创地址:http://www.cnblogs.com/jfzhu/p/4030008.html 转载请注明出处   前面介绍过如何创建一个WCF Service http://www.cnblo ...

  5. WCF Misconfiguration: Insufficient Audit Failure Handling

    Abstract: The program is configured not to generate an exception when it fails to write to an audit ...

  6. WCF vs ASMX WebService

    This question comes up a lot in conversations I have with developers. “Why would I want to switch to ...

  7. 【转】WCF和ASP.NET Web API在应用上的选择

    文章出处:http://www.cnblogs.com/shanyou/archive/2012/09/26/2704814.html 在最近发布的Visual Studio 2012及.NET 4. ...

  8. ASP.NET Web API——选择Web API还是WCF

    WCF是.NET平台服务开发的一站式框架,那么为什么还要有ASP.NET Web API呢?简单来说,ASP.NET Web API的设计和构建只考虑了一件事情,那就是HTTP,而WCF的设计主要是考 ...

  9. Learning WCF Chapter1 Generating a Service and Client Proxy

    In the previous lab,you created a service and client from scratch without leveraging the tools avail ...

  10. WCF和ASP.NET Web API在应用上的选择

    小分享:我有几张阿里云优惠券,用券购买或者升级阿里云相应产品最多可以优惠五折!领券地址:https://promotion.aliyun.com/ntms/act/ambassador/shareto ...

随机推荐

  1. CSS3实战手册(第3版)(影印版)

    <CSS3实战手册(第3版)(影印版)> 基本信息 原书名:CSS3: The Missing Manual, 3E 作者: David Sawyer McFarland 出版社:东南大学 ...

  2. StdRandom.java

    /************************************************************************* * Compilation: javac StdR ...

  3. springmvc(3)--数据类型转换

    springmvc 配置 中conversionService可以配置类型转换,springmvc 参数绑定 中各种绑定方式和注解就是使用的这些转换器 一.先看下spring提供的内建类型转换器 第一 ...

  4. Linux之用户管理

    1.添加普通用户 [root@server ~]# useradd chenjiafa   //添加一个名为chenjiafa的用户[root@server ~]# passwd chenjiafa  ...

  5. spring项目中如何添加定时器以及在定时器中自动生成sprng注入对象

    最近做了一个java的项目,部门领导给了一套代码让我尽快掌握,说心里话本人真心不喜欢java的这种项目方式,各种配置各种xml文件简直头都大了,下面就将我遇到的其中一个我认为是坑的地方整理出来,希望能 ...

  6. android chrome 不支持 audio/video的autoplay 属性

    在chrome 浏览器中输入:chrome://flags,找到"播放媒体时的手势要求",停用就可以了.

  7. 常用字符串API

    java.lang.string.1.0 1.char charAt(int index)  返回给定位置的代码单元. 2.int codePointAt(int index) 返回从给定位置开始或字 ...

  8. 提高HTML5 Canvas性能的技巧

    详细内容请点击 一:使用缓存技术实现预绘制,减少重复绘制Canvs内容 很多时候我们在Canvas上绘制与更新,总是会保留一些不变的内容,对于这些内容 应该预先绘制缓存,而不是每次刷新. 直接绘制代码 ...

  9. 【CSS3】---盒模型margin、padding及border

    盒模型--边框 盒子模型的边框就是围绕着内容及补白的线,这条线你可以设置它的粗细.样式和颜色(边框三个属性). 如下面代码为 div 来设置边框粗细为 2px.样式为实心的.颜色为红色的边框: div ...

  10. JavaScript--基本包装类型(13)

    // JS为了便于操作基本类型,提供了3个特殊的引用类型:Boolean/Number和String; 一 基本包装类型概述 // 实际上,每当读取一个基本类型值的时候,后台就会创建一个对应的基本包装 ...