Re: error on uploadDocument webmethod of "Writing Custom Web Services.
From: Mike Walsh (englantilainen_at_microsoft.com)
Date: 02/17/05
- Next message: david: "RE: error on uploadDocument webmethod of "Writing Custom Web Services."
- Previous message: david: "error on uploadDocument webmethod of "Writing Custom Web Services."
- In reply to: david: "error on uploadDocument webmethod of "Writing Custom Web Services."
- Next in thread: david: "Re: error on uploadDocument webmethod of "Writing Custom Web Servi"
- Reply: david: "Re: error on uploadDocument webmethod of "Writing Custom Web Servi"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 17 Feb 2005 11:15:37 +0200
This newsgroup is for CAML as used in SharePoint Team Services (2001).
You need the newsgroup for WSS programming at
microsoft.public.sharepoint.windowsservices.development
Mike Walsh, Helsinki, Finland
STS FAQ http://www.collutions.com/Lists/FAQ
WSS FAQ http://wss.collutions.com
please reply to the newsgroup only
"david" <david@discussions.microsoft.com> wrote in message
news:E30195A0-7E8D-486D-9378-F68A22F87AC6@microsoft.com...
> 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: david: "RE: error on uploadDocument webmethod of "Writing Custom Web Services."
- Previous message: david: "error on uploadDocument webmethod of "Writing Custom Web Services."
- In reply to: david: "error on uploadDocument webmethod of "Writing Custom Web Services."
- Next in thread: david: "Re: error on uploadDocument webmethod of "Writing Custom Web Servi"
- Reply: david: "Re: error on uploadDocument webmethod of "Writing Custom Web Servi"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|