I am writing a winforms C # 2.0 application that needs to put an XML file in a document library in SharePoint.
I want to use WebService instead of using the object model (without a link to sharepoint.dll here)
I am currently using http: //webserver/site/_vti_bin/copy.asmx webservice.
Here is the code:
byte[] xmlByteArray; using (MemoryStream memoryStream = new MemoryStream()) { xmlDocument.Save(memoryStream); xmlBytes = memoryStream.ToArray(); } string[] destinationUrlArray = new string[] {"http://webserver/site/Doclib/UploadedDocument.xml"}; FieldInformation fieldInfo = new FieldInformation(); FieldInformation[] fields = { fieldInfo }; CopyResult[] resultsArray; using (Copy copyService = new Copy()) { copyService.Credentials = CredentialCache.DefaultCredentials; copyService.Url = "http://webserver/site/_vti_bin/copy.asmx"; copyService.Timeout = 600000; uint documentId = copyService.CopyIntoItems("", destinationUrlArray, fields, xmlByteArray, out resultsArray); }
When this code works, I get the only result in the resultArray parameter:
DestinationURL: "http://webserver/site/Doclib/UploadedDocument.xml" ErrorCode: UnKnown ErrorMessage: "Object reference not set to an instance of an object."
From my search I found a couple of possible clues.
Microsoft TechNet - Copy.asmx copyintoitems will only work if the source and destination URLs are in the same SPWebApplication (Site Collection).
Microsoft Social - "The object reference is not installed in the object instance. An error occurs because SharePoint was unable to determine this specific property."
This leads me to believe that my source url should be configured for something, but what? This occurs from the client workstation and does not have a source URL.
Any help would be appreciated.
hank you
Kate
c # web-services file-upload sharepoint
Keith sirmons
source share