i am trying to upload image files(jpg, png, etc..) to SharePoint 2013 from an java applet via SOAP(http://msdn.microsoft.com/en-us/library/copy.copy.copyintoitems%28v=office.12%29.aspx), but i am alway getting the same exception:
Exception in thread "main" javax.xml.ws.WebServiceException: class com.microsoft.schemas.sharepoint.soap.CopyIntoItemsResponse do not have a property of the name return
code:
public class SharePoint {
public static void main(String[] args) throws IOException {
CopySoap temp = getPort("username", "password");
CreateDocument(temp);
}
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://example.sharepoint.com/sites/dev/_vti_bin/copy.asmx");
return port;
}
public static void CreateDocument(CopySoap port) throws IOException {
String url = "https://example.sharepoint.com/sites/dev/SiteAssets/test.jpg";
String sourceUrl = "http://media-cache-ec0.pinimg.com/736x/1c/c3/4e/1cc34e4e0aaeff76484b3ae963bfc701.jpg";//<-- for example
DestinationUrlCollection urls = new DestinationUrlCollection();
urls.getString().add(url);
URL Iurl = new URL(sourceUrl);
Image image = ImageIO.read(Iurl);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ImageIO.write((RenderedImage) image, "jpg", baos);
byte[] content = baos.toByteArray();
FieldInformation titelInfo = new FieldInformation();
titelInfo.setDisplayName("Titel");
titelInfo.setType(FieldType.TEXT);
titelInfo.setValue("test img");
FieldInformationCollection infos = new FieldInformationCollection();
infos.getFieldInformation().add(titelInfo);
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);
}
}
I have already taken a look at this: How can I upload a file to a Sharepoint Document Library through SOAP web services using Java? , but it throws the same exception.