views:

226

answers:

1

I am currently working on a SharePoint project that needs to use the Lists SharePoint web service (Lists.asmx). Therefore, we need to add a service reference to it in Visual Studio. However, we all develop and test on different virtual machines (with different VM names, URLs, etc.). The QA, Test and Production environments all have different names and URLs as well.

Adding a service reference adds a bunch of references to the URL that was specified when the reference was created (in the app.config. .wsdl, .disco, etc.). This is obviously a problem for us as code that works on one machine won't work anywhere else (which breaks the build and continuous integration) We also have to delete and add the service reference every time we work with code that was checked-in by someone else.

This must be a fairly common problem for people developing Web services so I wondered if there was a way around it. I know you can't really create a "dynamic" web reference, but perhaps the impacts of the URL change could be minimized somehow?

Thanks!

+7  A: 

By default, the web-service uses the location where it was initially created. The WebService proxy has a URL property which can be set.

This example shows setting it dynamically: http://www.codeproject.com/KB/XML/wsdldynamicurl.aspx

EDIT: You're also not limited to using the Add Web Reference feature in Visual Studio. You can use the wsdl.exe tool that ships with the .NET Framework SDK to generate the code file.

bryanbcook
Thanks. I was using the "service reference" which didn't give me the "dynamic" option. However, I can still create a web reference and set it to dynamic.
Hugo Migneron