[英]Upload File in Sharepoint online
I want to generate a file in sharepoint online I use this code but I still have an exception java.net.ConnectException: Connection timed out: connect
Any ideas please?? 我想在共享点在线生成一个文件,但我仍然使用
java.net.ConnectException: Connection timed out: connect
异常java.net.ConnectException: Connection timed out: connect
任何想法?
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://mysite/sites/_vti_bin/Copy.asmx");
return port;
}
public static void createDocument(CopySoap port) throws Exception {
String url = "https://mysite/sites/Documents partages/test.txt";
String sourceUrl = "C:\\TEMP\\test.txt";
File file=new File(sourceUrl);
DestinationUrlCollection urls = new DestinationUrlCollection();
urls.getString().add(url);
byte[] content = readAll(file);
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);
logger.debug("Long holder: " + longHolder.value);
//do something meaningful here
for (CopyResult copyResult : resultHolder.value.getCopyResult()) {
logger.debug("Destination: " + copyResult.getDestinationUrl());
logger.debug("Error Message: " + copyResult.getErrorMessage());
logger.debug("Error Code: " + copyResult.getErrorCode());
if(copyResult.getErrorCode() != CopyErrorCode.SUCCESS)
throw new Exception("Upload failed for: " + copyResult.getDestinationUrl() + " Message: "
+ copyResult.getErrorMessage() + " Code: " + copyResult.getErrorCode() );
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.