Sunday, April 5, 2009

Invoke the SSRS ReportExcecutionService from Java

As usual, the documentation stopped just short of what I was trying to achieve. In this case I was trying to call the MS SQL Server Reporting Service (2005) using a java client.

The problem was the following error upon invocation of the web service:
The session identifier is missing. A session identifier is required for this operation.

After searching the MSDN forums I found this thread that shed some light on my problem. Here is the summarized version:
  1. After creating the stub code using java's wsimport function, edit the ExecutionHeader.java class by adding the following annotation line above the class definition:
    @XmlAccessorType(XmlAccessType.FIELD)
    @XmlType(name = "ExecutionHeader", propOrder = {
    "executionID"
    })
    @XmlRootElement(name="ExecutionHeader")
    public class ExecutionHeader {...
  2. Invoking the web service to return a report is then a simple matter of adding the following method to your client class:
public Report runReport(List parms, String reportPath, ReportFormat format) { ArrayOfParameterValue parameters = new ArrayOfParameterValue();
for (ParameterValue value : parms) {
parameters.getParameterValue().add(value);
}
String devInfo = "False";
Holder result = new Holder();
String reportFormat = format.toString();
Holder extension = new Holder();
Holder mimeType = new Holder();
Holder encoding = new Holder();
Holder warnings = new Holder();
Holder streamIDs = new Holder();
try {
ExecutionInfo execInfo = rs.loadReport(reportPath, null);
String executionID = execInfo.getExecutionID();
ExecutionHeader header = new ExecutionHeader();
header.setExecutionID(executionID);
WSBindingProvider provider = (WSBindingProvider) rs;
provider.setOutboundHeaders(header);
rs.setExecutionParameters(parameters, "en-us");
rs.render(reportFormat, devInfo, result, extension, mimeType, encoding, warnings, streamIDs);
}
catch (Exception e) {
e.printStackTrace();
throw new RuntimeException("Error running report", e);
}
return new Report(format, result.value);
}


Take note of the highlighted lines of code, the Execution header needs to be set onto the WSBindingProvider in order to prevent the Session Identifier error when calling the render method.

I hope this summary helps someone getting past this problem quickly!

Friday, November 21, 2008

Create cool dynamic content using JQuery Ajax functions

I stumbled across a very nice way of loading dynamic content on your web page using JQuery's ajax functions and just had to share it!

I've created a simple demo and you can download the source code here.

Extract it to any folder and you'll find the following files:
  • index.html - this is the content page containing a basic menu to drive the ajax calls with the necessary 'div' placeholders into which the dynamic content will be loaded.
  • main.html - an html content file containing the some of the dynamic content loaded by default
  • aboutus.html - another html file what will be loaded as dynamic content.
  • mydemo.js - most importantly, the javascript file that controls the content.
This demo basically uses jquery's $.load() ajax function to load content from other files/html pages into the current page div.

Open the index.html page inside your browser to see it in action.

Step 1 - The javascript (mydemo.js)

If you're familiar with jquery you should immediately notice the "$(document).ready" function which runs automatically after the document is loaded.

This function adds a click listener to each of the menu items with the following lines of code:
displayNewContent("#indexnav=", "./main.html");
displayNewContent("#contactNav", "./aboutus.html");
and then loads the content of the main.html file into the 'dynamicContent' div using jquery's 'load' function:
$("#dynamicContent").load("./main.html");

Step 2 - The html
(index.html)

Things to note here are the inclusions of the javascript files into you html:
<script type="text/javascript" src="jquery-1.2.6.js"></script>
<script type="text/javascript" src="mydemo.js"></script>

the html anchors in the menu:
<ul>
<li><a id="indexNav" class="navClass" href="#" accesskey="i" title="Home">Home</a></li>
<li><a id="contactNav" class="navClass" href="#" accesskey="c" title="Load some dynamic content">About us</a></li>
</ul>

and finally the empty placeholder <div> for the dynamicContent:
<div id="dynamicContent"></div>

That's all there is to it. You can add new content pages and menu links by simply copying the existing anchor code and giving it a new unique id.

Thursday, October 23, 2008

Ready, steady, start living

Living and working with people who seem to let life go by without living it. Without taking part in every moment of every day. I was like that not too long ago!

Adopting a new mindset...

Life wasn't bad. I was just living from one moment of 'happiness' to the next, always looking forward to the next weekend or holiday when I could be free from the daily drudge.

Something was missing from my life. I started thinking about the old cliche: "what would you do if you only had one year left to live?" Most of us think immediately of quitting our jobs and chasing our dreams. To be able to go and do what your PASSION is in life! That's the answer right?!

The problem is that it's not that easy. Let's face it, where would you get the money to do what you love in life if you quit your job?

The Dilemma...
You know where you are. You know that you're not happy at his place in your life. You know what your life should look like. But how do you get there?

Start having fun!
The change for a better life doesn't start with quitting your job... It starts with having fun with what you're doing every day. Being a Java Developer, fun was just a few clicks away. I started reading about subjects that I've always been interested in. These weren't just every day interests, but also included things that applied to my every day job. Development methodologies, blogs and RSS feeds provides an endless source 'entertainment'. Speaking of entertainment, I found that watching less television gave me more time for reading and other forms of entertainment.

Leave what's behind
Deal with the things (or people) in your life that are dragging you down. Adopt a new attitude towards life, your job, and everything you do. People tend to live their life according to what others think of them and the 'role' that they have been assigned in their life (and job). These may be thoughts like "My input does not count anyway" or "I will never be able to contribute".

I am not an expert on the subject at all, but I'm speaking from my own experience. Life is still hard some days, but preparing for success is better than waiting around for the next blow that life has to offer.

Good luck!

Tuesday, October 7, 2008

A failing project

There are a lot of articles and blogs to read about why and how projects fail. Project failure are mostly contributed to aspects such as poor communication, poor project management, poor estimation and planning, documentation, lack of buy-in etc. The list is endless.

The software development project that I'm currently involved in seems to be failing because of something far more trivial. Failing to do the tasks at hand. Failure to follow through. Lack of Skills. And most importantly (I think), the lack of vision.

When management lacks vision, everyone on the project starts to develop their own (hidden) agenda, and what is supposed to be a collaborative effort turns into a fight for power.

My agony lies in not knowing how to restore the vision. How do you look past the politics brought on by a power struggle, and approach management to restore the focus? How to motivate software developers who have been set up for failure by project managers.

The journey continues...

Wednesday, September 3, 2008

Steekbaard

Welcome to my blog...

Steekbaard is the name of the street where I live and directly translated it means 'stubble beard'.

It's also a way to refer to a crossbreed dog in my home language which is Afrikaans (Similar to Dutch)

I am married to my beautiful wife Chantal and like motorcycling, motorsport and the world of computers.

This is my first attempt at blogging, so I hope the articles get longer and more interesting as time goes on. As a Java Developer I also hope to start blogging about my experiences within the wild and exciting open source world!

Until next time...