准备使用 Ant 目标以在 Tomcat Web Server 上部署 Web 服务:
创建 Web 服务或客户端文件:
<target name="-pre-init">
<property name="j2ee.platform.wscompile.classpath" value="${libs.jaxrpc16.classpath}"/>
</target>编写 Ant 目标以在 Tomcat Web Server 上部署 Web 服务:
<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>
仅当启动 Tomcat Web Server 后,才会创建 apache-tomcat-5.5.17_base 文件夹。
<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>
在 WEB-INF 文件夹中创建 XML 文档。将 XML 文档命名为 jaxrpc-ri。将以下内容添加到 jaxrpc-ri.xml 中,并将 mypackage.mysubpackage.myclassSEI 更改为 SEI 类的全限定名称,将 mypackage.mysubpackage.myclassImpl 更改为实现类的全限定名称:
<?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>
现在,右键单击项目节点,选择“属性”,选择“运行”窗格,然后在“相对 URL”中键入 MyTomcatWS。
在 Tomcat Web Server 上部署 Web 服务或 Web 服务客户端: