Note that there are some explanatory texts on larger screens.

plurals
  1. PORunning report on JasperServer from C#
    primarykey
    data
    text
    <p>Jasper Reports is a superb open source alternative to Crystal Reports. It's great for single page PDF pages such as letters &amp; invoices to multi-page reports. However it's not very .NET friendly, and getting C#/Mono to play nice with JasperServer has not been fruitful.</p> <p>Has anyone got any code samples of how to run a report on JasperServer from C#, and attach an XML dataset with the SOAP request? It needs to work on Mono, so Microsoft.Web.Services2 is out of the question.</p> <p>I had a go at trying to roll my own soap request. Jasper Server seems to accept it, but I cant seem to get any response back other than a server 500 error. I didn't get as far as attaching a MTOM attachment.</p> <pre><code>var sb = new StringBuilder(); sb.AppendLine("&lt;s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\"&gt;"); sb.AppendLine("&lt;s:Body s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"&gt;"); sb.AppendLine("&lt;q1:runReport xmlns:q1=\"http://axis2.ws.jasperserver.jaspersoft.com\"&gt;"); sb.AppendLine("&lt;requestXmlString xsi:type=\"xsd:string\"&gt;"); sb.AppendLine("&lt;request operationName=\"runReport\" locale=\"en\"&gt;"); sb.AppendLine(" &lt;argument name=\"RUN_OUTPUT_FORMAT\"&gt;PDF&lt;/argument&gt;"); sb.AppendFormat(" &lt;resourceDescriptor name=\"\" wsType=\"\" uriString=\"{0}\" isNew=\"false\"&gt;", "/JourneyReport"); sb.AppendLine(" &lt;label&gt;null&lt;/label&gt;"); sb.AppendLine(" &lt;parameter name=\"testparam\"&gt;1&lt;/parameter&gt;"); sb.AppendLine(" &lt;/resourceDescriptor&gt;"); sb.AppendLine(" &lt;/request&gt;"); sb.AppendLine("&lt;/requestXmlString&gt;"); sb.AppendLine("&lt;/q1:runReport&gt;"); sb.AppendLine("&lt;/s:Body&gt;&lt;/s:Envelope&gt;"); var webRequest = (HttpWebRequest)WebRequest.Create("http://localhost:8080/jasperserver/services/repository"); webRequest.Credentials = new NetworkCredential("jasperadmin","jasperadmin"); webRequest.PreAuthenticate = true; webRequest.Headers.Add("SOAPAction",""); //Set HttpWebRequest properties byte[] bytes = System.Text.Encoding.UTF8.GetBytes(sb.ToString()); webRequest.Method = "POST"; webRequest.ContentLength = bytes.Length; webRequest.ContentType = "text/xml; encoding='utf-8'"; //Get Stream object var objRequestStream = webRequest.GetRequestStream(); objRequestStream.Write(bytes, 0, bytes.Length); objRequestStream.Close(); var response = (HttpWebResponse)webRequest.GetResponse(); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload