开发者

Transforming a specific node in a web.config

I want to use the VS2010 web.config transform functionality, but I'm unsure of the XPath I should be using to replace a certain value.

I have the following client service endpoint defined:

<client>
    <endpoint   name="IMyService"
                address="net.tcp://x.x.x.x:xx/MySvc"
                binding="netTcpBinding"
                bindingConfiguration="..."
                contract="..."
                >
        <identity>
            <servicePrincipalName value="host/testMachine.domain.com" />
        </identity>
    </endpoint>
</client>

I want to replace the servicePrincipalName node with the following value.

<servicePrincipalName value="host/productionMachine.domain.com" />

As there could be multiple client endpoints defined, I prefer to use an XPath that identifies the specific endpoint node (in this case, where name="IMyService").

So in pseudo code, I need to do this:

<servicePrincipalName value="host/productionMachine.domain.com" 
                      xdt:Transform="Replace" 
 开发者_如何学Python                     xdt:Locator="Condition([containing endpoint node] @name='IMyService')" 
                      />

Can someone tell me what should be going where those square brackets are, or show me some other funky way of replacing that specific node?


I would match against and replace the endpoint node, as follows:

<client>
    <endpoint name="IMyService"
            address="net.tcp://x.x.x.x:xx/MySvc"
            binding="netTcpBinding"
            bindingConfiguration="..."
            contract="..."
            xdt:Transform="Replace"
            xdt:Locator="Match(name)"
            >
        <identity>
            <servicePrincipalName value="host/productionMachine.domain.com" />
        </identity>
    </endpoint>
</client>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜