Java2WDSL & WSDL2Java - java.util.Date not handled consistently

Java2WSDL and WSDL2Java tools in Axis (1.4) are pretty handy tools. Those help you to generate a WSDL from a java class as well as generatin...

Java2WSDL and WSDL2Java tools in Axis (1.4) are pretty handy tools. Those help you to generate a WSDL from a java class as well as generating stubs/skeletons from a WSDL. But if you are dealing with java.util.Date fields in your code, you must pay some attention.


Consider the following java interface which uses java.util.Date as a return type as well as a method parameter.
public interface MyService {
    public java.util.Date getNextDate();
    public void updateLastRun(java.util.Date date);
When the Java2WDSL tool generates a WSDL for a class with a Date field, it will represent java.util.Date fields as dateTime fields in WSDL. The generated WSDL file would look as follows.
<?xml version="1.0" encoding="UTF-8" ?>
<wsdl:definitions targetNamespace="http://service"
        xmlns:impl="http://service" xmlns:intf="http://service"
 <!--WSDL created by Apache Axis version: 1.4-->
    <wsdl:message name="setOpeningDateResponse">
    <wsdl:message name="setOpeningDateRequest">
        <wsdl:part name="in0" type="xsd:dateTime" />
    <wsdl:message name="getOpenningDateResponse">
        <wsdl:part name="getOpenningDateReturn" type="xsd:dateTime" />
    <wsdl:message name="getOpenningDateRequest">
    <!--rest of the content removed-->
I have posted only a part of the WSDL which contains the messages. If you go through the above WSDL, you will see that both java.util.Date fields are represented as "dateTime" fields (type="xsd:dateTime").


Now we can generate the Java classes using our WSDL file. WSDL2Java tool will use the WSDL file and generate a set of classes for us. Following is the generated MyService class.
package service;

public interface MyService extends java.rmi.Remote {
    public java.util.Calendar getOpenningDate() 
                                 throws java.rmi.RemoteException;
    public void setOpeningDate(java.util.Calendar in0) 
                                 throws java.rmi.RemoteException;
See the difference? The generated MyService interface has java.util.Calendar fields instead of java.util.Date.

Since your binding implementation class implements this new interface, you will have some hard time in dealing with this data type changes. May be there's a quick fix which we don't see from here.

We tried this on Axis1.4 and did not try with Axis2.





About,2,Adsense,3,Ant,1,Apache,3,Axis,3,Blogger,1,Books,1,CentOS,2,Chrome,2,CSS,2,Database,3,Earn Online,3,Eclipse,10,Facebook,1,Firefox,10,Gmail,4,GNU/Linux,9,Google,26,GWT,8,Hardware,2,IE,5,Interesting,15,Internet,14,Java,49,Javascript,7,JBoss,1,Jenkins,1,Log4j,2,Me,6,Microsoft,2,Miscellaneous,1,News,11,Opinion,10,OSGi,1,PHP,1,Productivity,3,Programming,36,Puzzle,3,Security,4,Software,41,Sports,9,Spring,2,Story,6,Subversion,3,TDD,4,Tech,2,Tips,1,Tomcat,6,Tutorial,13,Ubuntu,4,Web application,14,Web Design,2,Web services,3,Windows,10,Yahoo,1,Zip,2,
Digizol: Java2WDSL & WSDL2Java - java.util.Date not handled consistently
Java2WDSL & WSDL2Java - java.util.Date not handled consistently
Loaded All Posts Not found any posts VIEW ALL Readmore Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU LABEL ARCHIVE SEARCH ALL POSTS Not found any post match with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS CONTENT IS PREMIUM Please share to unlock Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy