[jboss-user] [JBossWS] - Re: How to generate mapping.xml & webservices.xml from WSDL?

docampbell do-not-reply at jboss.com
Tue Sep 12 07:10:30 EDT 2006


Hi,

You can generate the mapping using the "wstools" tool (!), which takes a configuration file to tell it what to do.  Here is an example of a configuration file (one I am using for testing at the moment, so excuse some of the hard coded stuff):


  | <?xml version="1.0" encoding="UTF-8"?>
  | <configuration xmlns="http://java.sun.com/xml/ns/jax-rpc/ri/config">
  | 
  | <global>
  | 	<package-namespace package="itag.wswg.rm.services.ss" namespace="http://itag.wswg.rm"/>
  | </global>
  | 
  | <wsdl-java file="C:/AllStuff/eclipse/jbossWorkspace/webby/resources/WSDL/SequenceService.wsdl">
  |     <mapping file="itag/wswg/rm/SequenceService-mapping.xml" /> 
  | </wsdl-java>
  | </configuration>
  | 

This will take a WSDL file and create the necessary Java classes using the package specified in the "global" section, together with the mapping file as specified.

I do not know if you can generate the webservices.xml file, I just have a template and copy/tailor that to suit, same for the web.xml file.

I call wstools using an ant script, which is shown below (I have copied it directly, as I don't have too much time to edit it - sorry !):


  | <project name="wsWSDLbuild" default="buildAll">
  | 
  | 	<!-- Use some fixed properties that will depend on the installation -->
  | 	<property file="genFromWSDL.properties"/>
  | 
  | 	<!--
  | 		 Required files to run wstools properly (list taken from wstools.sh supplied with the
  | 		 JBoss installation and those not absolutely required (found by trial-and-error) have
  | 		 been removed (I like to know what is really needed, rather than blindly putting every
  | 		 jar in the world here)
  | 	-->
  | 	<path id="jboss.wstools">
  | 		<fileset dir="${jboss.root}/client">
  | 			<include name="activation.jar"/>
  | 			<include name="javassist.jar"/>
  | 			<include name="jbossall-client.jar"/>
  | 			<include name="jbossretro-rt.jar"/>
  | 			<include name="jboss-backport-concurrent.jar"/>
  | 			<include name="jbossws-client.jar"/>
  | 			<include name="mail.jar"/>
  | 		</fileset>
  | 		<fileset dir="${jboss.root}/lib/endorsed">
  | 			<include name="xercesImpl.jar"/>
  | 		</fileset>
  | 	</path>
  | 
  | 	<!--
  | 		 Make up a path for wstools that also includes this projects's class
  | 	     base directory (only the base directory is needed or the files will
  | 	     not be found)
  | 	 -->
  | 	<path id="jboss.wstools.plus.project">
  | 		<path refid="jboss.wstools"/>
  | 		<pathelement path="${class.dir}"/>
  | 	</path>
  | 
  | 	<!--
  | 		 Set up the class file for wstools and ensure that the task will have the
  | 		 correct classpath that includes both the wstools required files and also
  | 		 the class files from this project
  | 	-->
  | 	<taskdef name="wstools" classname="org.jboss.ws.tools.ant.wstools">
  | 		<classpath refid="jboss.wstools.plus.project"/>
  | 	</taskdef>
  | 
  | 	<!--
  | 		 Build SequenceService
  | 	-->
  | 	<target name="buildSequenceService">
  | 		<echo message="SequenceService"/>
  | 		<wstools dest="${generated.WSDL.output}"
  | 		         config="${config.dir}/SequenceServiceWSDLconfig.xml"
  | 				 verbose="true"/>
  | 		<echo message="Done SequenceService"/>
  | 	</target>
  | 
  | 	<!--
  | 		 Build TestingService
  | 	-->
  | 	<target name="buildTestingService">
  | 		<echo message="TestingService"/>
  | 		<wstools dest="${generated.WSDL.output}"
  | 		         config="${config.dir}/TestingServiceWSDLconfig.xml"
  | 				 verbose="true"/>
  | 		<echo message="Done TestingService"/>
  | 	</target>
  | 
  | 	<!--
  | 		 Run wstools on the specified configuration file and generate all the necessary
  | 		 artefacts as specified in that file
  | 	-->
  | 	<target name="buildAll" depends="buildSequenceService,buildTestingService">
  | 		<echo message="Built both"/>
  | 	</target>
  | </project>
  | 

The properties file just contains some common property values:


  | # Where jboss is installed
  | #
  | jboss.root=C:/AllProgs/jboss-4.0.4.GA
  | 
  | # Lots of information about the project and the various required locations for classes
  | # and configuration files etc.
  | #
  | eclipse.root=C:/AllStuff/eclipse/jbossWorkspace
  | project.name=webby
  | project.root=${eclipse.root}/${project.name}
  | class.dir=${project.root}/bin
  | config.dir=${project.root}/resources/wsbuild
  |  
  | # Directory the generated code should be based from
  | #
  | generated.output=${project.root}/gensrc
  | generated.WSDL.output=${project.root}/genWSDLsrc
  | 

I run all this from within Eclipse, but it should all run from the command line or whatever.


Hope this is of some help.

Cheers,

Dominic.

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3970972#3970972

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3970972



More information about the jboss-user mailing list