This project is read-only.

Update: Our blog has moved. For future help and interaction, please contact us at Thank you!

WS UploadService is a custom built web service for SharePoint. It works with the latest SharePoint products (MOSS 2007 and WSS 3.0). The web service uploads documents to SharePoint server.

Project Home Page
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.

Frequently Asked Questions (FAQ)
Q: I get "Could not create type" error message. What could be the reason?

Make sure your .asmx file has correct class name definition. Open your .asmx file and if class name is myFiles, change it to myService.myFiles!

<%@ WebService Language="C#" Class="myService.myFiles" %> (Correct)

<%@ WebService Language="C#" Class="myFiles" %> (Incorrect)

It's better that you use correct format in the first place but you can change the .asmx file after deployment as well. Go to C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\ISAPI folder and open your .asmx file in notepad (or any editor of your choice) and make the changes as mentioned above.

Q: I get "Server did not recognize the value of HTTP Header SOAPAction: ..." error?

This error occurs if you do not use correct web service namespace. Following three lines should be included in your code, just before the class defintion:

WebService(Namespace "")
WebServiceBinding(ConformsTo WsiProfiles.BasicProfile1_1)

This error can occur even if you omit the trailing slash of, will result in an error.

Q: I get "File not found." error?

This happens when SharePoint fails to find the assembly file. Make sure you have added the assembly in the correct bin folder. Also, make sure you have added the assembly in the GAC.

Q: I get "Unauthorized" error?

Make sure the user who is trying to use the web service has "Contributor" rights in the destination site or library. Also, make sure following lines are added to your client application:

oUploader.PreAuthenticate = true;
oUploader.Credentials = CredentialCache.DefaultCredentials;

Q: I get "SQL Server might not be started" error. I have double checked, my SQL Server is running. Why am i getting the error?

There could be several reasons for this. If you modified the web.config file, reverse the changes you made to the config file and then try again. The error has nothing to do with the SQL Server.

Q: I do not see my web service when i click "Web services on the local machine" in Add Web Reference?

Did you make changes in the spsdisco.aspx file? To include your web service in the list of web services on the SharePoint server, you must add reference to your web service in the spsdisco.aspx file (within the discovery element).

Q: Is it necessary to include the code in the code-behind?

No! You can write code in the myFiles.asmx (markup page) and delete the myFiles.asmx.cs file. Here is the myFiles.asmx code listing:

<%@ WebService Language="C#" Class="myService.myFiles" %>

using System;
using System.Data;
using System.Web;
using System.Collections;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.ComponentModel;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
using System.Net;

namespace myService
/// <summary>
/// Summary description for Service1
/// </summary>
[WebService(Namespace "")]
[WebServiceBinding(ConformsTo WsiProfiles.BasicProfile1_1)]
public class myFiles : System.Web.Services.WebService

//public string HelloWorld()
// return "Hello World";
public string UploadDocument(string fileName, byte[] fileContents, string pathFolder)
if (fileContents == null)
return "Null Attachment";
int iStartIndex = pathFolder.LastIndexOf("/");
string sitePath = pathFolder.Remove(iStartIndex);
string folderName = pathFolder.Substring(iStartIndex + 1);

SPSite site = new SPSite(sitePath);
SPWeb web = site.OpenWeb();

SPFolder folder = web.GetFolder(folderName);

string fileURL = fileName;

folder.Files.Add(fileURL, fileContents);

if (folder.Files[fileURL].CheckedOutBy.Name != "")
folder.Files[fileURL].CheckIn("File Checked In");
return "File added successfully!";

catch (System.Exception ex)
return "Error: " + ex.Source + " - " + ex.Message;


Last edited Jan 20, 2013 at 1:47 AM by ssahmed, version 4