Báo cáo Jasper là một giải pháp thay thế nguồn mở tuyệt vời cho Báo cáo tinh thể. Thật tuyệt vời đối với các trang PDF một trang, chẳng hạn như các ký tự & hóa đơn cho các báo cáo nhiều trang. Tuy nhiên nó không phải là rất .NET thân thiện, và nhận được C#/Mono để chơi tốt đẹp với JasperServer đã không được hiệu quả.Chạy báo cáo trên JasperServer từ C#
Có ai có bất kỳ mẫu mã nào về cách chạy báo cáo trên JasperServer từ C# và đính kèm một tập dữ liệu XML với yêu cầu SOAP không? Nó cần phải làm việc trên Mono, vì vậy Microsoft.Web.Services2 là ra khỏi câu hỏi.
Tôi đã cố gắng để cuộn yêu cầu xà phòng của riêng mình. Jasper Server dường như chấp nhận nó, nhưng tôi dường như không thể nhận được bất kỳ phản hồi nào khác ngoài lỗi máy chủ 500. Tôi đã không nhận được như xa như gắn một tập tin đính kèm MTOM.
var sb = new StringBuilder();
sb.AppendLine("<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\">");
sb.AppendLine("<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\">");
sb.AppendLine("<q1:runReport xmlns:q1=\"http://axis2.ws.jasperserver.jaspersoft.com\">");
sb.AppendLine("<requestXmlString xsi:type=\"xsd:string\">");
sb.AppendLine("<request operationName=\"runReport\" locale=\"en\">");
sb.AppendLine(" <argument name=\"RUN_OUTPUT_FORMAT\">PDF</argument>");
sb.AppendFormat(" <resourceDescriptor name=\"\" wsType=\"\" uriString=\"{0}\" isNew=\"false\">", "/JourneyReport");
sb.AppendLine(" <label>null</label>");
sb.AppendLine(" <parameter name=\"testparam\">1</parameter>");
sb.AppendLine(" </resourceDescriptor>");
sb.AppendLine(" </request>");
sb.AppendLine("</requestXmlString>");
sb.AppendLine("</q1:runReport>");
sb.AppendLine("</s:Body></s:Envelope>");
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();
Có thể bài đăng này giúp bạn: http://stackoverflow.com/questions/4351511/upload-report-unit-via-webservice-in-c-sharp-net -to-jasperserver –
Cảm ơn, nhưng nó sẽ không hoạt động trên Mono. Tôi sẽ phải xem nếu tôi có thể tìm thấy một thư viện SOAP khác, hoặc làm theo cách thủ công. – FlappySocks
là một thành phần thương mại là một lựa chọn? – Yahia