解析 wsdl 时 cxf-codegen-plugin 失败(JSXB:未定义的属性 'xml:lang')

cxf-codegen-plugin failed while parsing wsdl (JSXB: undefined attribute 'xml:lang')

我尝试从 wsdl 为 Exchange Web 服务生成 java 代码。

我使用 apache cxf-codegen-plugin 配置为:

<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/maven-v4_0_0.xsd">

  <modelVersion>4.0.0</modelVersion>

  <name>ews-api</name>
  <groupId>net.retn</groupId>
  <artifactId>ews-api</artifactId>
  <version>1.0-SNAPSHOT</version>
  <packaging>jar</packaging>

  <properties>
    <encoding>UTF-8</encoding>
    <cxf.version>3.1.6</cxf.version>
  </properties>

  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-codegen-plugin</artifactId>
        <version>${cxf.version}</version>
        <dependencies>
          <dependency>
              <groupId>net.retn</groupId>
              <artifactId>cxf-ews-authenticator</artifactId>
              <version>1.0-SNAPSHOT</version>
          </dependency>
        </dependencies>
        <executions>
          <execution>
              <id>generate-sources</id>
              <phase>generate-sources</phase>
              <configuration>
                <sourceRoot>${project.build.sourceDirectory}/</sourceRoot>
                <wsdlOptions>
                  <wsdlOption>
                    <wsdl>https://server/EWS/Services.wsdl</wsdl>
                    <extraargs>
                      <extraarg>-b</extraarg>
                      <extraarg>${basedir}/src/main/resources/async_binding.xml</extraarg>
                    </extraargs>
                  </wsdlOption>
                </wsdlOptions>
              </configuration>
              <goals>
                <goal>wsdl2java</goal>
              </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

</project>

但是当我执行:mvn compile 抛出错误:

[ERROR] https://server/EWS/types.xsd [0:0]: undefined attribute 'xml:lang'
org.xml.sax.SAXParseException; systemId: https://server/EWS/types.xsd; lineNumber: 0; columnNumber: 0; undefined attribute 'xml:lang'
        at com.sun.xml.xsom.impl.parser.ParserContext.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:727)
        at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.processWsdl(WSDLToJavaContainer.java:271)
        at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.execute(WSDLToJavaContainer.java:165)
        at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.execute(WSDLToJavaContainer.java:416)
        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:207)
        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:863)
        at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
        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:606)
        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)

types.xsd:

<xs:schema xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:tns="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:xs="http://www.w3.org/2001/XMLSchema" id="types" elementFormDefault="qualified" version="Exchange2013_SP1" targetNamespace="http://schemas.microsoft.com/exchange/services/2006/types">
<xs:import namespace="http://www.w3.org/XML/1998/namespace"/>
.....
<xs:complexType name="ReplyBody">
<xs:sequence>
<xs:element minOccurs="0" maxOccurs="1" name="Message" type="xs:string"/>
</xs:sequence>
<xs:attribute ref="xml:lang" use="optional"/>
</xs:complexType>
.....
</xs:schema>

有人尝试做这样的事情吗?有什么问题?

我找到了解决办法。 http://www.w3.org/XML/1998/namespace 的 XML 架构的位置已更改:

Validating XML against XSD containing xsd:import without location