Re: error on uploadDocument webmethod of "Writing Custom Web Services.

From: Mike Walsh (englantilainen_at_microsoft.com)
Date: 02/17/05


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
>



Relevant Pages

  • Re: Including a web page results in [FrontPage Include Component]
    ... Sharepoint 2 = Windows SharePoint services has its own newsgroup at ... This newsgroup is for STS 1.0. ... STS FAQ at www.collutions.com/Lists/FAQ ... > work - no matter where I put the html file to include. ...
    (microsoft.public.sharepoint.teamservices)
  • Re: Import a CSV
    ... If you are in fact using Windows SharePoint Services (newsgroup: ... STS FAQ at hhtp://www.colutions.com/Lists/FAQ ... > I ask because I am trying to import a job register and make the job number ...
    (microsoft.public.sharepoint.teamservices)
  • Re: Calculated values in list items
    ... This is the newsgroup for the CAML language as used in SharePoint Team ... STS FAQ http://www.collutions.com/Lists/FAQ ... The request date is always the date the ...
    (microsoft.public.sharepoint.teamservices.caml)
  • Re: Newbee Web Part Question
    ... This newsgroup is the subgroup for the CAML language of the SharePoint Team ... STS FAQ at www.collutions.com/Lists/FAQ ...
    (microsoft.public.sharepoint.teamservices.caml)
  • Re: sharepoint user name change
    ... When you change the user name in SharePoint you still get the ... Microsoft CSS Online Newsgroup Support ... When opening a new thread via the web interface, we recommend you check the ... you may want to contact Microsoft CSS directly. ...
    (microsoft.public.windows.server.sbs)