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. Linux与Windows文件传输实现

    Linux与Windows文件传输实现 一.概述 在学习Linux服务器的时候,我们有时需要与Windows下的文件进行交互传输,这个时候我们需要如何实现呢?今天是我第一次在博客园上写文章,此时正值学 ...

  2. oracle PL/SQL(procedure language/SQL)程序设计之触发器(trigger)

    创建触发器 触发器类似于过程和函数,都拥有声明.执行和异常处理过程的带名PL/SQL块.与包类似,触发器必须存储在数据库中.前面已经讲过,过程是显式地通过过程调用执行的,同时过程调用可以传递参数.与之 ...

  3. HDU 2845 Beans (DP)

    Beans Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status ...

  4. Hibernate学习小结

    之前从事.net开发的三年经验里,我是用过EF.Microsoft Dynamic crm中集成的ORM以及上一家公司自主开发的ORM. 再接触Hibernate后,上手比较简单,但其提供了大量的接口 ...

  5. 宽度的100%和auto的区别

    前段时间做项目,发现分不清width设为100%和auto的区别,实在是太水了,就查了点资料,做个总结,有不对的地方欢迎大家指出. width:auto 块级元素默认的宽度值.看一下MDN上的解释:T ...

  6. MongoDB - Introduction of the mongo Shell

    Introduction The mongo shell is an interactive JavaScript interface to MongoDB. You can use the mong ...

  7. @@Error使用简单小结

    使用中经常用到@@Error来判断上一个语句是否执行成功,对此小结一下,可能有些不准确,欢迎指出. 1.1  介绍 SQL SERVER 中@@表示系统全局变量 (1)   返回执行的上一个 Tran ...

  8. R语言快速入门

    R语言是针对统计分析和数据科学的功能全面的开源语言,R的官方网址:http://www.r-project.org/  在Windows环境下安装R是很方便的 R语言的两种运行模式:交互模式和批处理模 ...

  9. sql深入理解

    我们做软件开发的,大部分人都离不开跟数据库打交道,特别是erp开发的,跟数据库打交道更是频繁,存储过程动不动就是上千行,如果数据量大,人员流动大,那么我们还能保证下一段时间系统还能流畅的运行吗?我们还 ...

  10. Part 36 to 39 Talking about Delegates in c#

    Part 36 Delegates in c# Part 37 Delegates usage in c# class Progim { public static void Main() { Lis ...