我有多种服务合同定义在一个WCF图书馆是主持下Windows服务。这些服务暴露如下Windows服务配置文件:

<services>
  <service behaviorConfiguration="ReportingComponentLibrary.TemplateServiceBehavior"
    name="ReportingComponentLibrary.TemplateService">
    <endpoint address="" binding="wsHttpBinding" contract="ReportingComponentLibrary.ITemplateService" bindingConfiguration="wsHttp" />
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" ></endpoint>
    <host>
      <baseAddresses>
        <add baseAddress="http://localhost:8080/ReportingComponentLibrary/TemplateService/" />
      </baseAddresses>
    </host>
  </service>
  <service behaviorConfiguration="ReportingComponentLibrary.TemplateServiceBehavior"
    name="ReportingComponentLibrary.TemplateReportService">
    <endpoint address="" binding="wsHttpBinding" contract="ReportingComponentLibrary.ITemplateReportService" bindingConfiguration="wsHttp" />
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" ></endpoint>
    <host>
      <baseAddresses>
        <add baseAddress="http://localhost:8080/ReportingComponentLibrary/TemplateReportService/" />
      </baseAddresses>
    </host>
  </service>
</services>

现在,当我增加服务的参考在我的客户应用程序,

是否有可能增加只是一个服务参考对上述两种服务或

我需要单独的参考对每个服务/服务合同。

更新:

这里是我的应用程序详细信息:

我有三个不同的项目:

  1. WCF服务的图书馆
  2. Windows服务为主持上述WCF服务
  3. 客户机-控制台应用程序,用于测试

现在,该应用程序。Config在WCF服务的图书馆如下:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>     

  <system.serviceModel>
    <bindings>
      <wsHttpBinding>
        <binding name="wsHttp" maxReceivedMessageSize="50000000" maxBufferPoolSize="50000000" messageEncoding="Mtom">
          <readerQuotas maxDepth="500" maxStringContentLength="500000000" maxArrayLength="500000000"
          maxBytesPerRead="500000000" maxNameTableCharCount="500000000" />
        </binding>
      </wsHttpBinding>
    </bindings>

    <services>
      <service behaviorConfiguration="ReportingComponentLibrary.TemplateServiceBehavior"
        name="ReportingComponentLibrary.TemplateService">
        <endpoint address="" binding="wsHttpBinding" contract="ReportingComponentLibrary.ITemplateService" bindingConfiguration="wsHttp" >
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" ></endpoint>
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8080/ReportingComponentLibrary/TemplateService/" />
          </baseAddresses>
        </host>
      </service>

      <service behaviorConfiguration="ReportingComponentLibrary.TemplateServiceBehavior"
        name="ReportingComponentLibrary.TemplateReportService">
        <endpoint address="" binding="wsHttpBinding" contract="ReportingComponentLibrary.ITemplateReportService" bindingConfiguration="wsHttp" >
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8080/ReportingComponentLibrary/TemplateReportService/" />
          </baseAddresses>
        </host>
      </service>

    </services>

    <behaviors>
      <serviceBehaviors>
        <behavior name="ReportingComponentLibrary.TemplateServiceBehavior">
          <serviceMetadata httpGetEnabled="True"/>
          <serviceDebug includeExceptionDetailInFaults="True" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>
</configuration>

和应用程序。配置Windows服务上述相同。

现在在我的客户应用程序,我需要消耗的方法,从两TemplateService和TemplateReportService.

所以,我可以总是两个不同的业务参考文为:

http://localhost:8080/ReportingComponentLibrary/TemplateService/

http://localhost:8080/ReportingComponentLibrary/TemplateReportService/

这是所有工作的罚款。

但我想知道如果有任何方式(除了从解决方法的包装你的建议) 我需要添加的只有一个参考和 我可以打电话的方法,从两者的服务。

有帮助吗?

解决方案

因为它的立场,我不认为这是可能的,你会需要2服务的参考,因为他们两个执行单独的合同。假设你已经控制的服务代码,你可以实现一个解决办法在那里创建一个服务包装来实现这两个合同,向两个单独的服务。那会让你有一个服务参考。是否有一个特定的问题,为什么你想让他们两个在一种服务而不是两个?

编辑:此 博客的文章Meineck.Net 表示你可以如何配置自己的服务,以实现什么你们之后,但又是相当多一个工作周围。好运气。

其他提示

一个服务参考=一个服务合同

你的Windows服务有许多内部的服务,每个都有它自己的合同。

有但是没什么能阻止你建立一个单一的合同包含的功能的所有服务,然后创建一个类实现那个合同,但是简单地通过层的其他服务.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top