【问题标题】:How to change an endpoint address with XML Transformation in web.config?如何在 web.config 中使用 XML 转换更改端点地址?
【发布时间】:2014-11-12 18:19:09
【问题描述】:

我需要在 web.config 中更改此配置的地址:

<client>
  <endpoint address="OLD_ADDRESS"
    binding="basicHttpBinding"
    contract="Service.IService" name="BasicHttpBinding_IService" />
</client>

到这里:

<client>
  <endpoint address="NEW_ADDRESS"
    binding="basicHttpBinding"
    contract="Service.IService" name="BasicHttpBinding_IService" />
</client>

在我的 XML 转换文件中(它正在工作,它改变了另一个 add key value
我有这个:

<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
  <client>
    <endpoint name="BasicHttpBinding_IService"
      address="NEW_ADDRESS"
      xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>
  </client>

但它不起作用。如果我按名称定位,我不明白为什么它不会改变。 任何帮助/提示将不胜感激。谢谢

【问题讨论】:

    标签: c# xml wcf xslt


    【解决方案1】:

    您的转换文件的结构是否与您的 web.config 匹配?具体来说,您是否缺少 systems.serviceModel 元素?

    <configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
       <system.serviceModel>
          <client>
             <endpoint name="BasicHttpBinding_IService" address="NEW_ADDRESS"
               xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>
          </client>
       </system.serviceModel>
    </configuration>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-07-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-11-14
      • 1970-01-01
      相关资源
      最近更新 更多