java 如何使用 Maven 构建 WSDL
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15499409/
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
How to build a WSDL using Maven
提问by Robert H
I'm looking to replace a supplied Ant build with Maven. I know of (but haven't used) ant run, and I'd prefer not too.
我希望用 Maven 替换提供的 Ant 构建。我知道(但没有使用过)ant run,我也不想。
To make a long story short, NetSuite provides a wsdl to use when making web service calls againsts its ERP offering and I currently use their provided ant build to generate the proxy classes from from the wsdl. (sample apps, wsdl and patched axis available here)
长话短说,NetSuite 提供了一个 wsdl,用于在针对其 ERP 产品进行 Web 服务调用时使用,我目前使用他们提供的 ant 构建从 wsdl 生成代理类。(此处提供示例应用程序、wsdl 和修补轴)
The problem I have is that the ant task uses a patched axis 1.4 (and supporting libraries, several of which are ~7 years old ) and I'd like to implement this wsdl using libraries that are readily available from a central maven repo, and preferably current.
我遇到的问题是 ant 任务使用修补过的 1.4 轴(和支持库,其中有几个大约有 7 年的历史),我想使用可从中央 maven 存储库轻松获得的库来实现此 wsdl,并且最好是当前的。
Can anyone point me where I need to research a solution that will work?
任何人都可以指出我需要研究可行的解决方案的地方吗?
For any who need to know: I've attempted generating with axis2 and it throws the following exception:
对于任何需要知道的人:我尝试使用axis2生成并抛出以下异常:
timeException: Element QName is null for ExceededRequestSizeFault!
at org.apache.axis2.wsdl.codegen.CodeGenerationEngine.generate(CodeGenerationEngine.java:293)
at org.apache.axis2.wsdl.WSDL2Code.main(WSDL2Code.java:35)
at org.apache.axis2.wsdl.WSDL2Java.main(WSDL2Java.java:24)
Caused by: org.apache.axis2.wsdl.codegen.CodeGenerationException: java.lang.RuntimeException: Element QName is null for ExceededRequestSizeFault!
at org.apache.axis2.wsdl.codegen.emitter.AxisServiceBasedMultiLanguageEmitter.emitSkeleton(AxisServiceBasedMultiLanguageEmitter.java:1451)
at org.apache.axis2.wsdl.codegen.CodeGenerationEngine.generate(CodeGenerationEngine.java:275)
... 2 more
Caused by: java.lang.RuntimeException: Element QName is null for ExceededRequestSizeFault!
at org.apache.axis2.wsdl.codegen.emitter.AxisServiceBasedMultiLanguageEmitter.getFaultParamElements(AxisServiceBasedMultiLanguageEmitter.java:
2925)
at org.apache.axis2.wsdl.codegen.emitter.AxisServiceBasedMultiLanguageEmitter.getFaultElement(AxisServiceBasedMultiLanguageEmitter.java:2844)
at org.apache.axis2.wsdl.codegen.emitter.AxisServiceBasedMultiLanguageEmitter.generateMethodElement(AxisServiceBasedMultiLanguageEmitter.java:
2366)
at org.apache.axis2.wsdl.codegen.emitter.AxisServiceBasedMultiLanguageEmitter.loadOperations(AxisServiceBasedMultiLanguageEmitter.java:2242)
at org.apache.axis2.wsdl.codegen.emitter.AxisServiceBasedMultiLanguageEmitter.createDOMDocumentForSkeleton(AxisServiceBasedMultiLanguageEmitte
r.java:2156)
at org.apache.axis2.wsdl.codegen.emitter.AxisServiceBasedMultiLanguageEmitter.writeSkeleton(AxisServiceBasedMultiLanguageEmitter.java:2082)
at org.apache.axis2.wsdl.codegen.emitter.AxisServiceBasedMultiLanguageEmitter.emitSkeleton(AxisServiceBasedMultiLanguageEmitter.java:1408)
... 3 more
Bonus points if its a tested solution with a recent NetSuite WSDL.
如果它是经过测试的具有最新 NetSuite WSDL 的解决方案,则会加分。
回答by ben75
I suggest you the cxf maven plugin. I did a small test with this wsdland it generate and compile successfully (JVM 1.7) 1408 source files. (be patient, it takes a while...)
我建议你使用cxf maven 插件。我用这个 wsdl做了一个小测试,它生成并成功编译 (JVM 1.7) 1408 源文件。(请耐心等待,这需要一段时间......)
I only get few warnings about max enum size reached. And so I had to pass a binding file to allow bigger enums. I did it through a binding file. Thanks to this post
我只收到一些关于达到最大枚举大小的警告。所以我不得不传递一个绑定文件以允许更大的枚举。我是通过绑定文件完成的。感谢这篇文章
Here is the required bind.xml
file
这是所需的bind.xml
文件
<jaxb:bindings xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
jaxb:version="2.0">
<jaxb:bindings >
<jaxb:globalBindings typesafeEnumMaxMembers="2000"/>
</jaxb:bindings>
</jaxb:bindings>
And the relevant part of the pom.xml
(as you can see: wsdl and bind.xml are in /src/main/resources
)
和相关部分pom.xml
(如您所见:wsdl 和 bind.xml 在/src/main/resources
)
<build>
<plugins>
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>2.7.3</version>
<executions>
<execution>
<id>generate-sources</id>
<phase>generate-sources</phase>
<configuration>
<sourceRoot>${project.build.directory}/generated/cxf</sourceRoot>
<wsdlOptions>
<wsdlOption>
<bindingFiles>
<bindingFile>${basedir}/src/main/resources/bind.xml</bindingFile>
</bindingFiles>
<wsdl>
${basedir}/src/main/resources/netsuite.wsdl
</wsdl>
</wsdlOption>
</wsdlOptions>
</configuration>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>