I'm new to web services and i've been trying to create a custom one using this tutorial:
http://msdn.microsoft.com/en-us/library/ms464040.aspx
I've named my service as Files and created a new method on the webservice called UploadDocument:
[WebMethod]
public string UploadDocument(string fileName, byte[] fileContents, string pathFolder)
{
if (fileContents == null)
{
return "Null Attachment";
}
try
{
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].CheckedOutByUser.Name != "")
{
folder.Files[fileURL].CheckIn("File Checked In");
}
return "File added successfully!";
}
catch (System.Exception ex)
{
return "Error: " + ex.Source + " - " + ex.Message;
}
}
I've done exactly as it's listed there, all the same name, methods etc.. and when i get to the point where you're asked to create the application that's going to consume the web service, the tutorial gives the following lines:
ServiceFolder.Files myUploadService = new ServiceFolder.Files();
myUploadService .UseDefaultCredentials = true;
MessageBox.Show(myUploadService.HelloWorld());
but on my application, i can't call the web service as it's telling me to do, when i type
ServiceFolder.
it won't have the option to call the classes i've created. it only gives me some options that are not the ones listed on the tutorial:
ServiceFolder.FilesSoap (Interface)
ServiceFolder.FilesSoapChannel (Interface)
ServiceFolder.FilesSoapClient (Class)
ServiceFolder.UploadDocumentCompletedEventArgs (Class)
ServiceFolder.UploadDocumentRequest (Class)
ServiceFolder.UploadDocumentRequestBody (Class)
ServiceFolder.UploadDocumentResponse (Class)
ServiceFolder.UploadDocumentResponseBody (Class)
Am i missing something? doing something wrong? i've tried to recreate the service a couple times and always get the same thing.
Thanks in advance.