使用 XML 转换更改我的 web.config 中的服务端点地址
Changing a service endpoint address in my web.config with XML Transformation
我有两个与我的服务关联的端点地址,我想在我的 Web.Release.config 中更改它们。我之前没有使用过 XML 转换,所以我不确定如何执行此操作,尤其是在需要更改多个端点地址的情况下。
我在 Whosebug 上找到了其他示例,但这些示例的 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.svc and https://MyApp.net/Leads.svc是我要改的
我明白了。这是我想出的转变。
<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>
我有两个与我的服务关联的端点地址,我想在我的 Web.Release.config 中更改它们。我之前没有使用过 XML 转换,所以我不确定如何执行此操作,尤其是在需要更改多个端点地址的情况下。
我在 Whosebug 上找到了其他示例,但这些示例的 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.svc and https://MyApp.net/Leads.svc是我要改的
我明白了。这是我想出的转变。
<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>