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. [Android 开源项目学习]Android的UITableView(1)

         最近由于项目加急,手里有好多看了差不多的开源项目,其中好多是大家经常用到的.图片的缓存BitmapFun(Android的文档中),AfinalMap,下拉刷新PullToRefresh等等 ...

  2. Oracle 基础 数据库备份与恢复

    一.为什么需要数据备份 造成数据丢失的主要原因: 1.介质故障. 2.用户的错误操作. 3.服务器的彻底崩溃. 4.计算机病毒. 5.不可预料的因素. Oracle中故障类型分为以下4种. 1.语句故 ...

  3. DNS的递归查询和迭代查询

    百度运维部二面,直接懵逼的节奏 (1)递归查询 递归查询是一种DNS 服务器的查询模式,在该模式下DNS 服务器接收到客户机请求, 必须使用一个准确的查询结果回复客户机. 如果DNS 服务器本地没有存 ...

  4. 【JS Note】字符串截取

    Js中字符截取常用的三个函数:slice().substring().substr(). slice(): slice(start,[end]) 第一个参数代表开始位置,第二个参数代表结束位置的下一个 ...

  5. MVC常用 ActionResult

    1.EmptyResult 2.ContentResult 3.FileResult 4.JavaScriptResult 5.JsonResult 6.HttpStatusCodeResult 7. ...

  6. 关于windows的svchost进程的问题(年代有点久远)

    这是N年前写的一篇关于svchost的blog,虽然写的不好却是我第一次写的技术类blog, 发上来做开博第一篇吧. ***************************************** ...

  7. 如何安装 JAVA 7 (JDK 7u75) 在 CentOS/RHEL 7/6/5 Fedora

    先下载JDK For 64 Bit:- # cd /opt/ # wget --no-cookies --no-check-certificate --header "Cookie: gpw ...

  8. 网站seo新手快速提升自己的技巧

    第一.找自身的问题 大多数从业者都有下面两个严重的问题: 1.过于放大SEO的重要性每个人,都有自大的习惯,地位越NB往往越把自己认知的一切当做真理,其实有可能那只是井口那巴掌大的一片天.在网络营销中 ...

  9. Exchange之准备AD及域

    1.         若有旧版本的Exchange 2003,则需要执行以下命令: setup.com /PrepareLegacyExchangePermissions 2.         准备架 ...

  10. UI1_UINavigationController

    // // FourthViewController.h // UI1_UINavigationController // // Created by zhangxueming on 15/7/6. ...