这个配置转换有什么问题?

时间:2013-02-14 22:37:14

标签: visual-studio-2010 .net-4.0

我有web.base.config的以下部分:

  <system.serviceModel>
    <client>
      <!--   Reporting Services -->
      <endpoint name="ReportExecutionEndpoint" address="http://~MACHINENAMEREPLACEMENTTOKEN~/ReportServer/ReportExecution2005.asmx" binding="basicHttpBinding" behaviorConfiguration="AuthenticatedBehavior" bindingConfiguration="ReportingServicesConfiguration" contract="ReportingWebService.ReportExecutionServiceSoap" />
      <!--   Custom Services    -->
      <endpoint name="Blah1Endpoint" address="net.tcp://~MACHINENAMEREPLACEMENTTOKEN~/DomainServices/blah1.svc" binding="netTcpBinding" behaviorConfiguration="AuthenticatedBehavior" bindingConfiguration="LargerMessagesConfiguration" contract="Fully.Qualified.IBlah1" />
      <endpoint name="Blah2Endpoint" address="net.tcp://~MACHINENAMEREPLACEMENTTOKEN~/DomainServices/blah2.svc" binding="netTcpBinding" behaviorConfiguration="AuthenticatedBehavior" bindingConfiguration="LargerMessagesConfiguration" contract="Fully.Qualified.IBlah2" />
      <endpoint name="Blah3Endpoint" address="net.tcp://~MACHINENAMEREPLACEMENTTOKEN~/DomainServices/blah3.svc" binding="netTcpBinding" behaviorConfiguration="AuthenticatedBehavior" bindingConfiguration="LargerMessagesConfiguration" contract="Fully.Qualified.IBlah3" />
    </client>
  </system.serviceModel>

我想为所有 CustomServices 添加<identity><dns /></identity>,而不是 ReportingServices 。为此,我有以下转换段:

  <system.serviceModel>
    <client>
      <endpoint xdt:Locator="Condition(contains(@address, 'net.tcp'))">
        <identity xdt:Transform="Insert">
          <dns value="~MACHINENAMEREPLACEMENTTOKEN~" />
        </identity>
      </endpoint>
    </client>
  </system.serviceModel>

问题是,这只适用于第一个 CustomService ,但不是所有其他的(尽管它正确地跳过 ReportingServices ) 。如何更改此转换,以便它能够访问我的所有 CustomServices 端点?

1 个答案:

答案 0 :(得分:1)

设计插入变换的方式仅供一次性使用。因此,它只会插入第一场比赛。

在这种情况下,您的解决方法是为每个net.tcp端点创建一个Insert转换。

如果你真的需要完成这项工作,你可以创建自己的自定义变换,可以插入多个匹配项。我在博客上写了关于如何做到这一点 http://sedodream.com/2010/09/09/ExtendingXMLWebconfigConfigTransformation.aspx