Jump to content
Changes to the Jaspersoft community edition download ×

how to call jasper reports from .NET platform?


adshocker

Recommended Posts

hi,

 

i'm using VB.Net express as my front end and is planning to use Jasper Reports. i have installed Jasper Server 3.0 and is using iReport 3.0 to create report templates (jrxml) then upload them on Jasper Server. i am able to run the report successfully in jasper server but i was wondering if anyone can help me run report from vb.net forms.

 

so far, i have added the wsdl of jasper server to my .net application but having problem with the runReport since it doesn.t have it. the URL for the wsdl i'm using is http://localhost:8080/jasperserver/services/repository?wsdl. then when adding this web service as a web reference is my .net application, i only get runReportCompletedEventArgs and runReportCompletedEventHandler.

 

are there any guides / documents/ articles that i can read about this?

 

thanks.



Post Edited by A.D. Shocker at 11/19/08 03:50
Link to comment
Share on other sites

  • 2 weeks later...
  • Replies 8
  • Created
  • Last Reply

Top Posters In This Topic

i've somehow found a way to call the report but i am getting the error when doing so.

 

see my code below.

 

the error i'm getting is..

 

Client found response content type of 'multipart/related; type="text/xml"; start="<22108A0FFCC1846DF9E59A2F921274EC>";     boundary="----=_Part_4_25969376.1227076879703"', but expected 'text/xml'.
The request failed with the error message:
--

------=_Part_4_25969376.1227076879703
Content-Type: text/xml; charset=UTF-8
Content-Transfer-Encoding: binary
Content-Id: <22108A0FFCC1846DF9E59A2F921274EC>

<?xml version="1.0" encoding="utf-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soapenv:Body><ns1:runReportResponse soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="http://axis2.ws.jasperserver.jaspersoft.com"><runReportReturn xsi:type="xsd:string"><?xml version="1.0" encoding="UTF-8"?>
<operationResult version="2.0.1">
    <returnCode><![CDATA[0]]></returnCode>
</operationResult>
</runReportReturn></ns1:runReportResponse></soapenv:Body></soapenv:Envelope>
------=_Part_4_25969376.1227076879703
Content-Type: application/pdf
Content-Transfer-Encoding: binary
Content-Id: <report>

%PDF-1.4
%????
5 0 obj <</Filter/FlateDecode/Length 726>>stream
x???Qo?0 ???+??IU? ;q?? .d
    ???M{?(eL?H[?j?~6)+ ?@?mB?  > ???0?????? 5 ?? '????2????w????i;???f4?
? ?O???? P ???d??P< ??t?97? ?*???? ???? %???d-9 >??    s???p ?????,?9???? kA??59???X???g? ?? ?I?O??p ?1    ???8??/????[?G??_/W??_???? ???k??!78??M???!????b]?!??z2OM|?d????&YqWd     ?t0,? ? $0??3???I/-? Q,TgX#]N
2J?4K? ; c?*G??$???U???P?;? aN???l ??#F? uh?? *? ??Q ?b  R ? !? P??7j???%???F???k?`R  O?
? i0`???c????? @/?p` J-??DG????R?`  ??p?1 ?e2???? ???? ????? {?f?8?]  ? rr   ???b-@?ko?? ?????   b?!????H?? ;??V  a??8  ??:4B?c0n?q??(??F ?????$T? ?F
? ?i ? ??? ?5 y iMp?!?e?` 2P"
la'????   #?  Ub??Kw ??b B?????t?! ?Pd T?qZ ??qw  *?H  ???? ?J0? ???[???.? ?@? ?R??[  ?& a? ?M????f<?k???? m  Y?? ]?S?? ???9 ?????m?C3c  ? ?? F??54? hM??
endstream
endobj
1 0 obj<</Type/Page/Contents 5 0 R/Parent 6 0 R/Resources<</ProcSet [/PDF /Text /ImageB /ImageC /ImageI]/Font<</F1 2 0 R/F3 4 0 R/F2 3 0 R>>>>/MediaBox[0 0 595 842]>>
endobj
7 0 obj[1 0 R/XYZ 0 854 0]
endobj
2 0 obj<</Type/Font/BaseFont/Helvetica/Subtype/Type1/Encoding/WinAnsiEncoding>>
endobj
3 0 obj<</Type/Font/BaseFont/Helvetica-Bold/Subtype/Type1/Encoding/WinAnsiEncoding>>
endobj
4 0 obj<</Type/Font/BaseFont/Helvetica-Oblique/Subtype/Type1/Encoding/WinAnsiEncoding>>
endobj
6 0 obj<</Count 1/Type/Pages/Kids[1 0 R]>>
endobj
8 0 obj<</Names[(JR_PAGE_ANCHOR_0_1) 7 0 R]>>
endobj
9 0 obj<</Dests 8 0 R>>
endobj
10 0 obj<</Type/Catalog/Pages 6 0 R/Names 9 0 R>>
endobj
11 0 obj<</CreationDate(D:20081119144119+08'00')/Producer(iText1.3.1 by lowagie.com (based on itext-paulo-154))/Creator(JasperReports (Employees))/ModDate(D:20081119144119+08'00')>>
endobj
xref
0 12
0000000000 65535 f
0000000808 00000 n
0000001016 00000 n
0000001103 00000 n
0000001195 00000 n
0000000015 00000 n
0000001290 00000 n
0000000982 00000 n
0000001340 00000 n
0000001393 00000 n
0000001424 00000 n
0000001481 00000 n
trailer
<</ID [<6e4a705411e2b3d417478962399f3e93><6e4a705411e2b3d417478962399f3e93>]/Root 10 0 R/Size 12/Info 11 0 R>>
startxref
1674
%%EOF

------=_Part_4_25969376.1227076879703--

--.

 

don't have a clue what it means. can someone help?

 

thanks

Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click  Dim n As New ManagementServiceService  Dim c As New System.Net.NetworkCredential("jasperadmin", "jasperadmin")  n.Credentials = c  n.runReport(TextBox1.Text)End SubTextBox1.Text has the ff:<?xml version="1.0" encoding="UTF-8"?><request operationName="runReport" locale="en"><argument name="RUN_OUTPUT_FORMAT">PDF</argument><resourceDescriptor name="" wsType="" uriString="/reports/EmployeesReport" isNew="false"><label>null</label></resourceDescriptor></request>
Link to comment
Share on other sites

  • 1 month later...
  • 2 weeks later...

Hi guys!

I have been working on the same problem for about a week and found a solution. I am using Jasper ireport and .net C# client side.

So to make an interop betwen the axis service and .Net client to use attachments u have to use WSE 2.0 and let your jasper know to use DIME attachments! Add an argument to the request xml:

<argument name="USE_DIME_ATTACHMENTS"></argument>

 

Very important: In the generated proxy class (from the wsdl.exe tool) make sure the class inherits from

Microsoft.Web.Services2.WebServicesClientProtocol

don't forget to add "using Microsoft.Web.Services2;" (for C#)

 

very simple example to read an attachment (C#):

      MyService mgmtServ = new MyService();
      mgmtServ.Credentials = new System.Net.NetworkCredential("usr", "pwd");
      mgmtServ.PreAuthenticate = true;

      string _out2 = mgmtServ.runReport(getReportXML);
      using (FileStream _out1 = new FileStream("C:/test.pdf", FileMode.Create, FileAccess.Write, FileShare.None))
      {

        //if attachment exists
        using (Stream data = (mgmtServ.ResponseSoapContext.Attachments[0].Stream))
        {
          byte[] b_array = new byte[data.Length];
          data.Read(b_array, 0, (int)data.Length);
          _out1.Write(b_array, 0, (int)data.Length);
        }
      }

 

hope this will help you!

Link to comment
Share on other sites

  • 2 years later...

Rajesh, I have been out of the .NET game for a few years so not up to speed on what they might have added for calling Java from .NET.   This is probably more a question for the JasperReports forum vs the iReport forum so you may have better luck there.

Note, check out a product called JNBridge,  just google it,  they have interopt between Java and .NET but other than that I can't comment on it's applicability nor what would be required to use.

Jeff

 

Link to comment
Share on other sites

  • 1 year later...

I was able to use jasperreports from an ASP.NET (C#) application using JNI4NET as a bridge between .NET & JAVA (works two ways), I performed a load test simulating multiple concurrent users through Apache Jmeter & the performance is very good, only the very first call takes some time for the initialization between the two environments to happen.

here is what I did:

1)using iReport designer, I built & compiled my report to .jasper file.
2)created a JAVA project in Eclipse referencing jasperreports JAR, the project reads records from a JDBC connection & fills the jasper template generating a PDF.
3)downloaded jni4net-0.8.6.0-bin from (http://jni4net.sourceforge.net/)
4)in Eclipse, export your project as a JAR file to be referenced from within JNI4NET.
5)use the generateProxies tool that comes with the package to generate a proxy for the JAVA class you directly reference from within .NET, several samples are provided within the package, for example in my project I had several classes, one for generating a chart, one for reading from a database, but only one was called directly from .NET to generate a PDF as in below:

create an XML file to be used by the generateProxy tool:

<TargetDirJvm>workjvm</TargetDirJvm>
<TargetDirClr>workclr</TargetDirClr>

<ClassPath Path="work/jbridge.jar"/> <!-- my Eclipse project exported to JAR-->
<ClassPath Path="lib/jasperreports-4.5.0.jar"/>
<!-- ....................-->

<JavaClass TypeName="reports.GeneratePDF"/> <!-- the JAVA class that will be directly invoked from within .NET, no need to generate proxies for other indirect classes-->


you can see examples on how to call this tool passing the XML file as a parameter in JNI4NET/samples package.

Link to comment
Share on other sites

  • 11 years later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...