Tôi đã có thể tìm ra cách chạy báo cáo, tải xuống tệp, liệt kê thư mục, v.v. trên JasperServer bằng Python với SOAPpy và xml.dom minidom.Lập kế hoạch Báo cáo JasperServer qua SOAP bằng cách sử dụng Python
Dưới đây là một ví dụ thực hiện yêu cầu báo cáo, trong đó hoạt động:
repositoryURL = 'http://[email protected]: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>
''')
Tuy nhiên, tôi đang gặp rắc rối định dạng yêu cầu của tôi đúng cho "ReportScheduler" của máy chủ. Tôi đã tham khảo tài liệu ở đây (http://jasperforge.org/espdocs/docsbrowse.php?id=74&type=docs&group_id=112&fid=305) và đã thử mô hình các yêu cầu của tôi sau khi mẫu của họ không có may mắn (xem trang 27).
Dưới đây là hai ví dụ mà tôi đã cố gắng, mà cả hai trả lại lỗi tương tự:
schedulingURL = 'http://[email protected]: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>''')
Mỗi yêu cầu gây ra lỗi:
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'}>
Bất kỳ sự giúp đỡ/hướng dẫn sẽ được đánh giá . Cảm ơn bạn.