My Learnings

Tuesday, June 3, 2008

Back after a long break

Had a wonderful 2 years in Germany. Travelled back to my place bangalore and it really took me some(3 months!!) to settle down and getting back to normal.
And iam still comming to terms in terms of bangalore's worst problem traffic congestion.
It took me just 10 min to go to work in Germany as compared to 2 hours here in bangalore!!!..

Had a great time travelling all over Europe the best place i have visited is Koenigssee.

Now have a long backlog of blogs. Thinking of posting all at once

Tuesday, September 11, 2007

FOP PDF Generation

I wonder why some of the scanners do not have the option to generate a single PDF for multiple page scans. It is quite irritating if you have to scan around 10 pages and have to send those scanned 10 pages to someone. And some scanners do not even provide the option to save the scanned image as PDF!!.

I was involved recently in a solution that required generation of PDFs. I found there were two major PDF generators available on net, itext and FOP

Itext is a purely java based solution and FOP an XSLT based solution. FOP really appealed me because of its ability to configure. The layouts can be changed every easily by just changing the 'fo' file. These 'fo' files are inputs to the xslt processor. I had to do a lot of R&D but the outcome was lot more sweet. I have seen many projects dont consider FOP just because of the initial learning curve. But the initial learning curve is worth considering the amount of flexibility it provides.
I had one troublesome requirement though printing pagenumber in format Page: 1 of 10. Printing a running page number is not at all an issue, but the actual issue is printing the total number of pages. i.e 10 in "Page 1 of 10". After a lot of research i found out that this can be acheived by
Page:<fo:page-number/> of <fo:page-number-citation ref-id="last-page"/>
in the above snippet, "last-page" is the id of the last block used in the fo file.

After working on a complicated layout, i decided to use FOP for my problem stated before. i.e bundling many images to a single PDF file!!. Below is the snippet that i used.

Friday, July 13, 2007

People Matter

In this universe we see two distinct entites, people(what philosophers call as spirit) and matter.
From my experience in software industry, what i understand is that people actually matter a lot. But unfortunately, people are expected to behave like matter!!. On the contrary people are highly creative by nature and they always intend to be treated that way

I beleive that in any organization interested in business there are always three entities involved to get the results.
1. People
2. Process
3. Technology
Attaining a balance amongst the above three entities has often been the quest of many organizations.

Many so called B-and-M ers concentrated on process and technology to get consistant results, so that they can churn out products of same quality always (and in huge numbers).
And people almost always try to derive the techniques and methodologies from the past and implement them in the Software industry. The basic idea behind many processes developed for software industry is its focus on consistancy and discipline.
In my personal experience, this has often been cause of irritation and displeasure amongst people. See article Characterizing people as non-linear, first-order components in software development

It is not that all people do not like consistancy, and it is also not that all people do not want to be disciplined. It all depends on how people are treated in any setup, especially in a software project. As the above article points out, there should be a strong sense of "Good citizenship" and "Community". The same idea is presented in the book Built to Last

It is very unfortunate that iam yet to see a project myself that gives "People" the right focus amongst the other entities "Process" and "Technology". However this does not mean that "Process" and "Technology" is not important. It is my personal opinion that "People", "Process" and "Technology" all the three should be given importance, but with an extra stress and focus on "People".

Thursday, July 12, 2007

Multipart Mime in B2B Communication (using webmethods Integration server)

During B2B communications, it is often required to send data using HTTP protocol with content-Type: multipart/form-data or multipart/mixed or multipart/related. This article helps you to provide a solution for the above mentioned requirement using Webmethods Integration server(I have implemented the solution explained below in version 6.0.1).
Mutlipart data as the name itself suggest, contains multiple parts separated by a boundary. An application receiving the multipart data can identify different parts of the message using the boundary. All file uploads using HTML forms are achieved using multipart/form-data. If you want to dig deeper into multipart/form-data, you may visit the site http://www.w3.org/TR/html4/interact/forms.html

Multipart data can be built using webmethods built-in services. I have used mainly two built-in services.

1. pub.mime:createMimeData
2. pub.mime:addBodyPart

createMimeData service creates the basic mime data with appropriate(default) headers. addBodyPart service is used to add individual body parts to the created mime data. Integration server adds a default boundary to separate each individual body parts provided by the service addBodyPart

A typical HTML file upload form, will have a mixture of data. i.e values that the user enters and the actual files that are required to be uploaded.
For example consider the form below. This contains both, a value for "submitter" and a file.


<form name="uploadform" action="yourserver" enctype="multipart/form-data" method="POST">
submitter: <input type="text" name="submitter" value="myname">
File to submit: <input type="file" name="myfileName">
<input type="submit" name="upload">
</form>


In order to post the data similar to above form using Webmethods Integration Server, follow these steps


1. Call service pub.mime:createMimeData



Provide the following mime header as input

Content-Type:multipart/form-data; boundary="------%%^myUniqueBoundary^%%------"

We have to override the Content-Type header because webmethods-IS by default produces a header as multipart/mixed. we have to also override the default boundary that the webmethods-IS generates, because stragely webmethods-IS puts a carriage return after the "Content-Type:multipart/form-data;" entry(may be because the default boundary string is long!!!!). This is not parsed by some of the server side programs

2. Call service pub.mime:addBodyPart, to add the value of "submitter" as given in the html form above.



Provide the following mime header as input
Content-Disposition:form-data; name="submitter"
Provide contenttype input as "text/plain"
Provide the encoding input as "8bit" (well this depends on your requirement. But 8bit would work on most cases i beleive)

Before calling the addBodyPart, convert the actual value being posted to a byte stream ("myname" in the above HTML form) and provide it as input to variable "content"

3. Call service pub.mime:addBodyPart again to add the value of "myfileName" as given in the html form above.



Provide the following mime header as input
Content-Disposition:form-data; name="myfileName"
Provide contenttype value appropriate to the file that you are trying to upload. for eg: application/octet-stream.
Provide the encoding input appropriate to the file that you are trying to upload. for eg:binary.

Before calling the addBodyPart, get the file lying on the disk and convert into stream.(incase, the file is stored on disk). Provide the file stream as input to variable "content"


4. Finally send the mime data built in above 3 steps through HTTP.




Call the service pub.client:http, and provide the above built mime data as input to the variable mimeStream under data.


Before calling the pub.client:http service, convert the created mime data to a envolope stream using service pub.mime:getEnvelopeStream. Provide this envolope stream as input to http service.


About Me

In quest of myself to know more about me :) Started blogging to store my thoughts and learnings