简体   繁体   English

Apache CXF插件 - 生成客户端失败

[英]Apache CXF Plugin - Failure Generating Client

I am trying to generate a webservice client using the Apache CXF Maven plugin but I am running into errors. 我正在尝试使用Apache CXF Maven插件生成一个Web服务客户端,但我遇到了错误。 I just have a very simple maven project setup in eclipse The wsdl file is located here - http://api.zenfolio.com/api/1.8/zfapi.asmx?wsdl 我在eclipse中只有一个非常简单的maven项目设置wsdl文件位于此处 - http://api.zenfolio.com/api/1.8/zfapi.asmx?wsdl

The pom file I am using is as follows 我正在使用的pom文件如下

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.test</groupId>
<artifactId>WebserviceClientGenerator</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
    <cxf.plugin.version>3.1.4</cxf.plugin.version>
</properties>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-codegen-plugin</artifactId>
            <version>${cxf.plugin.version}</version>
            <executions>
                <execution>
                    <id>generate-sources</id>
                    <phase>generate-sources</phase>
                    <configuration>
                        <sourceRoot>${project.build.directory}/src/main/java/com/test</sourceRoot>
                        <wsdlOptions>
                            <wsdlOption>
                                <wsdl>http://api.zenfolio.com/api/1.8/zfapi.asmx?wsdl</wsdl> 
                                <extraargs>
                                    <extraarg>-impl</extraarg>
                                    <extraarg>-verbose</extraarg>
                                </extraargs>
                            </wsdlOption>
                        </wsdlOptions>                          
                    </configuration>
                    <goals>
                        <goal>wsdl2java</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

When I run a maven install on this pom file, I get the following error 当我在这个pom文件上运行maven安装时,我收到以下错误

    [ERROR] http://api.zenfolio.com/api/1.8/zfapi.asmx?wsdl [1559:11]: undefined simple or complex type 'soapenc:Array'
org.xml.sax.SAXParseExceptionpublicId: http://api.zenfolio.com/api/1.8/zfapi.asmx?wsdl; systemId: http://api.zenfolio.com/api/1.8/zfapi.asmx?wsdl; lineNumber: 1559; columnNumber: 11; undefined simple or complex type 'soapenc:Array'
    at com.sun.xml.xsom.impl.parser.ParserContext$1.reportError(ParserContext.java:180)
    at com.sun.xml.xsom.impl.parser.NGCCRuntimeEx.reportError(NGCCRuntimeEx.java:175)
    at com.sun.xml.xsom.impl.parser.DelayedRef.resolve(DelayedRef.java:110)
    at com.sun.xml.xsom.impl.parser.DelayedRef.run(DelayedRef.java:85)
    at com.sun.xml.xsom.impl.parser.ParserContext.getResult(ParserContext.java:135)
    at com.sun.xml.xsom.parser.XSOMParser.getResult(XSOMParser.java:214)
    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:726)
    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:415)
    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:415)
    at org.apache.cxf.maven_plugin.AbstractCodegenMoho.execute(AbstractCodegenMoho.java:260)
    at org.apache.cxf.maven_plugin.wsdl2java.WSDL2JavaMojo.execute(WSDL2JavaMojo.java:512)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
    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:116)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:862)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:286)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:197)

Does anyone know if there is any configuration I make with the cxf plugin to get this working? 有没有人知道我使用cxf插件进行的任何配置是否有效?

Unfortunately, the WSDL uses a SOAP encoding, which is not supported by Apache CXF (or any current technology for that matter). 遗憾的是,WSDL使用SOAP编码,Apache CXF(或任何当前技术)不支持该编码。

You have to rely on old SOAP stack, like Axis 1.x, that are the only one to handle such obsolete encoding. 您必须依赖像Axis 1.x这样的旧SOAP堆栈,它们是唯一能够处理这种过时编码的堆栈。 Using the axistools-maven-plugin and Axis 1.4, you can generate a client stub for the WSDL: 使用axistools-maven-plugin和Axis 1.4,您可以为WSDL生成客户端存根:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>axistools-maven-plugin</artifactId>
    <version>1.4</version>
    <executions>
        <execution>
            <id>generate-client</id>
            <phase>generate-sources</phase>
            <goals>
                <goal>wsdl2java</goal>
            </goals>
            <configuration>
                <urls>
                    <url>http://api.zenfolio.com/api/1.8/zfapi.asmx?wsdl</url>
                </urls>
            </configuration>
        </execution>
    </executions>
</plugin>

Then you need to add Axis 1.4 as a compile-time dependency: 然后,您需要将Axis 1.4添加为编译时依赖项:

<dependency>
    <groupId>axis</groupId>
    <artifactId>axis</artifactId>
    <version>1.4</version>
</dependency>

The generated client will be located in target/generated-sources/axistools/wsdl2java by default, but you can override that with the outputDirectory configuration element. 默认情况下,生成的客户端将位于target/generated-sources/axistools/wsdl2java ,但您可以使用outputDirectory配置元素覆盖它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM