• Create document using WebServices

  • Do you want to create a native client or integrate with third party applications: webservices are the solution.
Do you want to create a native client or integrate with third party applications: webservices are the solution.
Forum rules: Please, before asking something see the documentation wiki or use the search feature of the forum. And remember we don't have a crystal ball or mental readers, so if you post about an issue tell us which OpenKM are you using and also the browser and operating system version. For more info read How to Report Bugs Effectively.
 #679  by sparhawk
 
Hi,

I\'ll put this message in my poor english and spanish, because I see some answers in spanish.

I have an application using Struts, and I want to create (upload) a document reading using Struts Action on the OpenKM repository.

This code is part from a method in a class that recieve a FormFile strutsFormFile parameter, where FormFile is a class from Struts.

OKMDocumentServiceLocator locatorDocument = new OKMDocumentServiceLocator();
OKMDocument document = null;

Document documento = new Document();
document = locatorDocument.getOKMDocumentPort();

Version version = new Version();
version.setActual(true);
version.setCreated(new GregorianCalendar());
version.setAuthor(\"david\");
version.setName(\"1.0\");
documento.setAuthor(\"david\");
documento.setKeywords(\"keywords\");
documento.setLanguage(\"ES\");
documento.setActualVersion(version);
documento.setMimeType(strutsFormFile.getContentType());
documento.setPath(\"/okm:root/A/Valid/Path\");

try {
document.create(token, documento, strutsFormFile.getFileData());
}
catch ( Exception e ) {
}

When I try to upload a PDF file, strutsFormFile.getContentType() is \"application/pdf\", but I get next Exception

es.git.openkm.core.UnsupportedMimeTypeException: application/octet-stream


I upload pdf files (with MIME/Type application/pdf using the web console without problems, but I cant using WebServices.

Any help?

Hola a todos, tengo un problema con el código que presento arriba. Tengo una aplicación hecha en Struts, que mediante ActionForms y FormFile obtiene un archivo. Quiero subir o crear este archivo en el gestor documental OpenKM. Para ello uso una función como la de arriba que recibe como parámetro el FormFile de Struts. Sin embargo, obtengo una excepción en el content type (el content type que devuelve struts para un archivo pdf es application/pdf)... ¿Qué se me escapa?

Gracias
 #682  by sparhawk
 
I solve the problem... Yo need to pass the name of the file in the path of the Document object, because the webservice use the name of the file in the path to know the mime type.

Regards!

About Us

OpenKM is part of the management software. A management software is a program that facilitates the accomplishment of administrative tasks. OpenKM is a document management system that allows you to manage business content and workflow in a more efficient way. Document managers guarantee data protection by establishing information security for business content.