cialowicz Posted May 15, 2009 Share Posted May 15, 2009 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 (jasperforge.org/espdocs/docsbrowse.php), 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>my@email.com</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. Link to comment Share on other sites More sharing options...
cialowicz Posted May 18, 2009 Author Share Posted May 18, 2009 Any ideas? Thanks... Link to comment Share on other sites More sharing options...
jmario Posted May 22, 2009 Share Posted May 22, 2009 hisame problem here....any solution yet? Link to comment Share on other sites More sharing options...
cialowicz Posted May 22, 2009 Author Share Posted May 22, 2009 I've tried fiddling with the XML, but still no luck. Misery, I tell you... =/ Post Edited by cialowicz at 05/22/2009 13:44 Link to comment Share on other sites More sharing options...
lucianc Posted May 27, 2009 Share Posted May 27, 2009 With ZSI you can generate client stubs and types via wsdl2py. Then you would programatically call web service operations.I'm attaching code that I used to test this approach, consisting of wsdl2py generated code plus some test code that I've written (my first Python application, so ignore the style).Regards,Lucian Link to comment Share on other sites More sharing options...
amosunfemi Posted September 3, 2009 Share Posted September 3, 2009 As anyone tried ZSI to call runreport method? i tried list web method with ZSI it was ok, but runReport method gave this error "xml.parsers.expat.ExpatError not well formed (invalid token) line 2, line 6" here are my requests and responses: List Request: '''<request operationName="list" locale="en"> <resourceDescriptor name="" wsType="folder" uriString="/ContentFiles" isNew="false"> <label>null</label> </resourceDescriptor> </request>''' Response:<?xml version="1.0" encoding="UTF-8"?> <operationResult version="2.0.1"> <returnCode><![CDATA[0]]></returnCode> <resourceDescriptor name="html" wsType="folder" uriString="/ContentFiles/html" isNew="false"> <label><![CDATA]></label> <resourceProperty name="PROP_HAS_DATA"> <value><![CDATA[false]]></value> </resourceProperty> <resourceProperty name="PROP_RESOURCE_TYPE"> <value><![CDATA[com.jaspersoft.jasperserver.api.metadata.common.domain.Folder]]></value> </resourceProperty> <resourceProperty name="PROP_PARENT_FOLDER"> <value><![CDATA[/ContentFiles]]></value> </resourceProperty> <resourceProperty name="PROP_VERSION"> <value><![CDATA[0]]></value> </resourceProperty> </resourceDescriptor> <resourceDescriptor name="pdf" wsType="folder" uriString="/ContentFiles/pdf" isNew="false"> <label><![CDATA[pdf]]></label> <resourceProperty name="PROP_HAS_DATA"> <value><![CDATA[false]]></value> </resourceProperty> <resourceProperty name="PROP_RESOURCE_TYPE"> <value><![CDATA[com.jaspersoft.jasperserver.api.metadata.common.domain.Folder]]></value> </resourceProperty> <resourceProperty name="PROP_PARENT_FOLDER"> <value><![CDATA[/ContentFiles]]></value> </resourceProperty> <resourceProperty name="PROP_VERSION"> <value><![CDATA[0]]></value> </resourceProperty> </resourceDescriptor> <resourceDescriptor name="xls" wsType="folder" uriString="/ContentFiles/xls" isNew="false"> <label><![CDATA[xls]]></label> <resourceProperty name="PROP_HAS_DATA"> <value><![CDATA[false]]></value> </resourceProperty> <resourceProperty name="PROP_RESOURCE_TYPE"> <value><![CDATA[com.jaspersoft.jasperserver.api.metadata.common.domain.Folder]]></value> </resourceProperty> <resourceProperty name="PROP_PARENT_FOLDER"> <value><![CDATA[/ContentFiles]]></value> </resourceProperty> <resourceProperty name="PROP_VERSION"> <value><![CDATA[0]]></value> </resourceProperty> </resourceDescriptor> </operationResult> RunReport Request: '''<request operationName="runReport" locale="en"> <argument name="RUN_OUTPUT_FORMAT">HTML</argument> <resourceDescriptor name="" wsType="" uriString="/reports/custacct/custacctbal" isNew="false"> <label>null</label> <parameter name="cust_ac_no">0051060146525401</parameter> </resourceDescriptor> </request>''' Response: ------=_Part_54_16191831.1252564510371 Content-Type: text/xml; charset=UTF-8 Content-Transfer-Encoding: binary Content-Id: <1128FB0E70D5884145245EA68D95A8ED> <?xml version="1.0" encoding="utf-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soapenv:Body><ns1:runReportResponse soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="http://axis2.ws.jasperserver.jaspersoft.com"><runReportReturn xsi:type="xsd:string"><?xml version="1.0" encoding="UTF-8"?> <operationResult version="2.0.1"> <returnCode><![CDATA[0]]></returnCode> </operationResult> </runReportReturn></ns1:runReportResponse></soapenv:Body></soapenv:Envelope> ------=_Part_54_16191831.1252564510371 Content-Type: text/html Content-Transfer-Encoding: binary Content-Id: <report> <html> <body text="#000000" link="#000000" alink="#000000" vlink="#000000"> <table width="100%" cellpadding="0" cellspacing="0" border="0"> <tr><td width="50%"> </td><td align="center"> <a name="JR_PAGE_ANCHOR_0_1"/> <table style="width: 1500px" cellpadding="0" cellspacing="0" border="0" bgcolor="white"> <tr> <td><img alt="" src="images/px" style="width: 20px; height: 1px;"/></td> <td><img alt="" src="images/px" style="width: 1px; height: 1px;"/></td> <td><img alt="" src="images/px" style="width: 74px; height: 1px;"/></td> <td><img alt="" src="images/px" style="width: 1px; height: 1px;"/></td> <td><img alt="" src="images/px" style="width: 118px; height: 1px;"/></td> <td><img alt="" src="images/px" style="width: 1px; height: 1px;"/></td> <td><img alt="" src="images/px" style="width: 1px; height: 1px;"/></td> <td><img alt="" src="images/px" style="width: 99px; height: 1px;"/></td> <td><img alt="" src="images/px" style="width: 1px; height: 1px;"/></td> <td><img alt="" src="images/px" style="width: 1px; height: 1px;"/></td> <td><img alt="" src="images/px" style="width: 36px; height: 1px;"/></td> <td><img alt="" src="images/px" style="width: 47px; height: 1px;"/></td> <td><img alt="" src="images/px" style="width: 26px; height: 1px;"/></td> <td><img alt="" src="images/px" style="width: 1px; height: 1px;"/></td> <td><img alt="" src="images/px" style="width: 104px; height: 1px;"/></td> <td><img alt="" src="images/px" style="width: 1px; height: 1px;"/></td> <td><img alt="" src="images/px" style="width: 66px; height: 1px;"/></td> <td><img alt="" src="images/px" style="width: 1px; height: 1px;"/></td> <td><img alt="" src="images/px" style="width: 1px; height: 1px;"/></td> <td><img alt="" src="images/px" style="width: 1px; height: 1px;"/></td> <td><img alt="" src="images/px" style="width: 8px; height: 1px;"/></td> <td><img alt="" src="images/px" style="width: 74px; height: 1px;"/></td> <td><img alt="" src="images/px" style="width: 1px; height: 1px;"/></td> <td><img alt="" src="images/px" style="width: 1px; height: 1px;"/></td> <td><img alt="" src="images/px" style="width: 56px; height: 1px;"/></td> <td><img alt="" src="images/px" style="width: 14px; height: 1px;"/></td> <td><img alt="" src="images/px" style="width: 1px; height: 1px;"/></td> <td><img alt="" src="images/px" style="width: 1px; height: 1px;"/></td> <td><img alt="" src="images/px" style="width: 20px; height: 1px;"/></td> <td><img alt="" src="images/px" style="width: 108px; height: 1px;"/></td> <td><img alt="" src="images/px" style="width: 1px; height: 1px;"/></td> <td><img alt="" src="images/px" style="width: 1px; height: 1px;"/></td> <td><img alt="" src="images/px" style="width: 2px; height: 1px;"/></td> <td><img alt="" src="images/px" style="width: 22px; height: 1px;"/></td> <td><img alt="" src="images/px" style="width: 4px; height: 1px;"/></td> <td><img alt="" src="images/px" style="width: 36px; height: 1px;"/></td> <td><img alt="" src="images/px" style="width: 99px; height: 1px;"/></td> <td><img alt="" src="images/px" style="width: 2px; height: 1px;"/></td> <td><img alt="" src="images/px" style="width: 2px; height: 1px;"/></td> <td><img alt="" src="images/px" style="width: 446px; height: 1px;"/></td> </tr> <tr valign="top"> <td colspan="40"><img alt="" src="images/px" style="width: 1500px; height: 28px;"/></td> </tr> <tr valign="top"> <td><img alt="" src="images/px" style="width: 20px; height: 1px;"/></td> <td colspan="36" style="border-top-style: solid; border-top-width: 1px; border-top-color: #000000; "><img alt="" src="images/px" border="0"/></td> <td colspan="3"><img alt="" src="images/px" style="width: 450px; height: 1px;"/></td> </tr> <tr valign="top"> <td colspan="40"><img alt="" src="images/px" style="width: 1500px; height: 4px;"/></td> </tr> <tr valign="top"> <td colspan="11"><img alt="" src="images/px" style="width: 353px; height: 35px;"/></td> <td colspan="18" style="text-align: center;"><span style="font-family: sansserif; font-size: 14.0px; font-weight: bold;">Customer Account Balance</span></td> <td colspan="11"><img alt="" src="images/px" style="width: 723px; height: 35px;"/></td> </tr> <tr valign="top"> <td colspan="40"><img alt="" src="images/px" style="width: 1500px; height: 3px;"/></td> </tr> <tr valign="top"> <td><img alt="" src="images/px" style="width: 20px; height: 1px;"/></td> <td colspan="36" style="border-top-style: solid; border-top-width: 1px; border-top-color: #000000; "><img alt="" src="images/px" border="0"/></td> <td colspan="3"><img alt="" src="images/px" style="width: 450px; height: 1px;"/></td> </tr> <tr valign="top"> <td colspan="40"><img alt="" src="images/px" style="width: 1500px; height: 6px;"/></td> </tr> <tr valign="top"> <td><img alt="" src="images/px" style="width: 20px; height: 18px;"/></td> <td colspan="2" style="background-color: #999999; "><span style="font-family: sansserif; color: #FFFFFF; background-color: #999999; font-size: 12.0px;">Branch Code</span></td> <td><img alt="" src="images/px" style="width: 1px; height: 18px;"/></td> <td style="background-color: #999999; "><span style="font-family: sansserif; color: #FFFFFF; background-color: #999999; font-size: 12.0px;">Branch Name</span></td> <td><img alt="" src="images/px" style="width: 1px; height: 18px;"/></td> <td colspan="2" style="background-color: #999999; "><span style="font-family: sansserif; color: #FFFFFF; background-color: #999999; font-size: 12.0px;">Customer </span></td> <td><img alt="" src="images/px" style="width: 1px; height: 18px;"/></td> <td colspan="4" style="background-color: #999999; "><span style="font-family: sansserif; color: #FFFFFF; background-color: #999999; font-size: 12.0px;">Account </span></td> <td><img alt="" src="images/px" style="width: 1px; height: 18px;"/></td> <td style="background-color: #999999; "><span style="font-family: sansserif; color: #FFFFFF; background-color: #999999; font-size: 12.0px;">Customer </span></td> <td><img alt="" src="images/px" style="width: 1px; height: 18px;"/></td> <td style="background-color: #999999; "><span style="font-family: sansserif; color: #FFFFFF; background-color: #999999; font-size: 12.0px;">Currency</span></td> <td><img alt="" src="images/px" style="width: 1px; height: 18px;"/></td> <td colspan="4" style="background-color: #999999; "><span style="font-family: sansserif; color: #FFFFFF; background-color: #999999; font-size: 12.0px;">Account Class</span></td> <td><img alt="" src="images/px" style="width: 1px; height: 18px;"/></td> <td colspan="3" style="background-color: #999999; "><span style="font-family: sansserif; color: #FFFFFF; background-color: #999999; font-size: 12.0px;">Description</span></td> <td><img alt="" src="images/px" style="width: 1px; height: 18px;"/></td> <td colspan="3" style="background-color: #999999; "><span style="font-family: sansserif; color: #FFFFFF; background-color: #999999; font-size: 12.0px;">Local Currency </span></td> <td colspan="2"><img alt="" src="images/px" style="width: 2px; height: 18px;"/></td> <td colspan="6" style="background-color: #999999; "><span style="font-family: sansserif; color: #FFFFFF; background-color: #999999; font-size: 12.0px;">Account Curr Avail Balance</span></td> <td colspan="2"><img alt="" src="images/px" style="width: 448px; height: 18px;"/></td> </tr> <tr valign="top"> <td colspan="2"><img alt="" src="images/px" style="width: 21px; height: 20px;"/></td> <td colspan="2"><span style="font-family: sansserif; font-size: 10.0px;">005</span></td> <td><span style="font-family: sansserif; font-size: 10.0px;">EBN LAGOS - SURULERE</span></td> <td colspan="2"><img alt="" src="images/px" style="width: 2px; height: 20px;"/></td> <td colspan="2"><span style="font-family: sansserif; font-size: 10.0px;">005106014652540</span></td> <td><img alt="" src="images/px" style="width: 1px; height: 20px;"/></td> <td colspan="4"><span style="font-family: sansserif; font-size: 10.0px;">AGWU - IBIAM</span></td> <td><span style="font-family: sansserif; font-size: 10.0px;">01465254</span></td> <td colspan="4"><span style="font-family: sansserif; font-size: 10.0px;">NGN</span></td> <td><img alt="" src="images/px" style="width: 1px; height: 20px;"/></td> <td colspan="4"><span style="font-family: sansserif; font-size: 10.0px;">SAIND</span></td> <td colspan="3"><span style="font-family: sansserif; font-size: 10.0px;">SAVINGS </span></td> <td><img alt="" src="images/px" style="width: 1px; height: 20px;"/></td> <td colspan="3"><span style="font-family: sansserif; font-size: 10.0px;">2135.28</span></td> <td colspan="2"><img alt="" src="images/px" style="width: 3px; height: 20px;"/></td> <td colspan="6"><span style="font-family: sansserif; font-size: 10.0px;">2135.28</span></td> <td><img alt="" src="images/px" style="width: 446px; height: 20px;"/></td> </tr> <tr valign="top"> <td colspan="40"><img alt="" src="images/px" style="width: 1500px; height: 686px;"/></td> </tr> <tr valign="top"> <td colspan="12"><img alt="" src="images/px" style="width: 400px; height: 19px;"/></td> <td colspan="9"><span style="font-family: sansserif; font-size: 10.0px;">9/10/09 7:35 AM</span></td> <td colspan="4"><img alt="" src="images/px" style="width: 132px; height: 19px;"/></td> <td colspan="9" style="text-align: right;"><span style="font-family: sansserif; font-size: 10.0px;">Page 1 of </span></td> <td><img alt="" src="images/px" style="width: 4px; height: 19px;"/></td> <td><span style="font-family: sansserif; font-size: 10.0px;">1</span></td> <td colspan="4"><img alt="" src="images/px" style="width: 549px; height: 19px;"/></td> </tr> <tr valign="top"> <td colspan="40"><img alt="" src="images/px" style="width: 1500px; height: 21px;"/></td> </tr> </table> </td><td width="50%"> </td></tr> </table> </body> </html> ------=_Part_54_16191831.1252564510371-- Link to comment Share on other sites More sharing options...
ddaly Posted October 6, 2009 Share Posted October 6, 2009 Have you got any further with using ZSI to run a report?It seems that the problem with using ZSI is that the response from runReport is multipart.I am working on a patch for ZSI's client.py which would allow it to receive the multipart response from jasperserver.Daryl. Link to comment Share on other sites More sharing options...
marco159 Posted November 8, 2010 Share Posted November 8, 2010 Have you created the patch for ZSI?I need to read a multipart/related response and with standard ZSI it's not possible ...Thanks Link to comment Share on other sites More sharing options...
ddaly Posted November 8, 2010 Share Posted November 8, 2010 Here is my customized client.py. It is based on ZSI svn source revision 1495. There is not much to my change. The ReceiveSOAP parses out the multi-part payloads then Receive returns the payloads. There is an API change because Receive either returns the normal reply or, if there are additional payloads, the normal reply plus the payloads. Because of this, it may break other usages of this routine. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now