【问题标题】:Issue with JasperServer report + C# + Soap protocolJasperServer 报告问题 + C# + Soap 协议
【发布时间】:2014-05-05 20:19:59
【问题描述】:

首先,我既不使用 C# 也不使用 Web 服务。 我正在尝试在我的 C# 应用程序中运行 Jasper 服务器上生成的报告,并在运行以下代码时返回错误 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();

我已经在网上找了很长时间了,但没有什么能帮到我……

Ps.:我正在运行 jasper 服务器并且凭据是正确的。我还需要使用 Soap,而不是 Rest,并且必须使用 C#。我已经让它与 PHP 一起工作,但这不是目标。

【问题讨论】:

    标签: c# soap jasper-reports jasperserver


    【解决方案1】:

    我终于发现了问题所在。 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>");
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-04-08
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多