【问题标题】:How specify to Jaxb plugin to generate only one schema from wsdl如何指定 Jaxb 插件从 wsdl 只生成一个模式
【发布时间】:2013-07-08 07:58:10
【问题描述】:

我使用maven-jaxb2-pluginwsdl 文件生成类。我的wsdl fila 有多个模式条目,但我只需要一个。那么是否可以指定我想要生成的shema。也许在 pom.xml 或 xjb 绑定文件中?我的pop.xmlmaven-jaxb2-plugin 配置:

<plugin>
    <groupId>org.jvnet.jaxb2.maven2</groupId>
    <artifactId>maven-jaxb2-plugin</artifactId>
    <version>0.8.0</version>
    <executions>
        <execution>
           <id>some_id</id>
           <goals>
               <goal>generate</goal>
           </goals>
           <configuration>
               <schemaLanguage>WSDL</schemaLanguage>
               <schemaDirectory>${basedir}/src/main/resources/wsdl/</schemaDirectory>
               <schemaIncludes>
                   <include>*.wsdl</include>
               </schemaIncludes>
               <bindingIncludes>
                   <include>binding.xjb</include> // is 
               </bindingIncludes>
               <generatePackage>my.custom.package</generatePackage> -->
               <generateDirectory>target/generated-sources/jaxb</generateDirectory>
           </configuration>
     </execution>

我的wsdl 文件如下所示:

<?xml version="1.0" encoding="utf-8"?>    
<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" ... other namespaces>    
  <types>    
    <xs:schema targetNamespace="http://www.custom.se/webservices/" elementFormDefault="qualified" attributeFormDefault="unqualified"     xmlns:xs="http://www.w3.org/2001/XMLSchema">
      <xs:element name="Elem">
        <xs:complexType>
          <xs:sequence>
            <xs:element name="SeqNo" type="xs:string"/>
            <xs:element name="Method" type="xs:string"/>
            <xs:element name="Id" type="xs:string"/>
            <xs:element name="UserId" type="xs:string"/>
            <xs:element name="ResultCode" type="xs:string"/>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
    </xs:schema>

    <xs:schema targetNamespace="http://www.custom.se/webservices/publishing/">
    ....
    </xs:shema>

    <xs:schema targetNamespace="http://www.custom.se/webservices/smth/">
    ....
    </xs:shema>

    ....

感谢您的帮助。

【问题讨论】:

    标签: jaxb wsdl jaxb2 wsdl2java


    【解决方案1】:

    你最终想要达到什么目的?由于您使用的是 jaxb 插件而不是 jaxws 插件,我假设您对从 WSDL 构造生成的 java 代码不感兴趣。所以目标是尽量减少生成的 jar 中生成的类的数量?

    好吧,在这种情况下,最简单的解决方案是全部生成它们,然后有选择地编译(或打包)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-02-10
      • 2014-02-01
      • 1970-01-01
      • 1970-01-01
      • 2012-01-25
      • 1970-01-01
      • 2023-03-28
      • 1970-01-01
      相关资源
      最近更新 更多