Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 191133
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T16:18:55+00:00 2026-05-11T16:18:55+00:00

I am writting a winforms c# 2.0 application that needs to put an XML

  • 0

I am writting a winforms c# 2.0 application that needs to put an XML file into a document library on SharePoint.

I want to use a WebService instead of using the object model (no sharepoint.dll to reference here)

I am currently using the http://webserver/site/_vti_bin/copy.asmx webservice.

Here is some 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 runs, I get a single result in the resultsArray out parameter:

DestinationURL: "http://webserver/site/Doclib/UploadedDocument.xml"
ErrorCode: UnKnown
ErrorMessage: "Object reference not set to an instance of an object."  

From my searching, I have found a couple of possible helps.

  • Microsoft TechNet — “The copy.asmx copyintoitems will only work if the source and destination urls are in the same SPWebApplication (Site Collection).”

  • Microsoft Social — “Object reference not set to an instance of an object
    error occurs because of SharePoint not able to identified that particular property.”

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.

Any help would be appricated.

hank you,
Keith

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T16:18:55+00:00Added an answer on May 11, 2026 at 4:18 pm

    Here is what is currently working:

    WebRequest request = WebRequest.Create(“http://webserver/site/Doclib/UploadedDocument.xml”);
    request.Credentials = CredentialCache.DefaultCredentials;
    request.Method = "PUT";
    byte[] buffer = new byte[1024];
    using (Stream stream = request.GetRequestStream())
    {
        using (MemoryStream memoryStream = new MemoryStream())
        {
            dataFile.MMRXmlData.Save(memoryStream);
            memoryStream.Seek(0, SeekOrigin.Begin);
            for (int i = memoryStream.Read(buffer, 0, buffer.Length); i > 0;
                i = memoryStream.Read(buffer, 0, buffer.Length))
            {
                stream.Write(buffer, 0, i);
            }
        }
    }
    
    WebResponse response = request.GetResponse();
    response.Close();
    

    So… Does anyone have an opinion as to if this “PUT” method is better in the SharePoint environment than using a built-in webservice?

    Right now I would have to say the “PUT” method is better since it works and I could not get the WebService to work.

    Keith

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing a .NET WinForms application that needs to display a list of
I'm writing an application that can be started either as a standard WinForms app
I'm writing an winforms app that needs to set internet explorer's proxy settings and
I am writing a C# application that needs to communicate with another application written
On a WinForms application that I am writing in C#, I have a DataGridViewTextBoxColumn
We are writting silverlight3 application, which use Tcp connction. Our project use client server
I'm writing a Winforms application and I've been writing these awful HTML reports where
I'm writing a WinForms application and one of the tabs in my TabControl has
I'm looking for a free winforms component for an application I'm writing. I basicly
I'm writting a financial C# application which receive messages from the network, translate them

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.