I was able to figure out how to run reports, download files, list folders, etc. on a JasperServer using Python with SOAPpy and xml.dom minidom.
Here's an example execute report request, which works:
repositoryURL = 'http://user@pass:myjasperserver:8080/jasperserver/services/repository'
repositoryWSDL = repositoryURL + '?wsdl'
server = SOAPProxy(repositoryURL, repositoryWSDL)
print server._ns(repositoryWSDL).runReport('''
<request operationName="runReport" locale="en">
<argument name="RUN_OUTPUT_FORMAT">PDF</argument>
<resourceDescriptor name="" wsType="" uriString="/reports/baz">
<label>null</label>
<parameter name="foo">bar</parameter>
</resourceDescriptor>
</request>
''')
However, I'm having trouble formatting my requests properly for the "ReportScheduler" section of the server. I've consulted the documentation located here (http://jasperforge.org/espdocs/docsbrowse.php?id=74&type=docs&group_id=112&fid=305), and have tried model my requests after their samples with no luck (see page 27).
Here are two examples that I've tried, which both return the same error:
schedulingURL = 'http://user@pass:myjasperserver:8080/jasperserver/services/ReportScheduler'
schedulingWSDL = schedulingURL + '?wsdl'
server = SOAPProxy(schedulingURL, schedulingWSDL)
# first request
print server._ns(schedulingWSDL).scheduleJob('''
<request operationName="scheduleJob" locale="en">
<job>
<reportUnitURI>/reports/baz</reportUnitURI>
<label>baz</label>
<description>baz</description>
<simpleTrigger>
<startDate>2009-05-15T15:45:00.000Z</startDate>
<occurenceCount>1</occurenceCount>
</simpleTrigger>
<baseOutputFilename>baz</baseOutputFilename>
<outputFormats>
<outputFormats>PDF</outputFormats>
</outputFormats>
<repositoryDestination>
<folderURI>/reports_generated</folderURI>
<sequentialFilenames>true</sequentialFilenames>
<overwriteFiles>false</overwriteFiles>
</repositoryDestination>
<mailNotification>
<toAddresses>[email protected]</toAddresses>
<subject>test</subject>
<messageText>test</messageText>
<resultSendType>SEND_ATTACHMENT</resultSendType>
</mailNotification>
</job>
</request>''')
# second request (trying different format here)
print server._ns(schedulingWSDL).scheduleJob('''
<ns1:scheduleJob soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="http://www.jasperforge.org/jasperserver/ws">
<job xsi:type="ns1:Job">
<reportUnitURI xsi:type="xsd:string">/reports/baz</reportUnitURI>
<username xsi:type="xsd:string" xsi:nil="true"/>
<label xsi:type="xsd:string">baz</label>
<description xsi:type="xsd:string">baz</description>
<simpleTrigger xsi:type="ns1:JobSimpleTrigger">
<timezone xsi:type="xsd:string" xsi:nil="true"/>
<startDate xsi:type="xsd:dateTime">2008-10-09T09:25:00.000Z</startDate>
<endDate xsi:type="xsd:dateTime" xsi:nil="true"/>
<occurrenceCount xsi:type="xsd:int">1</occurrenceCount>
<recurrenceInterval xsi:type="xsd:int" xsi:nil="true"/>
<recurrenceIntervalUnit xsi:type="ns1:IntervalUnit" xsi:nil="true"/>
</simpleTrigger>
<calendarTrigger xsi:type="ns1:JobCalendarTrigger" xsi:nil="true"/>
<parameters soapenc:arrayType="ns1:JobParameter[4]" xsi:type="soapenc:Array" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
</parameters>
<baseOutputFilename xsi:type="xsd:string">test</baseOutputFilename>
<outputFormats soapenc:arrayType="xsd:string[1]" xsi:type="soapenc:Array" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
<outputFormats xsi:type="xsd:string">PDF</outputFormats>
</outputFormats>
<outputLocale xsi:type="xsd:string" xsi:nil="true"/>
<repositoryDestination xsi:type="ns1:JobRepositoryDestination">
<folderURI xsi:type="xsd:string">/reports_generated</folderURI>
<sequentialFilenames xsi:type="xsd:boolean">false</sequentialFilenames>
<overwriteFiles xsi:type="xsd:boolean">false</overwriteFiles>
</repositoryDestination>
<mailNotification xsi:type="ns1:JobMailNotification" xsi:nil="true"/>
</job>
</ns1:scheduleJob>''')
Each of these requests result in errors:
SOAPpy.Types.faultType: <Fault soapenv:Server.userException: org.xml.sax.SAXException:
Bad types (class java.lang.String -> class com.jaspersoft.jasperserver.ws.scheduling.Job):
<SOAPpy.Types.structType detail at 14743952>: {'hostname': 'myhost'}>
Any help/guidance would be appreciated. Thank you.
I've had a lot of bad experiences with minidom. I recommend you use lxml. I haven't had any experience with soap itself, so I can't speak to the rest of the issue.
Without knowing anything at all about Jasper, I can guarantee you that you'll do better to replace your hardcoded SOAP requests with a simple client based on the excellent suds library. It abstracts away the SOAP and leaves you with squeaky-clean API access.
easy_install suds
and the docs should be enough to get you going.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With