Pedro Dusso
Pedro Dusso

Reputation: 2140

How to config Web References in Visual Studio for production environment

I'm developing an application which will upload documents to a sharepoint folder. Because my application will not run on a server environment, but in client machines, I decided to user the Web Services provided by Sharepoint to upload the documents (my sharepoint address + _vti_bin/copy.asmx) and check in the uploaded files (my sharepoint address + /_vti_bin/Lists.asmx).

My problem is with the my sharepoint address part. The Sharepoint I am using for development is of course different from the that the clients use. Since I have to add the Web References for the service at developing time in order to use it in the C# code, how should I approach?

I will have to obtain at least obtain the main parte of the sharepoint address - say https://sharepoint/projects/ProjectX/and declare my WS with it?

If it makes different, I am using WiX to deploy my application in the end, generating a .msi executable. My sharepoint is 2010 and I'm writing my application in VS2010 using .NET 4.0.

Thank you in advance

Upvotes: 2

Views: 904

Answers (2)

lem.mallari
lem.mallari

Reputation: 1275

Luis's answer is pretty much correct. Another approach you can do is create proxy classes using wsdl.exe. This creates a class instance which you can use in your project. Once you have the file you can just update the value of the variable URL so that it matches your sharepoint URL.

You can also update the constructor like below:

public Lists(string SERVER)
{
    this.Url = "http://" + SERVER + "/_vti_bin/Lists.asmx";
}

This makes sure that you can use whatever SharePoint site you want or place it in configuration files too.

Upvotes: 1

Luis
Luis

Reputation: 6001

Thats Correct Pedro.

You should point my sharepoint address to the url of the website, not root site collection, but website you want to access the services.

You have then 2 options, you can change the address on the configuration file that the visual studio proxy generates as part of the build scripts (sorry dont know Wix, but I bet it can be done)

Or you can then set the url at runtime, it will ignore the one in the config file generated by Visual Studio:

WSS.Lists svc = new WSS.Lists();
svc.Url = my sharepoint address + "/_vti_bin/Lists.asmx"

Upvotes: 1

Related Questions