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.

Use Dynamic URLs When Referencing Web Services<br />

If you want to call a Web service, you must first add a Web reference to your project.<br />

This generates a proxy class through which you interact <strong>with</strong> the Web service. The proxy<br />

code initially contains a static Uniform Resource Locator (URL) for the Web service; for<br />

example, http://localhost or http://SomeWeb<strong>Server</strong>.<br />

Important: For Web services in your current solution that execute on your computer,<br />

always use http://localhost rather than http://MyComputerName to ensure that the<br />

reference remains valid on all computers.<br />

The static URL that is embedded <strong>with</strong>in the proxy is usually not the URL that you require<br />

in either the production or test environment. Typically, the required URL varies as your<br />

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 allows separate developers (and<br />

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

location.<br />

Additional Resources<br />

• For more information, see “Chapter 6 - Managing Source Control Dependencies in<br />

<strong>Visual</strong> <strong>Studio</strong> <strong>Team</strong> System” in this guide.<br />

Distributed / Remote <strong>Development</strong><br />

• Make sure that you get an appropriately sized disk drive for your proxy.<br />

• Create a scheduled task to pull the latest files on a periodic basis.<br />

• Periodically monitor proxy performance counters and the event log.<br />

• Configure executionTimeout based on file sizes and bandwidth.<br />

• Disable the proxy if it is going to be down for an extended time period.<br />

• Consider workspace cloaking to reduce unnecessary file transfers.

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

Saved successfully!

Ooh no, something went wrong!