2013-07-08 39 views
0

我使用maven-jaxb2-pluginwsdl文件生成類。我的wsdl菲有多個模式條目,但我只需要一個。那麼是否可以指定我想生成哪個shema。也許在pom.xml或xjb綁定文件中?我pop.xmlmaven-jaxb2-plugin配置:如何指定Jaxb插件只從wsdl生成一個模式

<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> 

    .... 

我感謝所有幫助。

回答

0

你最終想達到什麼目的?由於您使用的是jaxb插件而不是jaxws插件,因此我假設您對從WSDL構造生成的java代碼不感興趣。所以我們的目標是最小化生成的jar中生成的類的數量?

那麼,在這種情況下,最簡單的解決方案是生成它們,然後選擇性地編譯(或打包)。