2009-05-15 13 views
6

私は、SOAPpyとxml.dom minidomを使用してPythonを使用してJasperServerでレポートを実行し、ファイルをダウンロードし、フォルダをリストする方法を見つけ出すことができました。Pythonを使用してSOAP経由でJasperServerレポートをスケジュール

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> 
''') 

をしかし、私は、サーバーの「ReportScheduler」セクションのために適切に私の要求をフォーマットするトラブルを抱えている:

は、ここでの例では、働くレポート要求を、実行します。私はここにあるドキュメント(http://jasperforge.org/espdocs/docsbrowse.php?id=74&type=docs&group_id=112&fid=305)に相談し、そのサンプルの後に私の要求をモデル化しようとしました(27ページ参照)。ここで

は同じエラーを返し、両方の私が試したの2つの例は、以下のとおりです。

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>''') 

これらの要求の各エラーになる:

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'}> 

すべてのヘルプ/ガイダンスは理解されるだろう。ありがとうございました。

答えて

1

私はミニドームで多くの悪い経験をしています。私はlxmlを使用することをお勧めします。私は石鹸自体の経験は一切持っていないので、残りの部分については話すことができません。

1

Jasperについて何も知らずに、ハードコードされたSOAPリクエストをthe excellent suds libraryに基づくシンプルなクライアントに置き換える方が良いことを保証します。これはSOAPを抽象化し、きれいでクリーンなAPIアクセスを提供します。

easy_install sudsthe docsで十分です。

関連する問題