Share |
en de hr da

Easy integration with Java

Enhance your Java application with docuplex DMS functionality.

This example implements a simple minimum-class "SimpleClient" to access the docuplex backend.
The class creates the request XML structure and receives the relevant variable parameters in the doRequest method.
The request is sent via HTTP protocol to the docuplex server and the response is received.
Everything you need for the XML data communication over the HTTP protocol comes with Java.

Your application obtains a simple way to store, manage and archive files and documents.
docuplex offers an extensive set of features that can be used immediately.
You can concentrate on implementing your workflow and user interface of your application.

Java & XML

  1. package docuplexsample;
  2.  
  3. import java.io.InputStream;
  4. import java.net.HttpURLConnection;
  5. import java.net.InetAddress;
  6. import java.net.URL;
  7. import java.text.SimpleDateFormat;
  8. import java.util.Date;
  9. import org.apache.commons.io.IOUtils;
  10.  
  11. public class SimpleClient {
  12.  
  13. private String serverAddress;
  14. private String username;
  15. private String password;
  16.  
  17. public SimpleClient(String serverAddress, String username, String password) {
  18. this.serverAddress = serverAddress;
  19. this.username = username;
  20. this.password = password;
  21. }
  22.  
  23. public InputStream doRequest(String module, String service,
  24. String method, String params) throws Exception {
  25.  
  26. StringBuilder request = new StringBuilder();
  27.  
  28. String clientID = InetAddress.getLocalHost().getHostName();
  29. String requestTimestamp = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
  30.  
  31. request.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
  32. request.append("<serviceRequest>");
  33. request.append("<requestHead>");
  34. request.append("<module>".concat(module).concat("</module>"));
  35. request.append("<service>".concat(service).concat("</service>"));
  36. request.append("<method>".concat(method).concat("</method>"));
  37. request.append("<clientID>".concat(clientID).concat("</clientID>"));
  38. request.append("<requester>".concat(username).concat("</requester>"));
  39. request.append("<password>".concat(password).concat("</password>"));
  40. request.append("<requestTimestamp>".concat(requestTimestamp).concat("</requestTimestamp>"));
  41. request.append("</requestHead>");
  42. request.append("<requestBody>");
  43. request.append("<params>".concat(params).concat("</params>"));
  44. request.append("</requestBody>");
  45. request.append("</serviceRequest>");
  46.  
  47. URL url = new URL(serverAddress.concat("/docuplex/ServiceController?perform"));
  48. HttpURLConnection conn = (HttpURLConnection) url.openConnection();
  49.  
  50. conn.setDoOutput(true);
  51. conn.setRequestMethod("POST");
  52. conn.setRequestProperty("Content-type", "text/xml");
  53. conn.getOutputStream().write(request.toString().getBytes());
  54.  
  55. return conn.getInputStream();
  56. }
  57.  
  58. public static void main(String[] args) throws Exception {
  59.  
  60. SimpleClient simpleClient = new SimpleClient("https://servername",
  61. "username", "202CB962AC59075B964B07152D234B70");
  62.  
  63. InputStream in = simpleClient.doRequest("docuplex", "FileHandling", "browseFolder",
  64. "<file client=\"bau gmbh\" repository=\"Buchhaltung\" name=\"/Umsatzsteuer\"/>");
  65.  
  66. System.out.println(IOUtils.toString(in));
  67. }
  68. }

For production use this exemplary implementation is not suitable, since there is no explicit error handling.
 

See some examples of how easy the integration of docuplex is:

  • Windows-DLL: All functions encapsulated in a library for use with Delphi, C++ e.a.
  • PHP-Integration: This way you embed docuplex into your web application
  • Java: Use docuplex platform-independent on server or client
Share |
en de hr da