views:

264

answers:

1

Our web reference does not seem to be defined in web.config of the website that consumes it. I found that there is a configuration file called "Reference.map" in the "Web References" folder that looks editable, but when I edit them nothing happens. I even renamed the WSDL file in the folder to see if it would get a new one. It did not.

Do I have to do a build just to change the URL of a referenced Web Service?

+8  A: 

You can mark a web reference as static or dynamic URL. If you choose dynamic then it will add the URL to the web.config which you can then change in your production environment.

If it is marked as static then it is compiled into the binary and is not changeable without a rebuild.

If it is already dynamic then the code looks for the dynamic URL and then if it can't find it then it uses the default original. Therefore, you can just add an entry into the web config such as:

<applicationSettings>
    <MySystem.Properties.Settings>
        <setting name="MySystem_MyService" serializeAs="String">
            <value>http://mysystem/service.asmx&lt;/value&gt;
        </setting>
    </MySystem.Properties.Settings>
</applicationSettings>
Robin Day
I realized after marking this as the answer that the URL is marked as dynamic, but it is still not in web config. Any other ideas?
JoshBaltzell
Have added some more info, basically you just add the lines in the web.config. The exact syntax of which depends on your web reference.
Robin Day
To add to that, simply removing and re-adding the web reference will probably rebuild your web.config for you. Make sure that it's not read only or anything though.
Robin Day
I did just that and got the syntax. Thanks a lot!
JoshBaltzell