【问题标题】:Changing a service endpoint address in my web.config with XML Transformation使用 XML 转换更改我的 web.config 中的服务端点地址
【发布时间】:2018-11-20 17:58:31
【问题描述】:

我有两个与我的服务关联的端点地址,我想在我的 Web.Release.config 中更改它们。我之前没有使用过 XML 转换,所以我不确定该怎么做,尤其是在需要更改多个端点地址的情况下。

我在 Stackoverflow 上找到了其他示例,但这些示例的 XML 结构与我的不同。

</configuration>

   <system.serviceModel>

      <services>

        <service behaviorConfiguration="MyService.ServiceBehavior" name="MyService.Documents">
           <endpoint name="MyService.Documents.Endpoint"
                address="https://MyApp.net/Documents.svc"
                behaviorConfiguration="MyService.EndpointBehavior"
                binding="webHttpBinding"
                bindingConfiguration="TransportSecurity"
                contract="MyService.IDocuments" />
        </service>

        <service behaviorConfiguration="MyService.ServiceBehavior" name="MyService.Leads">
           <endpoint name="MyService.Leads.Endpoint"
                address="https://MyApp.net/Leads.svc"
                behaviorConfiguration="MyService.EndpointBehavior"
                binding="webHttpBinding"
                bindingConfiguration="TransportSecurity"
                contract="MyService.ILeads" />
        </service>

     </services>

  </system.serviceModel>

</configuration>

https://MyApp.net/Documents.svchttps://MyApp.net/Leads.svc这两个端点地址是我需要改的。

【问题讨论】:

    标签: xml visual-studio xslt transformation


    【解决方案1】:

    我想通了。这是我想出的转换。

    <configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
    
        <system.serviceModel>
    
            <services>
    
                <service name="MyService.Documents">
                    <endpoint name="MyService.Documents.Endpoint" 
                        address="https://MyApp-sandbox.net/Documents.svc"
                        xdt:Locator="Match(name)"
                        xdt:Transform="SetAttributes(address)"/>
                </service>
    
                <service name="MyService.Leads">
                    <endpoint name="MyService.Leads.Endpoint"
                        address="https://MyApp-sandbox.net/Leads.svc"
                        xdt:Locator="Match(name)"
                        xdt:Transform="SetAttributes(address)"/>
                </service>
    
            </services>
    
        </system.serviceModel>
    
    </configuration>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-10-12
      • 1970-01-01
      • 1970-01-01
      • 2013-09-14
      • 1970-01-01
      相关资源
      最近更新 更多