WSUploadService - Web Service for uploading documents into SharePoint
WSUploadService - Web Service for uploading documents into SharePoint
Category: MOSS 2007, WSS 3.0 WS UploadService is a web service written for Microsoft Office SharePoint Server 2007 and Windows SharePoint Services 3.0 and is meant for uploading documents into SharePoint. I have just uploaded the zip file to GotDotNet.com so it will take some time before the zip file appears in the list of downloads. For the time being, you can download the zip file from the following location: http://www.walisystems.com/ws1_dlc.asp (Download Size: 361 KB) The zip file contains the web service and its related files. It also contains an installer to help you install the service easily on your server. Unzip the file to your hard disk. It will create a "WSUploadService" folder. You can unzip the file anywhere on your hard disk. There is no restriction on unzipping it to a particular folder. Run "UploadServiceCopier.exe" to install the service. Installer will ask you to select a SharePoint site where this service should be installed. Select your site from the drop down and keep the folder name as "bin" (second field: textbox) and click "Next". To uninstall, run the "UploadServiceCopier.exe" again. It will give you the following message: "Service is already installed. Do you want to uninstall it?" Select "Yes" and then select "Remove WSUploadService" and click "Finish" to uninstall the service. Uninstall will remove all copied files from your hard disk. Point to remember: 1. Please run "UploadServiceCopier.exe" to install/uninstall the service. Do not run "setup.exe" directly as it will not install the service correctly. ///////////////////////////////////////// Sample Application: ///////////////////////////////////////// Following is a C# sample demonstrating the use of this web service. 1. Create a .NET application. 2. Add a web reference to the web service installed on your server. For example, if you installed the web service on your default port (80), then use following url to access the web service: http://localhost/_vti_bin/Files.asmx?wsdl If you installed the service on another port, for example, port 17316, then the url will be: http://localhost:17316/_vti_bin/Files.asmx?wsdl You can also browse all web services available on the server. Files.asmx will be listed in the web services available on the server. There will be multiple entries, each entry representing the service available for a different web application. Therefore, if you want to upload documents to a site on port 80, then you should select Files.asmx for port 80. 3. Add following code to your application: try { localhost.Files oUploader = new localhost.Files(); oUploader.PreAuthenticate = true; oUploader.Credentials = CredentialCache.DefaultCredentials; string strPath = @"C: est.doc"; string strFile = strPath.Substring(strPath.LastIndexOf("\") + 1); string strDestination = "http://sp:17316/Docs"; FileStream fStream = new FileStream(strPath, System.IO.FileMode.Open); byte[] binFile = new byte[(int)fStream.Length]; fStream.Read(binFile, 0, (int)fStream.Length); fStream.Close(); string str = oUploader.UploadDocument(strFile, binFile, strDestination); MessageBox.Show(str); } catch (Exception ex) { MessageBox.Show(ex.Source + " - " + ex.Message + " - " + ex.InnerException + " - " + ex.StackTrace); } localhost is the name of the web reference that you added in previous step. 4. Run the application to test the service. "strPath" contains the filename that is to be uploaded. This is just a sample to show you how the service works, that's why i have hard coded the filename but in a real life situation you may want to add a text box and a browse button to select files from your hard disk. "strDestination" contains the destination path. This should be the path representing the document library where file is to be uploaded. 5. Finally, before testing the service, make sure the current user has privileges to upload documents in the destination document library. The user should have "Contributor" rights in the document library otherwise, you will get "401: Unauthorized" error. Please feel free to send your comments and feedback and keep visiting the blog for more detail on the web service. Thank you, S.S. Ahmed SharePoint Tags: http://del.icio.us/sharepoint |
Comments
All About SharePoint said:
http://www.gotdotnet.com/Community/UserSamples/Details.aspx?SampleGuid=c032a25e-ddfe-476e-b946-a95c4827a283...
All About SharePoint said:
You can download WS UploadService 1.0...
ssa said:
Thanks for your email. The web service must be installed on the server that hosts SharePoint. Because you are trying to add a document to a library on virtual PC1 therefore, web service must be installed on virtual PC1. You can access this web service from any other machine (client). Be it Win 2003 or XP!
Hope this helps!
Regards,
SSA
Sahridhayan said:
Yes, i have my VPC2 installed with WSS 3.0 since i am able to execute Share point Object model, is that not enough to connect to another sharepoint server using the same web service?
regards,
Sahridhayan
ssa said:
Since you are trying to upload the document to VPC1, therefore, web service must be installed on VPC1.
Regards,
SSA
Sahridhayan said:
Due to some constraint i cannot have web service and SP(production) in single place, cannot i access SP from with in another WS (where WSS3.0) installed?
regards
sahridhayan
ssa said:
Of course, you can access SP from any web service but that web service must be running on the server. This is what web services are for. You can access SP from remote machines using web services.