首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用XML转换更改web.config中的服务端点地址

使用XML转换更改web.config中的服务端点地址
EN

Stack Overflow用户
提问于 2018-11-20 17:58:31
回答 1查看 520关注 0票数 0

我有两个与我的服务相关联的端点地址,我想在我的Web.Release.config中更改这两个端点地址。我以前没有使用过XML转换,所以我不确定如何做到这一点,特别是在需要更改多个端点地址的情况下。

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

代码语言:javascript
复制
</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是我需要更改的。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-11-21 18:52:32

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

代码语言:javascript
复制
<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>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/53398861

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档