error on uploadDocument webmethod of "Writing Custom Web Services.
From: david (david_at_discussions.microsoft.com)
Date: 02/17/05
- Next message: Mike Walsh: "Re: error on uploadDocument webmethod of "Writing Custom Web Services."
- Previous message: Mike Walsh: "Re: Adding news programatically"
- Next in thread: Mike Walsh: "Re: error on uploadDocument webmethod of "Writing Custom Web Services."
- Reply: Mike Walsh: "Re: error on uploadDocument webmethod of "Writing Custom Web Services."
- Reply: david: "RE: error on uploadDocument webmethod of "Writing Custom Web Services."
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 17 Feb 2005 00:39:03 -0800
Hello!
i'm trying to make a sharepoint web service to upload documents, and i've
seen the excellent "Writing Custom Web Services for SharePoint Products and
Technologies"
(http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odc_sp2003_ta/html/odc_writingcustomwebservicesforsppt.asp)
But i have a really strange problem with the example attached
(ODC_WritingCustomWebServicesSampleSPPT.EXE)
I've downloaded and installed it. I've added it to a winform application and
then , when i developed a code snippet to upload a document and i'e tested
it, i've obtained this error:
"the parameter cannot be null" (or something like this)
The fact is that my client method is:
public static string uploadDocument(string strPath,string strDestination)
{
uploadService.SPFiles svcDocLib = null;
string result=null;
try
{
svcDocLib = new uploadService.SPFiles();
svcDocLib.Credentials = AuthGetAutheticationData();
svcDocLib.Url = SharePointHost + UploadServiceName;
string strFile = strPath.Substring(strPath.LastIndexOf("\\") + 1);
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();
result = svcDocLib.UploadDocument(strFile, binFile, strDestination);
}
catch (Exception e)
{
OnError("upload methods","uploadDocument Error",e.Message.ToString());
result ="NEXTEL ERROR:"+e.Message.ToString();
}
finally
{
if (svcDocLib!=null)
svcDocLib.Dispose();
}
return (result);
}
i've tested that the parameters that receive svcDocLib.UploadDocument are
not null, but, when the webmethod on the server is invoked,the values, for
some reason of the first and the third params are null (strFile is received
as null, binFile CORRECT, strDestination is received as null)
this is the upload document webmethod. As you can see, i've debugging with a
string variable and the value returned says that filename is null,
targetfolder is null, and the size of filecontents is the length of the
uploaded file in bytes, so this param is received ok.
[WebMethod]
public string UploadDocument(string fileName, byte[] fileContents, string
targetFolder)
{
string result ="Init"+'\n';
if (fileName=="")
result+= "filename Empty"+'\n';
if (fileName==null)
result+="filename Null"+'\n';
if (targetFolder == "")
result+="targetFolder empty"+'\n';
if (targetFolder == null)
result+="targetFolder null"+'\n';
if (fileContents==null)
result+="fileContents null"+'\n';
else
result+="fileContents"+fileContents.Length.ToString()+'\n';
result+="params:"+'\n'+"fileName:"+fileName+'\n'+"fileContents.Size="+(fileContents!=null).ToString()+"targetFolder:"+targetFolder+'\n';
if (fileContents == null)
{
result+= "Null Attachment"+'\n';
return result;
}
try
{
SPFolder folder = targetWebSite.GetFolder(targetFolder);
result+="folder!=null -->"+(folder!=null).ToString()+'\n';
SPFile newFile = folder.Files.Add(fileName, fileContents);
result+="newFile!=null -->"+(newFile!=null).ToString()+'\n';
return result+"\n"+newFile.Title + " created " +
newFile.TimeCreated.ToLongDateString();
}
catch (System.Exception ee)
{
result+= ee.Message + ee.Source + "::targetfolder="+targetFolder+'\n';
return result;
}
}
any ideas?
i'm really confused, this is really strange, isn't it?
Thanks
- Next message: Mike Walsh: "Re: error on uploadDocument webmethod of "Writing Custom Web Services."
- Previous message: Mike Walsh: "Re: Adding news programatically"
- Next in thread: Mike Walsh: "Re: error on uploadDocument webmethod of "Writing Custom Web Services."
- Reply: Mike Walsh: "Re: error on uploadDocument webmethod of "Writing Custom Web Services."
- Reply: david: "RE: error on uploadDocument webmethod of "Writing Custom Web Services."
- Messages sorted by: [ date ] [ thread ]