我有一个简单的ant脚本来从sdl构建我的类。不幸的是,wimport立即失败。我怀疑这与类路径有关。
<taskdef name="wsimport" classname="com.sun.tools.ws.ant.WsImport">
<classpath>
<pathelement location="${jaxws.lib.dir}/jaxws-tools.jar" />
</classpath>
</taskdef>
<wsimport
wsdl="${project.wsdl.dir}some.wsdl"
destdir="${jaxws.output.dir}"
keep="false"
extension="true"
verbose="true"
wsdlLocation="http://localhost/wsdl"
target="2.1">
<depends file="${project.wsdl.dir}"/>
<produces dir="${jaxws.output.dir}"/>
</wsimport>
这是它产生的输出:
[wimport] 15 Mar 2013 12:23:25 PM com.sun.xml.bind.v2.util。XmlFactory createDocumentBuilderFactory[wsimport] SEVERE: null[wsimport] java.lang.AbstractMethodError: javax.xml.parsers.DocumentBuilderFactory.setFeature(Ljava/lang/String;Z[wsimport] at com.sun.xml.bind.v2.util.XmlFactory.createDocumentBuilderFactory(XmlFactory.java:176)[wimport]在com.sun.tools.xjc.reader.internalizer.DOMForest.(DOMForest.java:162)[wsimport] at com.sun.tools.xjc.api.impl.s2j.SchemaCompilerImpl.resetSchema(SchemaCompilerImpl.java:215)[wimport]在com.sun.tools.xjc.api.impl.s2j.SchemaCompilerImpl.(SchemaCompilerImpl.java:114)[wimport]在com.sun.tools.xjc.api. xjc. createschemaccompiler (XJC.java:72)[wsimportoptions . com.sun.tools.ws.wscompile.WsimportOptions. java:152][wsimporttool] .(WsimportTool.java:89)[wsimporttool] .(WsimportTool.java:92)[WsImport2.java:848][wimport] at com.sun.istack.tools.ProtectedTask.execute(ProtectedTask.java:103)[wimport] at org.apache.tools.ant. unknowelement .execute(unknowelement .java:269)[wimport] at org.apache.tools.ant.Task.perform(Task.java:364)[wimport] at org.apache.tools.ant.Target.execute(Target.java:301)[wimport] at org.apache.tools.ant.helper.ProjectHelper2.parse(ProjectHelper2.java:135)[wimport] at org.eclipse.ant.internal. launch.remote.internalantrunner . parsebuildfile (InternalAntRunner.java:192)[wimport] at org. eclipse.ant.internalantrunner .run(InternalAntRunner.java:401)[wimport] at org.eclipse.ant.internal. launch.remote . internalantrunner .main(InternalAntRunner.java:138)
如果我从jax-ws bin目录运行详细日志创建的命令行,在wimport上,一切正常
[wsimport] command line: wsimport -d C:DevelopmentSourceccsjaxws-output -extension -verbose -target 2.1 C:DevelopmentSourceccswsdlsome.wsdl -wsdllocation http://localhost/wsdl
我试着寻找一个解决方案,但现在我无计可施
我认为在您提到的方法(taskdef
和wsimport
)中使用的乏味的事情之一是添加环境变量,特别是当您想在web服务中使用SSL和基本身份验证时。另一方面,您可以使用wsimport
工具而无需定义新任务。像这样:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE project>
<project name="generate-client" default="main" basedir=".">
<property name="java.home"
value="X:Softwarejdk1.7.0_11" />
<property name="wsdl.location"
value="http://localhost/wsdl" />
<target name="main">
<exec executable="${java.home}binwsimport.exe">
<arg line="${wsdl.location} -s src -Xdebug -verbose -Xnocompile" />
</exec>
</target>
</project>
现在您有了一个想法,您可以自定义输出目录,添加目标版本…