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

  • Home
  • SEARCH
  • 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 7509661
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T22:58:58+00:00 2026-05-29T22:58:58+00:00

New to SharePoint. I’m trying to upload a document to SharePoint using it’s CopyIntoItems

  • 0

New to SharePoint.

I’m trying to upload a document to SharePoint using it’s CopyIntoItems web service method with Java but keep on getting 400 Bad Request. I’ve use the Java’s wsimport to generate the class files from the .wsdl file. Here is my Java code with the generated classes.

public static void createDocument(CopySoap port) {
    String url = SoapPortProvider.spSiteUrl + "/Shared Documents/Temp Folder/test.txt";
    String sourceUrl = "http://null";

    byte[] content = IoUtil.getBytes(new File("C:/CopyFile/READ-ME.txt"));

    FieldInformation descInfo = new FieldInformation ();
    descInfo.setDisplayName("Test Doc");
    descInfo.setType(FieldType.TEXT);
    descInfo.setValue("Test uploaded file");        


    DestinationUrlCollection urls = new DestinationUrlCollection();
    urls.getString().add(url);

    FieldInformationCollection infos = new FieldInformationCollection ();
    infos.getFieldInformation().add(descInfo);  

    CopyResultCollection results = new CopyResultCollection ();
    Holder<CopyResultCollection> resultHolder = new Holder<CopyResultCollection>(results);

    Holder<Long> longHolder = new Holder<Long>(new Long(-1));

    port.copyIntoItems(sourceUrl, urls, infos, content, longHolder, resultHolder);

}

My SOAP Request looks like

<?xml version="1.0" ?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
   <S:Body>
      <CopyIntoItems xmlns="http://schemas.microsoft.com/sharepoint/soap/">    
         <SourceUrl>http://null</SourceUrl>
         <DestinationUrls>
            <string>https://www.mysite.com/sites/TestSite/Shared Documents/Temp Folder/test.txt</string>
         </DestinationUrls>
         <Fields>
            <FieldInformation Value="Test uploaded file" DisplayName="Test Doc" Type="Text"/>
         </Fields>
         <Stream>KioqTWFrZSBzdXJlIHRoZSBjb250ZW50IGlzIHVuZGVyIEM6L0NvcHlGaWxlLy4gICoqKg0KDQpUbyBydW46DQoNCjEuICBFZGl0IHRoZSBkZXBsb3kucHJvcHMgZmlsZS4gIFNwZWNpZnkgdGhlIHNvdXJjZSAoZm9sZGVyIHRoYXQgY29udGFpbiBpdGVtcyB0byBkZXBsb3kpLCBkZXN0aW5hdGlvbiAoZm9sZGVyIHRvIGRlcGxveSB0byksIGFuZCBmaWxlcyAodGhlIGl0ZW1zIHRvIGRlcGxveSkuDQoyLiAgRG91YmxlIGNsaWNrIG9uIGRlcGxveUN1c3RvbWl6YXRpb24uYmF0DQoNCk5vdGUgdGhhdCBhIGxvZyBvZiB0aGUgcHJvZ3Jlc3Mgd2lsbCBiZSBjcmVhdGVkIGluIEM6L0NvcHlGaWxlL2NvcHlGaWxlLmxvZyANCg0KTm90ZSB0aGF0LCBmb3IgcHJlY2F1dGlvbiwgZXhpc3RpbmcgZmlsZSB3aWxsIG5vdCBiZSBvdmVyd3JpdHRlbiwgaW5zdGVhZCB3aWxsIGJlIHNhdmVkIGFzIHlvdXJfY29kZV9maWxlLm9sZA==</Stream>
      </CopyIntoItems>
    </S:Body>
</S:Envelope>

And the response I get is

null: HTTP/1.1 400 Bad Request
Content-length: 0
X-powered-by: ASP.NET
Server: Microsoft-IIS/7.5
Date: Tue, 14 Feb 2012 16:29:51 GMT
Microsoftsharepointteamservices: 14.0.0.5138

which doesn’t tell me much. What could be missing?

  • 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-29T22:59:00+00:00Added an answer on May 29, 2026 at 10:59 pm

    Got it! There is just a bug in my code in initialization. Here is the working code to anyone out there looking to work with SharePoint and Java. I’ve use JAX-WS wsimport tool to generate the class file from the .wsdl file. You can point the tool straight to the url of the WSDL, for example, https://my.site.come/sites/mysite/_vti_bin/copy.asmx?wsdl

    public static CopySoap getPort(String username, String password)  {
    
        Copy service = new Copy();
        CopySoap port = service.getCopySoap();
    
        BindingProvider bp = (BindingProvider) port;
    
        bp.getRequestContext().put(BindingProvider.USERNAME_PROPERTY, username);
        bp.getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, password);
        bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, 
                "https://my.site.com/sites/mysite/_vti_bin/copy.asmx");
    
    
        return port;
    }   
    
    public static void createDocument(CopySoap port) {
        String url = "https://my.site.com/sites/mysite/Shared Documents/Temp Folder/test.txt";
        String sourceUrl = "C:\\CopyFile\\READ-ME.txt";     
    
        DestinationUrlCollection urls = new DestinationUrlCollection();
        urls.getString().add(url);
    
        byte[] content = IoUtil.getBytes(new File(sourceUrl));
    
        FieldInformation titleInfo = new FieldInformation ();
        titleInfo.setDisplayName("Title");
        titleInfo.setType(FieldType.TEXT);
        titleInfo.setValue("Test Doc");
    
        FieldInformationCollection infos = new FieldInformationCollection ();
        infos.getFieldInformation().add(titleInfo);
    
        CopyResultCollection results = new CopyResultCollection ();
    
        Holder<CopyResultCollection> resultHolder = new Holder<CopyResultCollection>(results);      
    
        Holder<Long> longHolder = new Holder<Long>(new Long(-1));       
    
        port.copyIntoItems(sourceUrl, urls, infos, content, longHolder, resultHolder);
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In SharePoint 2010, there is a new method CreateWeb in the Sites web service
I'm trying to generate a new SharePoint list item directly using SQL server. What's
I am new on SharePoint 2010 and trying to make basic web sites. First,
I created a new SharePoint portal for testing purposes using a manually added HOSTS
First off, I'm new to Sharepoint. When I open up a document in read-only
We are building a new SharePoint 2007 web site to replace our intranet website
I am new to SharePoint technologies and trying to figure out its suitability for
I’m new to SharePoint development. We are currently running SharePoint 2007, but we have
I'm trying to learn to call SharePoint Web Services from an external C# client.
I've built a new SharePoint 2010 Web Site. My authantication type is Claims Based

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.