[英]Issue with JasperServer report + C# + Soap protocol
First of all, I'm not used with neither C# nor Web Services. 首先,我既没有使用C#也没有使用Web服务。 I'm trying to run the reports genereted on Jasper Server in my C# application and it's returning the error 500 (internal server error) when running the code below:
我试图在我的C#应用程序中运行Jasper Server上生成的报告,并且在运行以下代码时返回错误500(内部服务器错误):
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\">HTML</argument>");
sb.AppendFormat(" <resourceDescriptor name=\"\" wsType=\"\" uriString=\"/reports/samples/Accounts Report\" isNew=\"false\">");
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();
I've been looking on internet for quite a long time now and nothing have helped me with this… 我一直在互联网上寻找很长一段时间,对此没有任何帮助。
Ps.: I have jasper server running and the credentials are right. 附注:我正在运行jasper服务器,并且凭据正确。 Also I NEED to use Soap, not Rest, and must be with C#.
我还需要使用Soap,而不是Rest,并且必须与C#一起使用。 I've made it work with PHP but it's not the objective.
我已经使其与PHP一起使用,但这不是目标。
I've finally found out what is wrong . 我终于找到了问题所在。 There was a missing tag in the XML.
XML中缺少标签。
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("<![CDATA[<request operationName=\"runReport\" locale=\"br\">");
sb.AppendLine("<argument name=\"RUN_OUTPUT_FORMAT\">HTML</argument>");
sb.AppendFormat("<resourceDescriptor name=\"Accounts Report\" wsType=\"reportUnit\" uriString=\"/reports/samples/AllAccounts\" isNew=\"false\">");
sb.AppendLine("</resourceDescriptor>");
sb.AppendLine("</request>]]>");
sb.AppendLine("</requestXmlString>");
sb.AppendLine("</q1:runReport>");
sb.AppendLine("</s:Body></s:Envelope>");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.