To prepare to use Ant targets to deploy a web service on the Tomcat Web Server:
To create the web service or client files:
<target name="-pre-init"> <property name="j2ee.platform.wscompile.classpath" value="${libs.jaxrpc16.classpath}"/> </target>
To write Ant targets to deploy a web service on the Tomcat Web Server:
<target name="-pre-init"> <property name="j2ee.platform.wscompile.classpath" value="${libs.jaxrpc16.classpath}"/> <property name="tomcat.home" value="full_path_to_$NB_USER_DIR/5.0/apache-tomcat-5.5.17_base"/> </target>
The apache-tomcat-5.5.17_base folder is created only once the Tomcat Web Server has been started.
<target name="run-deploy" depends="init,compile,compile-jsps,-do-compile-single-jsp,dist"> <property name="raw.war.name" value="${dist.dir}/raw-${war.name}"/> <copy file="${dist.war}" tofile="${raw.war.name}"/> <delete file="${dist.war}"/> <taskdef name="wsdeploy" classname="com.sun.xml.rpc.tools.ant.Wsdeploy" classpath="${wscompile.classpath}"/> <wsdeploy inWarFile="${raw.war.name}" outWarFile="${dist.war}" fork="true" classpath="${wscompile.classpath}:${build.classes.dir.real}:${javac.classpath}" keep="true" verbose="true" source="1.1.2"/> <delete file="${raw.war.name}"/> <copy file="${dist.war}" todir="${tomcat.home}/webapps"/> </target>
<target name="run-display-browser" if="do.display.browser" depends="run-deploy"> <nbbrowse url="http://my-host:my-port-number/${ant.project.name}/${client.urlPart}"/> </target>
Create an XML document in the WEB-INF folder. Call the XML document jaxrpc-ri. Add this content to jaxrpc-ri.xml and change mypackage.mysubpackage.myclassSEI to the fully qualified name of the SEI class and mypackage.mysubpackage.myclassImpl to the fully qualified name of the implementation class:
<?xml version="1.0" encoding="UTF-8"?> <webServices xmlns="http://java.sun.com/xml/ns/jax-rpc/ri/dd" version="1.0" targetNamespaceBase="http://java.sun.com/xml/ns/jax-rpc/wsi/wsdl" typeNamespaceBase="http://java.sun.com/xml/ns/jax-rpc/wsi/types" urlPatternBase="/webservice"> <endpoint name="MyTomcatWS" displayName="TomcatService" description="Tomcat Web Service endpoint" interface="mypackage.mysubpackage.myclassSEI" implementation="mypackage.mysubpackage.myclassImpl"/> <endpointMapping endpointName="MyTomcatWS" urlPattern="/MyTomcatWS"/> </webServices>
Now right-click the project node, choose Properties, select the Run pane, and type MyTomcatWS in Relative URL.
To deploy a web service or web service client on the Tomcat Web Server: