26.04.2015 Views

Team Development with Visual Studio Team Foundation Server

Team Development with Visual Studio Team Foundation Server

Team Development with Visual Studio Team Foundation Server

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

application moves from development to test to production. You have three options to<br />

address this issue:<br />

• You can programmatically set the Web service URL when you create an instance of<br />

the proxy class.<br />

• A more flexible approach that avoids a hard coded URL in the proxy is to set the<br />

URL Behavior property of the Web service reference to Dynamic. This is the<br />

preferred approach. When you set the property to Dynamic, code is added to the<br />

proxy class to retrieve the Web service URL from a custom configuration section of<br />

the application configuration file, Web.config for a Web application or<br />

SomeApp.exe.config for a Windows application.<br />

• You can also generate the proxy by using the WSDL.exe command line tool and<br />

specifying the /urlkey switch. This works in a similar way to setting the URL<br />

Behavior property in that it adds code to the proxy to retrieve the Web service URL,<br />

but in this case the URL is stored in the section of the<br />

application configuration file.<br />

The dynamic URL approach also lets you provide a user configuration file, which can<br />

override the main application configuration file. This enables separate developers and<br />

members of the test team to temporarily redirect a Web service reference to an alternate<br />

location.<br />

How to Use Dynamic URLs and a User Configuration File<br />

Set the URL Behavior property of your Web service reference to Dynamic to gain<br />

maximum configuration flexibility <strong>with</strong>in both the development and production<br />

environments. By default, <strong>Visual</strong> <strong>Studio</strong> sets the value of this property to Dynamic when<br />

you add a Web reference. To check that this value is still set to Dynamic:<br />

1. In the Solution Explorer, expand the list of Web references.<br />

2. Select each Web reference in the list.<br />

3. For each Web reference, check that the value of the URL Behavior property is set to<br />

Dynamic.<br />

To specify a Web Service URL in a user configuration file<br />

1. When you first add a Web reference, <strong>Visual</strong> <strong>Studio</strong> automatically generates the<br />

App.config file for you. This file contains the Web service reference and the<br />

configuration setting in the App.config file looks like the following:<br />

<br />

<br />

<br />

<br />

<br />

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!