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

Ask A Question

Stats

  • Questions 118k
  • Answers 118k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I've used svn on a shared network directory between unix,… May 11, 2026 at 11:37 pm
  • Editorial Team
    Editorial Team added an answer There's no specification per se. The closest thing is the… May 11, 2026 at 11:37 pm
  • Editorial Team
    Editorial Team added an answer This line in the hosts file will redirect to localhost.… May 11, 2026 at 11:37 pm

Related Questions

I am looking to build a new website which will require a sql server
I have made a WinForms application with a custom richtextbox control. I am referring
I'm currently writing myself a little C# back up program. I'm using a standard
I am looking to display an array from 128 to 512 bytes in size

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.