Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7735787
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T07:35:16+00:00 2026-06-01T07:35:16+00:00

I need to switch out an IP address in multiple WCF services in web.config.

  • 0

I need to switch out an IP address in multiple WCF services in web.config. With web.config transformation, is there any way, besides specifying each an every address by xpath, to create a search and replace statement. E.g. switch out IP address 1.2.3.4 with 4.3.2.1 for all instances of 1.2.3.4

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T07:35:17+00:00Added an answer on June 1, 2026 at 7:35 am

    Say your Web.config is something like this (a simplified scenario, but // in XPath works everywhere):

    <configuration>
        <endpoint address="1.2.3.4" />
        <endpoint address="1.2.3.4" />
        <endpoint address="1.2.3.4" />
        <endpoint address="1.2.3.4" />
    </configuration>
    

    then you will need something like this:

    <?xml version="1.0"?>    
    <!-- For more information on using web.config transformation visit http://go.microsoft.com/fwlink/?LinkId=125889 -->    
    <configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
    
        <replaceAll>
            <endpontAddresses xdt:Locator="XPath(//endpoint[@address='1.2.3.4'])" xdt:Transform="SetAttributes(address)" address="4.3.2.1" />
        </replaceAll>
    
    </configuration>
    

    NOTE: this XPath will look for every element in the whole Web.config and check whether given element has address attribute with value equal to “1.2.3.4”.
    If you need something more general then try this:

    <?xml version="1.0"?>
        <!-- For more information on using web.config transformation visit http://go.microsoft.com/fwlink/?LinkId=125889 -->    
        <configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
    
            <replaceAll>
                <endpontAddresses xdt:Locator="XPath(//*[@address='1.2.3.4'])" xdt:Transform="SetAttributes(address)" address="4.3.2.1" />
            </replaceAll>
    
        </configuration>
    

    This will look at every XML element (due to the asterisk: *) and check whether it has address attribute with value equal to “1.2.3.4”.
    So this will work for a file like this:

    <configuration>
        <endpoint name="serviceA" address="1.2.3.4" />
        <endpoint name="serviceB" address="1.2.3.4" />
        <endpoint name="serviceC" address="1.2.3.4" />
        <endpoint2 address="1.2.3.4" />
        <endpoint3 address="1.2.3.4" />
        <endpoint4 address="1.2.3.4" />
    
        <innerSection>
        <endpoint address="1.2.3.4" />
        <anotherEndpoint address="1.2.3.4" />
        <sampleXmlElement address="1.2.3.4" />
        </innerSection>
    </configuration>
    

    Now if you want to limit substitutions to a certain section i.e. <system.serviceModel> then you can use an XPath like this:

        <endpontAddresses xdt:Locator="XPath(/configuration/system.serviceModel//*[@address='1.2.3.4'])" xdt:Transform="SetAttributes(address)" address="4.3.2.1" />
    

    This will update addresses only in <system.serviceModel> section

    <configuration>
        <endpoint name="serviceA" address="1.2.3.4" />
        <endpoint name="serviceB" address="1.2.3.4" />
        <endpoint name="serviceC" address="1.2.3.4" />
        <endpoint2 address="1.2.3.4" />
        <endpoint3 address="1.2.3.4" />
        <endpoint4 address="1.2.3.4" />
    
        <innerSection>
        <endpoint address="1.2.3.4" />
        <anotherEndpoint address="1.2.3.4" />
        <sampleXmlElement address="1.2.3.4" />
        </innerSection>
    
        <system.serviceModel>
        <endpoint name="serviceB" address="1.2.3.4" />
        <endpoint name="serviceC" address="1.2.3.4" />
        <endpoint2 address="1.2.3.4" />
        <innerSection>
          <endpoint address="1.2.3.4" />
          <anotherEndpoint address="1.2.3.4" />
          <sampleXmlElement address="1.2.3.4" />
          </innerSection>
        </system.serviceModel>
    
    </configuration>
    

    Give those a try and choose the one that suits your needs most.

    NOTE: This has a limitation that you need to specify what is the name of the attribute that contains the IP (1.2.3.4) but I think its better to be explicit rather than have magic happen here. If you have many attibute names just repeat the

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there an easy way to switch out a movieClip for another dynamically loaded
Basically out of about 25 MySQL tables I have I need to switch 3
For various reasons (code review mostly) I need to switch from current development branch
Currently I am working on selenium IDE, now I need to switch to selenium
We need to identify and then process switch/case statements in code based on some
NOTE: I am aware of the SVN relocate switch, I just need to know
Need to insert selected text on the page into textarea. There must be some
Need to take a SELECT drop down list options and find if any of
I need help figuring out how to change out the view in my application.
I have a page I need to build out where depending on the selection

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.