Java Maven cxf-codegen-plugin 并在 wsdl 中导入
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21517275/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Maven cxf-codegen-plugin and import in wsdl
提问by BlueLettuce16
I'm trying to generate webservice classes from wsdl file using apache cxf-codegen-pluginfrom maven. My wsdl file imports xsd like below using
我正在尝试使用maven 中的apache cxf-codegen-plugin从wsdl 文件生成 webservice 类。我的 wsdl 文件使用如下方式导入 xsd
<xs:import namespace="http://my.ns.com/privateperson" schemaLocation="../xsd/PrivatePerson.xsd"/>
and in pom.xml I have:
在 pom.xml 我有:
<wsdlOption>
<extraargs>
<extraarg>-catalog ${basedir}/src/main/resources/xsd/PrivatePerson.xsd</extraarg>
<extraarg>-server</extraarg>
</extraargs>
...
</wsdlOptions>
However when I run cxf-codegen-plugin I get the following error:
但是,当我运行 cxf-codegen-plugin 时,出现以下错误:
wsdl2java failed: org.apache.cxf.tools.common.toolspec.parser.BadUsageException: Unexpected option: -catalog valid/path/to/xsd/file/privateperson.xsd
Is there something wrong with my configuration? When I don't include external xsd file everything works fine.
我的配置有问题吗?当我不包含外部 xsd 文件时,一切正常。
I used catalog as it is described here: http://cxf.apache.org/docs/wsdl-to-java.html
我使用了此处描述的目录:http: //cxf.apache.org/docs/wsdl-to-java.html
I have also run maven with -e:
我也用 -e 运行了 maven:
[ERROR] Failed to execute goal org.apache.cxf:cxf-codegen-plugin:3.0.0-milestone1:wsdl2java (generate-sources) on project Services: unresolved reference -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.cxf:cxf-codegen-plugin:3.0.0-milestone1:wsdl2java (generate-sources) on project Services: unresolved reference
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:216)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:317)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:152)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:555)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:214)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:158)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
at org.codehaus.classworlds.Launcher.main(Launcher.java:46)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
Caused by: org.apache.maven.plugin.MojoExecutionException: unresolved reference
at org.apache.cxf.maven_plugin.wsdl2java.WSDL2JavaMojo.generate(WSDL2JavaMojo.java:447)
at org.apache.cxf.maven_plugin.AbstractCodegenMoho.execute(AbstractCodegenMoho.java:311)
at org.apache.cxf.maven_plugin.wsdl2java.WSDL2JavaMojo.execute(WSDL2JavaMojo.java:524)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:106)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
... 25 more
Caused by: java.lang.InternalError: unresolved reference
at com.sun.xml.xsom.impl.parser.DelayedRef._get(DelayedRef.java:103)
at com.sun.xml.xsom.impl.parser.DelayedRef$Type.getType(DelayedRef.java:148)
at com.sun.xml.xsom.impl.ElementDecl.getType(ElementDecl.java:110)
at com.sun.xml.xsom.impl.ElementDecl.updateSubstitutabilityMap(ElementDecl.java:174)
at com.sun.xml.xsom.impl.parser.ParserContext.getResult(ParserContext.java:141)
at com.sun.xml.xsom.parser.XSOMParser.getResult(XSOMParser.java:211)
at com.sun.tools.xjc.ModelLoader.createXSOM(ModelLoader.java:538)
at com.sun.tools.xjc.api.impl.s2j.SchemaCompilerImpl.bind(SchemaCompilerImpl.java:269)
at com.sun.tools.xjc.api.impl.s2j.SchemaCompilerImpl.bind(SchemaCompilerImpl.java:95)
at org.apache.cxf.tools.wsdlto.databinding.jaxb.JAXBDataBinding.initialize(JAXBDataBinding.java:460)
at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.generateTypes(WSDLToJavaContainer.java:714)
at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.processWsdl(WSDLToJavaContainer.java:270)
at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.execute(WSDLToJavaContainer.java:164)
at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.execute(WSDLToJavaContainer.java:412)
at org.apache.cxf.tools.common.toolspec.ToolRunner.runTool(ToolRunner.java:103)
at org.apache.cxf.tools.wsdlto.WSDLToJava.run(WSDLToJava.java:113)
at org.apache.cxf.tools.wsdlto.WSDLToJava.run(WSDLToJava.java:86)
at org.apache.cxf.maven_plugin.wsdl2java.WSDL2JavaMojo.generate(WSDL2JavaMojo.java:427)
... 29 more
采纳答案by BlueLettuce16
Ok, I've solved my issue - in wsdl I have placed
好的,我已经解决了我的问题 - 在 wsdl 中我已经放置了
<xs:import ... />
in wrong place. It was before
在错误的地方。以前是
<wsdl:types>
element.
元素。
回答by Tanveer Ali
Try the following tag and check if it works
尝试以下标签并检查它是否有效
<wsdlOptions>
<wsdlOption>
<wsdl>${basedir}/<file-path></wsdl>
</wsdlOption>
</wsdlOptions>
also check which version of cxf plugin you are using. Try to use the latest one.
还要检查您使用的是哪个版本的 cxf 插件。尝试使用最新的。
Let me know if its still giving error
让我知道它是否仍然给出错误
回答by Donal Fellows
Each of the extra arguments must be on its own; you tried to pass two in one, and that won't work because of the care the plugin takes to quote things correctly for you (or to pass each argument as a separate element of the argument array, depending on whether it execs under the covers or not).
每个额外的参数都必须单独存在;您试图将二合一传递,但这将不起作用,因为插件会小心地为您正确引用内容(或将每个参数作为参数数组的单独元素传递,具体取决于它是否在幕后执行)或不)。
You want this:
你要这个:
<wsdlOption>
<extraargs>
<extraarg>-catalog</extraarg>
<extraarg>${basedir}/src/main/resources/xsd/PrivatePerson.xsd</extraarg>
<extraarg>-server</extraarg>
</extraargs>
...
</wsdlOptions>
(Be aware that getting catalogs right can take experimentation; the logging of failures in XML catalog lookups is… virtually non-existent.)
(请注意,正确获取目录可能需要进行实验;XML 目录查找中的失败日志……几乎不存在。)