You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Tom Höfte <to...@gmail.com> on 2006/07/17 11:47:17 UTC

How to map namespaces to package names

Hi,

I'm using Axis 1.2 for while now in my project. However I want to migrate to
Axis2.0 in the near future, but I still have one open issue on
generating the client code for Axis2.0 using the ant-task. Int the WSDL2Java
task in Axis 1.2 you are able to specify mappings between the namespaces in
the WSDL and the Java package names. I cannot find this option in de codegen
task in Axis2.0 and also not in the argument list of the  WSDL2Java tool..

So I want to know if and how I can specify mappings between namespaces and
the Java package names during the generation of the client-code for a WSDL
in AXIS2.0

Thanks in advance!

-Tom

-- 
--Keep the faith in all the things you think you can't do--

RE: How to map namespaces to package names

Posted by Derek <de...@crc-corp.com>.
Tom:
 
I spent quite a while fighting this one. I had serious problems in trying to
specify the namespace2package options on the command line, so I was forced
to use a properties file.
 
After finally having had to trace through the source code to WSDL2Java,
here's what I came up with:
 
  <!--
   This macro is for creating Java code from a WSDL description.
   "binding" is the name of the skeleton SOAP binding that will be generated
   "package" is the name of the package that classes will be generated into
   "path" is the directory that the classes will be generated into
   "wsdl" is the path to the WSDL file that will be parsed.
   -->
   <macrodef name="generateJavaFromWSDL">
      <attribute name="binding"/>
      <attribute name="package"/>
      <attribute name="path"/>
      <attribute name="wsdl"/>
      <sequential>
         <!-- Delete some files that will be generated, since WSDL2Java
refuses to overwrite them -->
         <delete
file="@{path}/src/crc/@{package}/wsdl2java/@{binding}SkeletonInterface.java"
failonerror="false"/>
         <delete
file="@{path}/src/crc/@{package}/wsdl2java/@{binding}MessageReceiverInOut.ja
va" failonerror="false"/>
         <delete
file="@{path}/src/crc/@{package}/wsdl2java/@{binding}CallbackHandler.java"
failonerror="false"/>
         <delete
file="@{path}/src/crc/@{package}/wsdl2java/@{binding}Stub.java"
failonerror="false"/>
         <delete
file="@{path}/src/crc/@{package}/wsdl2java/@{binding}Skeleton.java"
failonerror="false"/>

         <property name="tempFile"
value="${env.TEMP}/Namespace2PackageMap.properties"/>
         <echo file="${tempFile}">
http\://www.crc-corp.com/wsdl/2004-10-01/cars=com.mycompany.package1
http\://www.w3.org/2004/06/xmlmime=com.mycompany.package2
         </echo>
         <!-- Consult
http://ws.apache.org/axis2/tools/1_0/CodegenToolReference.html for details
on the following -->
         <java classname="org.apache.axis2.wsdl.WSDL2Java" fork="true"
failonerror="true">
            <classpath refid="axis.classpath"/>
            <arg value="--databinding-method"/>
            <arg value="xmlbeans"/>
            <arg value="--uri"/>
            <arg value="@{wsdl}"/>
            <arg value="--server-side"/>
            <arg value="--generate-all"/>
            <arg value="--service-description"/>
            <arg value="--output"/>
            <arg value="@{path}"/>
            <arg value="--package"/>
            <arg value="crc.@{package}.wsdl2java"/
<mailto:crc.@{package}.wsdl2java> >
            <arg value="--namespace2package"/>
            <arg value="${tempFile}"/>
         </java>
         <!-- Delete the skeleton file that was generated, since I have a
modified version in a different source tree included in my source path -->
         <delete
file="@{path}/src/crc/@{package}/wsdl2java/@{binding}Skeleton.java"/>
      </sequential>
   </macrodef>

Note that a backslash is needed after http, since the colon is considered a
separator in a property file.
 
Also note that the ability to specify a properties file like this is
undocumented as far as I can tell.
 
Derek 

-----Original Message-----
From: Tom Höfte [mailto:tomhofte@gmail.com] 
Sent: Monday, July 17, 2006 2:47 AM
To: axis-user@ws.apache.org
Subject: How to map namespaces to package names


Hi,
 
I'm using Axis 1.2 for while now in my project. However I want to migrate to
Axis2.0 in the near future, but I still have one open issue on generating
the client code for Axis2.0 using the ant-task. Int the WSDL2Java task in
Axis 1.2 you are able to specify mappings between the namespaces in the WSDL
and the Java package names. I cannot find this option in de codegen task in
Axis2.0 and also not in the argument list of the  WSDL2Java tool..
 
So I want to know if and how I can specify mappings between namespaces and
the Java package names during the generation of the client-code for a WSDL
in AXIS2.0
 
Thanks in advance!
 
-Tom 

-- 
--Keep the faith in all the things you think you can't do--