2

Apache cxf-codegen-pluginMaven プラグインを使用して、WSDL ファイルから Java クラスを生成しようとしています。次のエラーが表示されます。

Part <parameters> in Message <{http://www.foo.com/bar}PushCommandSoapIn> referenced Type <{http://www.foo.com/bar}CommandMessage> can not be found in the schemas

問題の型 ( CommandMessage) は、次の POM ファイルを使用して参照しようとした XSD ファイルで定義されています。

<plugin>
  <groupId>org.apache.cxf</groupId>
  <artifactId>cxf-codegen-plugin</artifactId>
  <version>2.7.11</version>
  <executions>
    <execution>
      <id>generate-sources</id>
      <phase>generate-sources</phase>
      <configuration>
        <wsdlOptions>
          <wsdlOption>
            <wsdl>${basedir}/src/main/resources/wsdl/SomeService.wsdl</wsdl>
            <dependencies>
              <!-- Here I try to reference the XSD -->
              <dependency>${basedir}/src/main/resources/wsdl/SomeTypes.xsd</dependency>
            </dependencies>
          </wsdlOption>
        </wsdlOptions>
      </configuration>
      <goals>
        <goal>wsdl2java</goal>
      </goals>
    </execution>
  </executions>
</plugin>  

エラーが発生する理由について何か提案はありますか? を追加するの<dependency>が正しい方法かどうかはわかりませんが、XSD ファイルを参照する方法を説明するドキュメントを見つけるのに苦労しました。

以下は、欠落しているタイプを参照する WSDL ファイルのスニペットです。

<?xml version="1.0" encoding="utf-8"?>
<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" 
      xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" 
      xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" 
      xmlns:bar="http://www.foo.com/bar" 
      targetNamespace="http://www.foo.com/bar">
  <wsdl:message name="PushCommandSoapIn">
    <wsdl:part name="parameters" element="bar:CommandMessage" />
  </wsdl:message>

XSD ファイルのヘッダーとスニペットを次に示します。

<?xml version="1.0" encoding="UTF-8"?>
<schema targetNamespace="http://www.foo.com/bar" 
      xmlns:bar="http://www.foo.com/bar" 
      xmlns="http://www.w3.org/2001/XMLSchema" 
      xmlns:xs="http://www.w3.org/2001/XMLSchema" 
      xmlns:ds="http://www.w3.org/2000/09/xmldsig#" 
      elementFormDefault="qualified" attributeFormDefault="unqualified">
  <import namespace="http://www.w3.org/2000/09/xmldsig#" schemaLocation="xmldsig-core-schema.xsd" />
  ...
  <element name="CommandMessage" type="bar:CommandMessageType" substitutionGroup="bar:Message" final="#all" />
4

1 に答える 1