String token = "";
OKMAuthService authService = null;
OKMDocumentService docService = null;
OKMAuth okmAuth = null;
OKMDocument okmDocument = null;
OKMDocumentBean okmDocumentBean = new OKMDocumentBean();
try {
authService = new OKMAuthService(new URL(host + "/OKMAuth?wsdl"), AuthServiceName);
docService = new OKMDocumentService(new URL(host + "/OKMDocument?wsdl"), DocumentServiceName);
okmAuth = authService.getOKMAuthPort();
okmDocument = docService.getOKMDocumentPort();
BindingProvider bpAuth = (BindingProvider) okmAuth;
BindingProvider bpDocument= (BindingProvider) okmDocument;
bpAuth.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, host+"/OKMAuth");
bpDocument.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, host+"/OKMDocument");
token = okmAuth.login(username, password);
okmDocument.checkout(token, doc.getPath());
byte[] bytedoc = okmDocument.getContent(token, doc.getPath(), false);
String fileName = Util.getLocalFilenameWithoutCollisions(doc, directoryPath);
File file = new File(fileName);
file.createNewFile();
FileOutputStream fos = new FileOutputStream(file);
fos.write(bytedoc);
fos.flush();
fos.close();
okmDocumentBean = Util.copy(doc);
okmDocumentBean.setLocalFilename(fileName);
// Logout OpenKM
okmAuth.logout(token);
token = "";
} catch (Exception ex) {