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. 【Trie】模板(动态指针,静态数组)

    摘自hackbuteer1 Trie树,又称单词查找树或键树,是一种树形结构,是一种哈希树的变种.典型应用是用于统计和排序大量的字符串(但不仅限于字符串),所以经常被搜索引擎系统用于文本词频统计.它的 ...

  2. hdu-5686 Problem B(斐波那契数列)

    题目链接: Problem B Time Limit: 2000/1000 MS (Java/Others)     Memory Limit: 65536/65536 K (Java/Others) ...

  3. 使用Xcode5开发时的icon取消高光效果

    .在General中App Icons 使用Source--> AppIcon .在Images.xcassets 中依次添加对应尺寸的icon. .选中AppIcon ,在右侧第三个按钮下,勾 ...

  4. C# 文件相关操作

    百度搜的,下面这个写的挺全的.   FROM Pegasus923 http://www.cnblogs.com/pegasus923/archive/2011/01/26/1944838.html ...

  5. js获取iframe的parent对象

    使用谷歌浏览器调试代码时无意间发现了一个奇特的问题:从iframe页面调用父级页面的方法,window.parent.text(),出现 Blocked a frame with origin &qu ...

  6. 默认样式重置 (css reset)

    body,p,h1,h2,h3,h4,h5,h6,dl,dd,t{margin:0; font-size:12px;/* font-family:XX; */} ol,ul{list-style:no ...

  7. C/S打包(图文)

    最近几天接触到了关于C/S打包这块. 由于自己当时遇到了很多疑点,所以特意总结一下: 1.创建Project: 2.当创建Ok后会出现如下页面,左侧3个文件夹,第一个是放置程序文件(只需要放入.exe ...

  8. js打印Iframe中的内容,并且不需要预览。

    js打印Iframe中的内容,并且不需要预览 js代码如下: <script type="text/javascript" language="Javascript ...

  9. asp连接SQL数据库的代码

    connstr="driver={SQL Server};server=(local);uid=sa;pwd=sa;database=Your database" 语法介绍: 1. ...

  10. IOS 模仿TableView封装

    一.先贴一下未封装的代号,好跟后面的对比 @interface MTHomeDropdown : UIView + (instancetype)dropdown; @property (nonatom ...