WCFHost多个Service config

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <system.serviceModel>
    <services>
      <service name ="CarManagementService.CarManagementImplementation" behaviorConfiguration="ExposeMetaDataBehavior">
        <endpoint
           address="http://localhost:9876/CarManagementService"
           binding="wsHttpBinding"
           bindingConfiguration="AllowBigMessageSize"
           contract="CarManagementInterface.ICarManagement"
          />
      </service>

      <service name ="CustomerService.CustomerImplementation">
        <endpoint
           address="http://localhost:9876/CustomerService"
           binding="wsHttpBinding"
          
           contract="CustomerInterface.ICustomer"
          />
      </service>

      <service name ="RentalService.RentalImplementation">
        <endpoint
           address="http://localhost:9876/RentalService"
           binding="wsHttpBinding"
           contract="RentalInterface.IRental"
          />
      </service>

      <service name ="ExternalInterfaceFacade.ExternalInterfaceFacadeImplementation">
        <endpoint
           address="http://localhost:9876/ExternalInterfaceFacadeService"
           binding="wsHttpBinding"
           contract="ExtenalInterface.IExtenalInterface"
          />
      </service>
    </services>

    <behaviors>
      <serviceBehaviors>
        <behavior name="ExposeMetaDataBehavior">
          <serviceMetadata httpGetUrl="http://localhost:9876/CarManagementService/Mex" httpGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="true"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>

    <bindings>
      <wsHttpBinding>
        <binding name="AllowBigMessageSize" maxReceivedMessageSize="999999" >
        </binding>
      </wsHttpBinding>
    </bindings>
  </system.serviceModel>
</configuration>

--------------------------

static ServiceHost CarManagementServiceHost;
        static ServiceHost CustomerServiceHost;
        static ServiceHost RentalServiceHost;
        static ServiceHost ExtentalServiceHost;
        static void Main(string[] args)
        {
            CarManagementServiceHost = new ServiceHost(typeof(CarManagementService.CarManagementImplementation));
            CarManagementServiceHost.Open();

            CustomerServiceHost = new ServiceHost(typeof(CustomerService.CustomerImplementation));
            CustomerServiceHost.Open();

            RentalServiceHost = new ServiceHost(typeof(RentalService.RentalImplementation));
            RentalServiceHost.Open();

            ExtentalServiceHost = new ServiceHost(typeof(ExternalInterfaceFacade.ExternalInterfaceFacadeImplementation));
            ExtentalServiceHost.Open();

            Console.WriteLine("服务已经启动...");
            Console.ReadKey();
        }

posted @ 2013-10-10 15:24  feidaochuanqing  阅读(286)  评论(0编辑  收藏  举报