First of all, I'm not used with neither C# nor Web Services. 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:
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. Also I NEED to use Soap, not Rest, and must be with C#. I’ve made it work with PHP but it’s not the objective.
I've finally found out what is wrong . There was a missing tag in the 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>");