Tớ gặp lỗi này khi ant build để gen skeleton/stub file của web service từ eclipse
Problem: failed to create task or type axis-java2wsdl
Cause: The name is undefined.
Action: Check the spelling.
Action: Check that any custom tasks/types have been declared.
Action: Check that any <presetdef>/<macrodef> declarations have taken place.
Bạn nào có kinh nghiệm thì chỉ dùm nhé,mình cũng mới học :ym_blushing:
hoặc chỉ mình cách gen skeleton/stub file bằng cách nhanh nhất có thể
Dưới đây là nội dụng file build.xml
Code:
<?xml version="1.0"?>
<project name="Axis-Soap Stub/Skeleton generation" default="main" basedir=".">
<property name="webinf.home" value="${basedir}/Web Root/WEB-INF"/>
<property name="lib.home" value="${webinf.home}/lib"/>
<property name="generated.home" value="${basedir}/../soap_temp"/>
<property name="service.classes" value="${webinf.home}/classes"/>
<property name="persistence.classes" value="${basedir}/../PrimusPersistence/classes"/>
<property name="service.src.home" value="${basedir}/src"/>
<property name="service.src.dir" value="${basedir}/Java Source"/>
<!-- service endpoint stuff (used also for deployment) -->
<property name="target.port" value="8080"/>
<property name="target.server" value="localhost"/>
<property name="target.appname" value="primus"/>
<path id="axis.classpath">
<pathelement location="${lib.home}/axis-ant.jar"/>
<pathelement location="${lib.home}/axis.jar"/>
<pathelement location="${lib.home}/jaxrpc.jar"/>
<pathelement location="${lib.home}/wsdl4j.jar"/>
<pathelement location="${lib.home}/saaj.jar"/>
<pathelement location="${lib.home}/activation.jar"/>
<pathelement location="${lib.home}/mail.jar"/>
<pathelement location="${lib.home}/hibernate.jar"/>
<pathelement location="${lib.home}/log4j.jar"/>
<pathelement location="${lib.home}/commons-lang.jar"/>
<pathelement location="${lib.home}/commons-discovery.jar"/>
<pathelement location="${lib.home}/commons-beanutils.jar"/>
<pathelement location="${lib.home}/commons-collections.jar"/>
<pathelement location="${lib.home}/commons-logging.jar"/>
</path>
<fileset id="generated_files" dir="${generated.home}">
<include name="**/*Skeleton.java"/>
<include name="**/*Stub.java"/>
</fileset>
<fileset id="other_generated_files" dir="${generated.home}">
<include name="**/*ServiceLocator.java"/>
<include name="**/*Service.java"/>
<include name="**/*SoapBindingImpl.java"/>
</fileset>
<taskdef resource="axis-tasks.properties"
classpathref="axis.classpath" />
<target name="--init">
<echo message="location=${basedir}"/>
<echo message="lib=${lib.home}"/>
<mkdir dir="${generated.home}"/>
<mkdir dir="${service.src.dir}"/>
</target>
<target name="generate_wsdl" depends="--init"
description="Generates wsdl file for primus soap (needed only to create stub/skeleton).">
<axis-java2wsdl
typemappingversion="1.2"
implclass="com.routescape.primus.service.ceo.export.CEOExportImpl"
output="${generated.home}/ceoexport.wsdl"
classname="com.routescape.primus.service.ceo.export.CEOExport"
namespace="urnrimusWeb"
location="http://localhost:8080/primus/services/CEOExport"
>
<classpath>
<pathelement location="${service.classes}"/>
<pathelement location="${persistence.classes}"/>
</classpath>
</axis-java2wsdl>
</target>
<target name="generate_stubs" depends="--init"
description="Generates stub/skeletons for primus soap.">
<axis-wsdl2java
output="${generated.home}"
url="${generated.home}/ceoexport.wsdl"
all="true"
deployscope="session"
serverside="true"
skeletondeploy="true">
<classpath>
<pathelement location="${service.classes}"/>
</classpath>
<mapping
namespace="urnrimusWeb"
package="com.routescape.primus.service.ceo.export" />
</axis-wsdl2java>
</target>
<target name="copy_files" unless="copy_all">
<echo message="Copying only service skeleton/stub files (set copy_all property to copy everything)"/>
<echo message="NOTE: We do not use the Axis generated bean classes (only the stub/skeleton)." />
<copy failonerror="true" verbose="true" todir="${service.src.dir}" >
<fileset refid="generated_files"/>
</copy>
</target>
<target name="copy_all_files" if="copy_all">
<echo message="Copying all generated service files (except bean classes)"/>
<copy failonerror="true" verbose="true" todir="${service.src.dir}" >
<fileset refid="generated_files"/>
</copy>
<copy failonerror="true" verbose="true" todir="${service.src.dir}" >
<fileset refid="other_generated_files"/>
</copy>
</target>
<target name="--deploy_service">
<echo message="Deploying service to Axis Server..."/>
<echo message="-- If this fails, check to make sure the primus webapp "/>
<echo message="-- is running at the following location: http://${target.server}:${target.port}/${target.appname}"/>
<echo message=" "/>
<echo message="Contacting axis admin service to undeploy..."/>
<axis-admin
port="${target.port}"
hostname="${target.server}"
failonerror="false"
servletpath="${target.appname}/services/AdminService"
debug="true"
xmlfile="${generated.home}/com/routescape/primus/service/ceo/export/undeploy.wsdd"
/>
<echo message="Contacting axis admin service to deploy..."/>
<axis-admin
port="${target.port}"
hostname="${target.server}"
failonerror="true"
servletpath="${target.appname}/services/AdminService"
debug="true"
xmlfile="${generated.home}/com/routescape/primus/service/ceo/export/deploy.wsdd"
/>
</target>
<target name="--copy_server_config" >
<echo message="Copying axis server-config.wsdd to primus web-inf..." />
<echo message="-- Note, you should check in this file." />
<echo message=" "/>
<copy flatten="true" file="${tomcat.home}/webapps/primus/WEB-INF/server-config.wsdd" failonerror="true" verbose="true" todir="${webinf.home}" />
</target>
<target name="clean">
<delete dir="${generated.home}" />
</target>
<target name="main" depends="clean, --init, generate_wsdl, generate_stubs, copy_files, copy_all_files"
description="Generates Apache Axis SOAP stub/skeleton.">
</target>
<target name="deploy" depends="--init, --deploy_service, --copy_server_config"
description="Deploys the service and copies the server-config.wsdd back to primus WEB-INF.">
</target>
</project>