Inforama API Examples
Generating Documents via SOAP Calls
When you have created your projects, templates and data fields and are successfully generating documents through the Inforama Studio, you have really only started to scratch the surface of what can be done. To really bring your documents to life you can hook up to the SOAP service and generate documents automatically from other systems.
In order to use the Soap Service you will need to pass your username and API key as part of each service call. You can find your API key under the account section of the studio
Sample Java Project
In this section we will go through the process of creating a Java project that will make calls to the Inforama Document Generation Service. In this example we will generate the SOAP stubs using version 2.7.0 of the Apache CXF library. You can download the latest version of the Apache CXF library from http://cxf.apache.org/download.html
Create a batch file which contains the following commands...
The jaxws21 instruction will produce code which is JaxWS 2.1 compatible. When executed the Java stub classes will be created is the src directory. We can then use these generated stubs to make webservice calls.
Start by creating a properties file called generate.properties that contains all of the information you will use in the call.
|USERNAME||Your www.inforama.com login name|
|PASSWORD||Your www.inforama.com API key. Can be obtained from the account section of the studio|
|WS_ADDRESS||The URL of the Inforama document generation WSDL...
|PROJECT_NAME||The name of your Inforama project that you wish to generate documents from|
|DOC_NAME||The name of the template that you wish to use|
|DOC_TYPE||The type of the template (for example, PDF)|
|DATASET||The name of the data fields from which the template is bound|
|DATA_FILE||The location on your local machine where the file containing your data is located|
|OUTPUT_FILE||The full path and name of the output file (ZIP format)|
Next create a Java class that will use this properties file to call the Inforama service.
In this sample class the callService method is called from main. From here the loadProperies function loads the generate.properties file created earlier. The createRequest function creates a new InlineDataRequest object which will be passed to the service. The username and API Key are passed as part of the HTTP headers and the service call is made. When the service call returns the contents of the zip are extracted in the extractResponse method.
And that's it, the service has been called and has returned our documents neatly in a zip archive. This mechanism will allow you to automate your documents from the desktop or by copying the code you can integrate with your existing systems.