WSUploadService – Web Service for uploading documents into SharePoint
来源:互联网 发布:seo属于什么专业 编辑:程序博客网 时间:2024/05/20 05:05
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,
本文摘自:http://vspug.com/ssa/2006/11/30/wsuploadservice-web-service-for-uploading-documents-into-sharepoint/
- WSUploadService – Web Service for uploading documents into SharePoint
- SharePoint Web Service的身份验证
- SharePoint web service 介紹(1)
- SharePoint Web Service的身份验证
- sharepoint 2010 扩展富文本框上传图片功能extend InputFormTextBox for uploading image
- Tips for uploading arXiv
- SharePoint Web Service系列:编写自定义SharePoint Web Services之一
- SharePoint Web Service系列:编写自定义SharePoint Web Services之一
- Web service for attachement
- web service for java
- SharePoint自带WebService(Authentication Web Service)
- 通过WEB SERVICE读取SHAREPOINT列表数据
- SharePoint web service 介紹(2) - Lists
- Client Call SharePoint Web Service(SOAP)
- SharePoint excel service web part 连接到 filter web part
- [SharePoint 2010– InfoPath]通过REST Web Service在表单中嵌入地图
- jax-rpc for web service
- SharePoint Web Service系列:编写自定义SharePoint Web Services之二
- Gentoo VirtualBox虚拟机虚拟Window XP
- 2010-2-10
- Firefox 快捷键列表
- HTTP Error 503. The service is unavailable.
- IE与Firefox在JavaScript上的7个不同句法
- WSUploadService – Web Service for uploading documents into SharePoint
- 获取Servlet初始化参数
- 挨踢人生路--记我的10年18家工作经历(转载)
- python模块之ConfigParser: 用python解析配置文件
- Go语言 簡介
- 随机保存图片---记录你的状态----java robot test
- Simple语言 簡介
- 从系统Demo中改的一个 托盘图标带窗体的系统服务程序
- Sharepoint & PHP