Thursday, April 21, 2005

Lifez chugging along...

Today I didn't have anything "nutritious" on my plate. I was asked to take a session on Tiles (again!) tomorrow that would be recorded for new joinees in the future. This time I want to experiment with the "metacognition" approach I learnt from reading the Heaf First series books, made a PPT. Letz see how it goes.
I accidently hit upon Amit Rathore's site, he is just amazing.

Wednesday, April 20, 2005

File Attachments using Axis

Another small but interesting problem. My colleague agained stumbled upon a problem - sending files as attachments using webservices. Although, I knew that SAAJ is used for attachments, I was looking for a good example to speed up my friend's work. I found a very simple yet exhaustive example at this link http://www.bii.a-star.edu.sg/infoscience/seg/fileTransfer.asp. Thanks to Azmi Bin Mohamed Ridwan, who shared this excellent example.

Monday, April 18, 2005

POI is tres cool

Today, my task was to parse an XML file and generate a Excel file out of it. I was trying various available alternatives like Gnumeric format, SpreadsheetML and jakarta POI. POI is tres cool.It saved lot of lines of code and most interestingly a very narrow learning curve.

Friday, April 15, 2005

Publishing an EJB as WS


To expose an EJB as an endpoint, there are two ways - if the container supports EJB2.1 spec, a stateless session bean can be exposed as a web service or use Axis Platform to publish an EJB as a WS. I preferred the latter for some project reasons. I'm using WLS8.1 SP2.
The process doesn't require more than 3-4 lines in the deploy.wsdd file.
The following is a copy paste from the deploy.wsdd:





<parameter name="beanJndiName" value="HelloBean"/>
<parameter name="homeInterfaceName" value="demo.HelloHome"/>
<parameter name="remoteInterfaceName" value="demo.Hello"/>
<parameter name="allowedMethods" value="*"/>
<parameter name="jndiURL" value="t3://localhost:7001"/>
<parameter name="jndiContextClass" value="weblogic.jndi.WLInitialContextFactory"/>


And Bingo! I executed published and consumed the WS at the first go without any errors. whew! what a relief.
The next step was to send and receive arrays of VOs from the WS. This requried some fiddling of the wsdd file again. This line did the magic:



<beanMapping qname="myNS:VO" xmlns:myNS="urn:ravi" languageSpecificType="java:ravi.MyVO"/>



and the extra lines in the client program>



call.registerTypeMapping(MyVO.class, qn,
new org.apache.axis.encoding.ser.BeanSerializerFactory(MyVO.class, qn),
new org.apache.axis.encoding.ser.BeanDeserializerFactory(MyVO.class, qn));
call.setReturnType( qn );




This solved 80% of my problem. The next step was to return an array of VOs. This required just one change in the above code
call.setReturnType(XMLType.SOAP_ARRAY);
I'm delighted on publishing and consuming the WS. I'm still excited, thought I would write a Eclipse plugin that uses axis and generates stubs for static invocation.. Hmm not a bad idea....

Wednesday, April 13, 2005

Back to Web Services

One of my colleagues has stumbled upon webservices and asked for help. The problem was intriguing and spurred interest. The scope of the problem was to pass an object (VO) as in put argument to an EJB published as a web service and get another VO as a return from the method call. This was interesting indeed and I jumped onto it immediately....