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?