title: SSRS Upload reports with SOAP in Java
body: <p>I am using this <a href="https://github.com/realityforge/ssrs-api" rel="nofollow">SSRS-API</a> in my JAVA project, with SQL Server Reporting Services. With this API I can access my SSRS folders and Reports but I want to know if its possible to upload or Export reports in Excel or PDF.</p>
  
  <p>Here is the SSRS java class : <a href="https://raw.githubusercontent.com/realityforge/ssrs-api/master/src/main/java/org/realityforge/sqlserver/ssrs/SSRS.java" rel="nofollow">SSRS.java</a></p>
  
  <p>And my Managed bean : </p>
  
  <pre><code>@ViewScoped
  @ManagedBean(name = "biController")
  @SuppressWarnings("restriction")
  public class BiController {
  
      private final String ADDRESS = "http://SERVERNAME/reportserver/ReportService2005.asmx?wsdl";
      private String[] listReports;
      private SSRS ssrs;
  
      @PostConstruct
      public void init() {
          try {
              URL url = new URL(null, ADDRESS, new sun.net.www.protocol.http.Handler());
              NTLMAuthenticator.setDefault(new NTLMAuthenticator("DOMAIN", "USERNAME", "PASSWORD"));
              ssrs = new SSRS(url, "");
          } catch (MalformedURLException e) {
              throw new FacesException();
          }
      }
  
      // This function let me have the Report's names
      public void constructListOfReports(String path) {
          listReports = ssrs.listReports(path);
      }
  
      public String[] getListReports() {
          return listReports;
      }
  
      public void setListReports(String[] listReports) {
          this.listReports = listReports;
      }
  
  }
  </code></pre>
  
  <p>Any suggestions?</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>I used the download function (<strong>downloadReport</strong>) of SSRS api I mentioned above (<a href="https://github.com/realityforge/ssrs-api" rel="nofollow">SSRS-API</a>), here is the code of the function : </p>
  
  <pre><code>public void downloadReport(final String path, final String filename) {
      final File file = new File(filename);
      final String physicalName = toPhysicalFileName(path);
  
      info("Downloading Report with symbolic name " + path + " to " + file);
  
      final byte[] data = _soap.getReportDefinition(physicalName);
  
      try (final FileOutputStream out = new FileOutputStream(file)) {
          out.write(data);
      } catch (final IOException ioe) {
          final String message = "Failed to download report with symbolic name " + path + " to " + file;
          LOG.warning(message);
          if (file.exists() &amp;&amp; !file.delete()) {
              throw new IllegalStateException(message + " and failed to delete temporary file", ioe);
          } else {
              throw new IllegalStateException(message, ioe);
  
          }
      }
  }
  </code></pre>
  
  <p>And here is the function that I use to call this function : </p>
  
  <pre><code>public void downloadReport() {
      ssrs.downloadReport('Path/Report name', 'C:\\PATH\\TO\\A\\FOLDER\\REPORT.XML');
  }
  </code></pre>
  
  <p>And in the given path (C:/PATH/TO/A/FOLDER/REPORT.XML) I get an XML file like this : </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;Report xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner" xmlns:cl="http://schemas.microsoft.com/sqlserver/reporting/2010/01/componentdefinition" xmlns="http://schemas.microsoft.com/sqlserver/reporting/2010/01/reportdefinition"&gt;
    &lt;AutoRefresh&gt;0&lt;/AutoRefresh&gt;
    &lt;DataSources&gt;
      &lt;DataSource Name="PercallAnalysisDW"&gt;
        &lt;DataSourceReference&gt;Entrepôt de données Percall Analysis&lt;/DataSourceReference&gt;
        &lt;rd:SecurityType&gt;None&lt;/rd:SecurityType&gt;
        &lt;rd:DataSourceID&gt;3a3e3aa4-c6d6-4b44-80f0-f18a9ecd2eac&lt;/rd:DataSourceID&gt;
      &lt;/DataSource&gt;
    &lt;/DataSources&gt;
    &lt;DataSets&gt;
      &lt;DataSet Name="DeliveryMarginCumuleDS"&gt;
        &lt;SharedDataSet&gt;
          &lt;SharedDataSetReference&gt;DeliveryMarginCumuleDS&lt;/SharedDataSetReference&gt;
        &lt;/SharedDataSet&gt;
        &lt;Fields&gt;
          &lt;Field Name="Date"&gt;
            &lt;DataField&gt;Date&lt;/DataField&gt;
            &lt;rd:TypeName&gt;System.String&lt;/rd:TypeName&gt;
          &lt;/Field&gt;
          &lt;Field Name="Projet"&gt;
            &lt;DataField&gt;Projet&lt;/DataField&gt;
            &lt;rd:TypeName&gt;System.String&lt;/rd:TypeName&gt;
          &lt;/Field&gt;
          &lt;Field Name="LABOR_facturé"&gt;
            &lt;DataField&gt;LABOR_facturé&lt;/DataField&gt;
            &lt;rd:TypeName&gt;System.Int32&lt;/rd:TypeName&gt;
          &lt;/Field&gt;
          &lt;Field Name="TL_facturé"&gt;
            &lt;DataField&gt;TL_facturé&lt;/DataField&gt;
            &lt;rd:TypeName&gt;System.Int32&lt;/rd:TypeName&gt;
          &lt;/Field&gt;
          &lt;Field Name="Coût_total"&gt;
            &lt;DataField&gt;Coût_total&lt;/DataField&gt;
            &lt;rd:TypeName&gt;System.Int32&lt;/rd:TypeName&gt;
          &lt;/Field&gt;
          &lt;Field Name="DM"&gt;
            &lt;DataField&gt;DM&lt;/DataField&gt;
            &lt;rd:TypeName&gt;System.Int32&lt;/rd:TypeName&gt;
          &lt;/Field&gt;
          &lt;Field Name="Revenu"&gt;
            &lt;Value&gt;=Fields!LABOR_facturé.Value + Fields!TL_facturé.Value&lt;/Value&gt;
          &lt;/Field&gt;
        &lt;/Fields&gt;
      &lt;/DataSet&gt;
    &lt;/DataSets&gt;
    &lt;ReportSections&gt;
      &lt;ReportSection&gt;
        &lt;Body&gt;
          &lt;ReportItems&gt;
            &lt;Tablix Name="Tablix1"&gt;
              &lt;TablixBody&gt;
                  ...
  </code></pre>