RE: Problems with upload Web Service

From: david (david_at_discussions.microsoft.com)
Date: 02/17/05


Date: Thu, 17 Feb 2005 02:33:01 -0800

Fixed.

it's a great article but with an terrible bug on the code example (terrible
because i've spent three hours debugging my own code to discover this
problem); on the spfileswsdl.aspx, the xml for uploadDocument webmethod is:

      <s:element name="UploadDocument">
        <s:complexType>
          <s:sequence>
            <s:element minOccurs="0" maxOccurs="1" name="strFilename"
type="s:string" />
            <s:element minOccurs="0" maxOccurs="1" name="fileContents"
type="s:base64Binary" />
            <s:element minOccurs="0" maxOccurs="1" name="pathFolder"
type="s:string" />
          </s:sequence>
        </s:complexType>
      </s:element>

notice the property name of the first and the third elements; strFilename
and pathFolder.

and the webmethod method header is:

[WebMethod]
public string UploadDocument(string fileName, byte[] fileContents, string
targetFolder)

notice that here, the first parameter is fileName (instead of strFilename)
and targetFolder (instead of pathFolder)

so, as the name of the method params are not equal, the first and the third
params are received as null params, and the second is received Ok. If you
rename the webmethod params as the spfileswsdl.aspx params and refresh the
webmethod, the params are received ok

"Clive Godden" wrote:

> Hi
>
> Ime a real newbie to sharepoint.
> I have created a WorkSpace programatically and that worked fine, the address
> to the docs via the web client is http://cfit/ppl/shared documents where ppl
> is the workspace.
> I have downloaded and compiled the web service from the
> ODC_WritingCustomWebServicesSPPTSample.zip file.
> I use the code below to upload the document
>
> Dim upload As New SharepointFiles.SPFiles
> upload.Credentials = System.Net.CredentialCache.DefaultCredentials
> dim filename As String = "c:\200411911736.xls"
> Dim strDestination As String = http://cfit/ppl/shared documents (have tried
> all sorts of things here)
> Dim fStream As New FileStream(filename, System.IO.FileMode.Open)
> Dim binFile(CInt(fStream.Length)) As Byte
> fStream.Read(binFile, 0, CInt(fStream.Length))
> fStream.Close()
> Dim str As String
> str = upload.UploadDocument(filename, binFile, strDestination)
> MessageBox.Show(str)
>
> All I get is an error box that says "value cannot be
> null.microsoft.sharepoint"
> Can anyone help and point out what i am doing wrong
> I am trying to do this from Windows.Forms with vb.net
>
> Ta
>
> Clive
>
>
>



Relevant Pages

  • RE: error on uploadDocument webmethod of "Writing Custom Web Services.
    ... the xml for uploadDocument webmethod is: ... and targetFolder ... params are received as null params, and the second is received Ok. ... > i'm trying to make a sharepoint web service to upload documents, ...
    (microsoft.public.sharepoint.teamservices.caml)
  • Re: Check for existence of dll and use if found
    ... Type tObj = yourAssembly.GetType; ... Dim tObj as Type = yourAssembly.GetType ... Dim Params() as Object ... I've looked into loading assemblies dynamically, ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: Remoting a UDT array to an ActiveX Exe fails with error 429
    ... actual params. ... Public Type TestData ... Public Sub SetTestDataAs TestData) ... Dim o As New UDTLib.UDTClass ...
    (microsoft.public.vb.general.discussion)
  • Finding a control in a Nested DataGrid
    ... nested datagrids. ... I want the textbox to update the label with the value ... Dim params As String= ... Dim price As System.Web.UI.WebControls.Label ...
    (microsoft.public.dotnet.framework.aspnet.buildingcontrols)
  • Find Control in a nested DataGrid
    ... nested datagrids. ... I want the textbox to update the label with the value ... Dim params As String= ... Dim price As System.Web.UI.WebControls.Label ...
    (microsoft.public.dotnet.framework.aspnet)