title: Scheduling a JasperServer Report via SOAP using Python
body: <p>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.</p>
  
  <p>Here's an example execute report request, which works:</p>
  
  <pre><code>repositoryURL = 'http://user@pass:myjasperserver:8080/jasperserver/services/repository'
  repositoryWSDL = repositoryURL + '?wsdl'
  server = SOAPProxy(repositoryURL, repositoryWSDL)
  print server._ns(repositoryWSDL).runReport('''
    &lt;request operationName="runReport" locale="en"&gt;
      &lt;argument name="RUN_OUTPUT_FORMAT"&gt;PDF&lt;/argument&gt;
      &lt;resourceDescriptor name="" wsType="" uriString="/reports/baz"&gt;
        &lt;label&gt;null&lt;/label&gt;
        &lt;parameter name="foo"&gt;bar&lt;/parameter&gt;
      &lt;/resourceDescriptor&gt;
    &lt;/request&gt;
  ''')
  </code></pre>
  
  <p>However, I'm having trouble formatting my requests properly for the "ReportScheduler" section of the server. I've consulted the documentation located here (<a href="http://jasperforge.org/espdocs/docsbrowse.php?id=74&amp;type=docs&amp;group_id=112&amp;fid=305" rel="noreferrer">http://jasperforge.org/espdocs/docsbrowse.php?id=74&amp;type=docs&amp;group_id=112&amp;fid=305</a>), and have tried model my requests after their samples with no luck (see page 27).</p>
  
  <p>Here are two examples that I've tried, which both return the same error:</p>
  
  <pre><code>schedulingURL = 'http://user@pass:myjasperserver:8080/jasperserver/services/ReportScheduler'
  schedulingWSDL = schedulingURL + '?wsdl'
  server = SOAPProxy(schedulingURL, schedulingWSDL)
  
  # first request
  print server._ns(schedulingWSDL).scheduleJob('''
    &lt;request operationName="scheduleJob" locale="en"&gt;
      &lt;job&gt;
        &lt;reportUnitURI&gt;/reports/baz&lt;/reportUnitURI&gt;
        &lt;label&gt;baz&lt;/label&gt;
        &lt;description&gt;baz&lt;/description&gt;
        &lt;simpleTrigger&gt;
          &lt;startDate&gt;2009-05-15T15:45:00.000Z&lt;/startDate&gt;
          &lt;occurenceCount&gt;1&lt;/occurenceCount&gt;
        &lt;/simpleTrigger&gt;
        &lt;baseOutputFilename&gt;baz&lt;/baseOutputFilename&gt;
        &lt;outputFormats&gt;
          &lt;outputFormats&gt;PDF&lt;/outputFormats&gt;
        &lt;/outputFormats&gt;
        &lt;repositoryDestination&gt;
          &lt;folderURI&gt;/reports_generated&lt;/folderURI&gt;
          &lt;sequentialFilenames&gt;true&lt;/sequentialFilenames&gt;
          &lt;overwriteFiles&gt;false&lt;/overwriteFiles&gt;
        &lt;/repositoryDestination&gt;
        &lt;mailNotification&gt;
          &lt;toAddresses&gt;my@email.com&lt;/toAddresses&gt;
          &lt;subject&gt;test&lt;/subject&gt;
          &lt;messageText&gt;test&lt;/messageText&gt;
          &lt;resultSendType&gt;SEND_ATTACHMENT&lt;/resultSendType&gt;
        &lt;/mailNotification&gt;
      &lt;/job&gt;
    &lt;/request&gt;''')
  
  # second request (trying different format here)
  print server._ns(schedulingWSDL).scheduleJob('''
    &lt;ns1:scheduleJob soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="http://www.jasperforge.org/jasperserver/ws"&gt;
    &lt;job xsi:type="ns1:Job"&gt;
      &lt;reportUnitURI xsi:type="xsd:string"&gt;/reports/baz&lt;/reportUnitURI&gt;
      &lt;username xsi:type="xsd:string" xsi:nil="true"/&gt;
      &lt;label xsi:type="xsd:string"&gt;baz&lt;/label&gt;
      &lt;description xsi:type="xsd:string"&gt;baz&lt;/description&gt;
      &lt;simpleTrigger xsi:type="ns1:JobSimpleTrigger"&gt;
        &lt;timezone xsi:type="xsd:string" xsi:nil="true"/&gt;
        &lt;startDate xsi:type="xsd:dateTime"&gt;2008-10-09T09:25:00.000Z&lt;/startDate&gt;
        &lt;endDate xsi:type="xsd:dateTime" xsi:nil="true"/&gt;
        &lt;occurrenceCount xsi:type="xsd:int"&gt;1&lt;/occurrenceCount&gt;
        &lt;recurrenceInterval xsi:type="xsd:int" xsi:nil="true"/&gt;
        &lt;recurrenceIntervalUnit xsi:type="ns1:IntervalUnit" xsi:nil="true"/&gt;
      &lt;/simpleTrigger&gt;
      &lt;calendarTrigger xsi:type="ns1:JobCalendarTrigger" xsi:nil="true"/&gt;
      &lt;parameters soapenc:arrayType="ns1:JobParameter[4]" xsi:type="soapenc:Array" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"&gt;
      &lt;/parameters&gt;
      &lt;baseOutputFilename xsi:type="xsd:string"&gt;test&lt;/baseOutputFilename&gt;
      &lt;outputFormats soapenc:arrayType="xsd:string[1]" xsi:type="soapenc:Array" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"&gt;
        &lt;outputFormats xsi:type="xsd:string"&gt;PDF&lt;/outputFormats&gt;
      &lt;/outputFormats&gt;
      &lt;outputLocale xsi:type="xsd:string" xsi:nil="true"/&gt;
      &lt;repositoryDestination xsi:type="ns1:JobRepositoryDestination"&gt;
        &lt;folderURI xsi:type="xsd:string"&gt;/reports_generated&lt;/folderURI&gt;
        &lt;sequentialFilenames xsi:type="xsd:boolean"&gt;false&lt;/sequentialFilenames&gt;
        &lt;overwriteFiles xsi:type="xsd:boolean"&gt;false&lt;/overwriteFiles&gt;
      &lt;/repositoryDestination&gt;
      &lt;mailNotification xsi:type="ns1:JobMailNotification" xsi:nil="true"/&gt;
    &lt;/job&gt;
    &lt;/ns1:scheduleJob&gt;''')
  </code></pre>
  
  <p>Each of these requests result in errors:</p>
  
  <pre><code>SOAPpy.Types.faultType: &lt;Fault soapenv:Server.userException: org.xml.sax.SAXException:
  Bad types (class java.lang.String -&gt; class com.jaspersoft.jasperserver.ws.scheduling.Job):
  &lt;SOAPpy.Types.structType detail at 14743952&gt;: {'hostname': 'myhost'}&gt;
  </code></pre>
  
  <p>Any help/guidance would be appreciated. Thank you.</p>