0

我有一个 WCF 服务库项目,其中有 2 个具有 [ServiceContract] 属性的类。

我有一个控制台应用程序将托管 2 个服务。

代码:

Uri baseAddressRetrieve = new Uri("http://localhost:8000/api/Retrieve/");
Uri baseAddressStorage = new Uri("http://localhost:8005/api/Storage/");

ServiceHost hostRetrieve = new ServiceHost(typeof(Retrieve), baseAddressRetrieve);
ServiceHost hostStorage = new ServiceHost(typeof(Storage), baseAddressStorage);

hostRetrieve.AddServiceEndpoint(typeof(IRetrieve), new WSHttpBinding(SecurityMode.None), "Retrieve");
hostStorage.AddServiceEndpoint(typeof(IStorage), new WSHttpBinding(SecurityMode.None), "Storage");

hostRetrieve.Open();
hostStorage.Open();

现在,当我通过 URI 访问这两个服务地址时,它们都被标记为“存储服务”,并且在生成的代码中都有这行代码:

StorageClient client = new StorageClient();

Retrieve 服务肯定应该是 RetrieveClient 吗?

app.config

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <system.serviceModel>
    <services>
      <service name="NS.Retrieve">
        <endpoint address="" binding="basicHttpBinding" contract="NS.IRetrieve">
          <identity>
            <dns value="localhost"/>
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8733/Design_Time_Addresses/NS/Retrieve/"/>
          </baseAddresses>
        </host>
      </service>
      <service name="NS.Storage">
        <endpoint address="" binding="basicHttpBinding" contract="NS.IStorage">
          <identity>
            <dns value="localhost"/>
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8733/Design_Time_Addresses/NS/Storage/"/>
          </baseAddresses>
        </host>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <serviceMetadata httpGetEnabled="True" httpsGetEnabled="True"/>
          <serviceDebug includeExceptionDetailInFaults="False" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>
</configuration>
4

0 回答 0