title: How do you copy a file into SharePoint using a WebService?
body: <p>I am writting a winforms c# 2.0 application that needs to put an XML file into a document library on SharePoint.  </p>
  
  <p>I want to use a WebService instead of using the object model (no sharepoint.dll to reference here)  </p>
  
  <p>I am currently using the <a href="http://webserver/site/_vti_bin/copy.asmx" rel="noreferrer">http://webserver/site/_vti_bin/copy.asmx</a> webservice.</p>
  
  <p>Here is some code:  </p>
  
  <pre><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);
  }
  </code></pre>
  
  <p>When this code runs, I get a single result in the resultsArray out parameter:  </p>
  
  <pre><code>DestinationURL: "http://webserver/site/Doclib/UploadedDocument.xml"
  ErrorCode: UnKnown
  ErrorMessage: "Object reference not set to an instance of an object."  
  </code></pre>
  
  <p>From my searching, I have found a couple of possible helps.  </p>
  
  <ul>
  <li><p><a href="http://social.technet.microsoft.com/Forums/pt-BR/sharepointdevelopment/thread/5a1ce3c9-ebc7-4ec9-b0fb-b891d076591b" rel="noreferrer">Microsoft TechNet</a> -- "The copy.asmx copyintoitems will only work if the source and destination urls are in the same SPWebApplication (Site Collection)."</p></li>
  <li><p><a href="http://social.microsoft.com/Forums/zh-CN/sharepointdevelopment/thread/273528be-b207-48d9-b697-74777416638e" rel="noreferrer">Microsoft Social</a> -- "Object reference not set to an instance of an object 
  error occurs because of SharePoint not able to identified that particular property."</p></li>
  </ul>
  
  <p>This leads me to believe my source url should be set to something, but what?  This is originating from a client workstation and does not have a source URL.</p>
  
  <p>Any help would be appricated.  </p>
  
  <p>hank you,<br>
  Keith </p>