2

I have a problem when generating java classes from WSDL using JAX-RPC wscompile ANT task.

My ant script:

<taskdef name="wscompile" classname="com.sun.xml.rpc.tools.ant.Wscompile" classpathref="jaxrpc.classpath"/>
<taskdef name="wsdeploy" classname="com.sun.xml.rpc.tools.ant.Wsdeploy" classpathref="jaxrpc.classpath"/>
<wscompile
        fork="true"
        base="${target.jaxrpc.dir}"
        server="true"
        client="false"
        features="documentliteral"
        model="${target.jaxrpc.dir}/model.xml.gz"
        debug="true"
        keep="true"
        verbose="true"
        config="${src.main.config.dir}/jaxrpc-service-config.xml">
    <classpath refid="jaxrpc.classpath"/>
</wscompile>

In my wsdl there is Date type objects, the problem is that JAX-RPC generates Calendar objects. Is there a way to set some flag or somehow to force JAX-RPC to generate Date objects?

Paulius Matulionis
  • 23,085
  • 22
  • 103
  • 143

1 Answers1

1

This is because the Enterprise Web Services 1.1 specification defines the default mapping between Java classes and XML types.However you can change the default mapping for your application.You can change the mapping by editing the contents of the element JAX-RPC mapping file. In your case you have to do following changes:

    <java-wsdl-mapping>
      ...
       <java-xml-type-mapping>
       <java-type>java.util.Date</java-type>
      <root-type-qname xmlns:qn="http://www.w3c.org/2001/XMLSchema">qn:dateTime</root-type-qname>
     </java-xml-type-mapping>
      ...
    <java-wsdl-mapping>
Rupeshit
  • 1,476
  • 1
  • 14
  • 23
  • Thanks. But I can not figure out where I have to specify this file? ... mapping="${src.main.config.dir}/jaxrpc-mapping- ... I put it into my task, but into this file, task writes all objects from wsdl. It overides it and my changes does not take affect. – Paulius Matulionis Jan 17 '12 at 09:00
  • Just go through this http://docs.oracle.com/cd/B32110_01/web.1013/b28975/appjaxrpcmapping.htm#CEGEEAIJ here is all the details – Rupeshit Jan 17 '12 at 09:10