- my webspace

- my webspace

Latest Comment

Why I must believe in GOD
Testing time is almost passed..there are many colours in lif...
27/06/12 01:43 More...
By Tarun Shekhawat

Allama Iqbal - Selective verse...
Yahoouj
Really good work about this website was done. Keep trying mo...
07/03/10 15:04 More...
By Roderick

Allama Iqbal - Selective verse...
Great Job
You have dont a great job of collecting these... Even I had ...
25/08/09 01:01 More...
By Sikandar

O ye who don't believe !
It's like Lehman Brothers :grin
11/10/08 10:31 More...
By anurag Chaturvedi

I Protest
@Sikku
Thanks Sikku for the feedback. I never intend to blame, a...
29/07/08 11:06 More...
By Aminur Rashid

Login






Lost Password?
Home arrow Java arrow Axis1 date datatype workaround
Axis1 date datatype workaround PDF Print E-mail
User Rating: / 3
PoorBest 
Written by Aminur Rashid   
Monday, 09 May 2011

If you are handling a legacy system, using Axis (1.4) webservices you must have come across Java2WSDL and WSDL2Java tools. The tools help you to generate a WSDL from a java class as well as generating stubs/skeletons from a WSDL. However if are dealing with java.util.Date fields in your code, you should notice following :
package com.aminur.test.ws.axis1.dateservice;

import java.util.Date;

public abstract class TestService {
	public abstract Date fetchEndDate();

	public void updateEndDate(Date dateToBeSet) {
	}
}
Now if you will use Java2WSDL like below :(ignore the variables in the attribute. Entire project is attached in end of post)

you will find wsdl as something like below: Notice the xsd type for the return or the parameter. It is dateTime. When this WSDL will be used in target WSDL2Java, then the datatype for the parameter/return type will be changed to java.util.Calendar.
You can change the generate wsdl file manually to replace dateTime with date. However in the automated build process this will be a bottleneck. What I did is customized this generated wsdl file with a xsl style sheet to replace the type of the elements, I want. Following is the style sheet I used

And following is the snippet from build.xml file which uses the xsl to replace dateTime with date.

The wsdl file snippet generated after customization (and after compiling the abstract class in debug mode) is as below :

Now the last part remaining is the insertion of following code in your server-config.wsdd as child of your service. This is required, to assign the correct (De)Serializer to the element.


Resources: Source Code

Note :
To get rid of generated parameter name e.g in0,in1 in wsdl and to keep original parameter, compile your class with debug option. In ant use javac debug="true" debuglevel="lines,vars, source" and if you are compiling directily use option javac -g:lines,vars, source
Note :
If you do not get the actual parameter name even after compiling the interface with debug on, try converting the interface with abstract class


StumbleUponDigg This!Bookmark on Delicious

Add as favourites (490) | Quote this article on your site | Views: 3679 | E-mail

Be first to comment this article
RSS comments

Only registered users can write comments.
Please login or register.

Last Updated ( Monday, 09 May 2011 )
 
< Prev   Next >
Aminur Rashid