1

wsdl から生成されたクラスの名前を変更しようとしています (wsdl または xsd ファイルを直接変更したくありません)。問題は、その定義が別の xsd ファイルにあることです。

wsdl の構造は次のようになります。

main.wsdl:

<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://foo.bar/zee">
<wsdl:import location="typedef.wsdl" namespace="http://foo.bar/wee">
</wsdl:import>
    ...
</wsdl:definitions>

typedef.wsdl:

<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="Foo" targetNamespace="http://foo.bar/wee">
    <wsdl:types>
        <xsd:schema>
            <xsd:import namespace="http://foo.bar/wee/schema" schemaLocation="FooBar.xsd"/>
        </xsd:schema>
    </wsdl:types>
    ...
<wsdl:definitions> 

FooBar.xsd:

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" targetNamespace="http://foo.bar/wee/schema">
    ...
    <xsd:complexType name="FooType">
    <xsd:sequence>
        ...
    </xsd:complexType>
</xsd:schema>    

ここで、FooType クラスの名前を Foo に変更するとします。これを読んだ後: JAXB: XSD で属性タイプが指定されている場合、XJC で生成されたクラス名を変更する方法は? 次のバインディング ファイルを作成しました。

jaxws_bindings.xml:

<?xml version="1.0" encoding="UTF-8"?>
<jxb:bindings
        xmlns:xs="http://www.w3.org/2001/XMLSchema"
        xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
        version="2.1"
        wsdlLocation="http://127.0.0.1:8431/Foo/types.wsdl">

    <jxb:bindings schemaLocation="http://127.0.0.1:8431/Foo/FooBar.xsd">
        <jxb:bindings node="//xs:complexType[@name='FooType']">
            <jxb:class name="Foo"/>
        </jxb:bindings>
    </jxb:bindings>

</jxb:bindings>

しかし、私が得るのはエラーだけです:

[ERROR] Failed to execute goal org.apache.cxf:cxf-codegen-plugin:2.7.0:wsdl2java (generate-sources) on
project foo: Execution generate-sources of goal org.apache.cxf:cxf-codegen-plugin:2.7.0:wsdl2java failed:
file:/E:/sources/.../jaxws_bindings.xml [8,95]: "http://127.0.0.1:8431/Foo/FooBar.xsd" is not a part of 
this compilation. Is this a mistake for "http://127.0.0.1:8431/Foo/FooBar.xsd"? -> [Help 1]

頭に浮かんだことはすべて試しましたが、まだ成功に近いものはありません。誰でもこれを行う方法を知っていますか?

PS: クラスを生成するには、pom.xml で次の構成で maven cxf codegen プラグインを使用します。

<build>
    <finalName>${project.groupId}.${project.artifactId}</finalName>
    <plugins>
      <plugin>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-codegen-plugin</artifactId>
        <version>2.7.0</version>
        <executions>
          <execution>
            <id>generate-sources</id>
            <phase>generate-sources</phase>
            <configuration>
              <sourceRoot>${project.build.directory}/generated-sources</sourceRoot>
              <wsdlOptions>
                <wsdlOption>
                  <wsdl>http://127.0.0.1:8431/Foo/main.wsdl</wsdl>
                  <extraargs>
                    <extraarg>-client</extraarg>
                  </extraargs>
                  <bindingFiles>
                    <bindingFile>jaxws_bindings.xml</bindingFile>
                  </bindingFiles>
                </wsdlOption>
              </wsdlOptions>
            </configuration>
            <goals>
              <goal>wsdl2java</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
</build>
4

1 に答える 1