Deploy report to JasperServer via SOAP API
I am looking for an example on deploying a report unit to JasperServer using it开发者_JS百科's SOAP Services, preferably with a java client.
I found a way to do that with JasperServer WebServices
(Set of SOAP services for managing server and data on it).
So ... the unit of data used to communicate with the server is com.jaspersoft.jasperserver.api.metadata.xml.domain.impl.ResourceDescriptor
... which represents a resource... implementation of client is the following com.jaspersoft.jasperserver.irplugin.wsclient.WSClient
...
to make it a bit clearer here is the code :
public void publishImage() throws Exception {
ResourceDescriptor rd = new ResourceDescriptor();
rd.setName("coffeepicture");
rd.setLabel("Coffee picture from java");
rd.setResourceType(ResourceDescriptor.TYPE_IMAGE);
rd.setMainReport(true);
rd.setParentFolder("/Samples");
rd.setUriString(rd.getParentFolder() + rd.getName());
rd.setWsType(ResourceDescriptor.TYPE_IMAGE);
rd.setIsNew(true);
rd.setHasData(true);
File image = new File("/home/coffee.jpg");
client.addOrModifyResource(rd, image);
}
The code above shows how to upload an image to the server, to deploy a report you will need to create separate ResourceDescriptors
for .jrxml
file and datasource if any...
Regards!
精彩评论