2016-11-08 94 views
0

使用maven-jaxb2-plugin爲兩個彼此相關的WSDL模式生成JAXB類。Maven JAXB 2插件 - 如何設置以使用交叉方案依賴關係

中的類生成這樣的:

com - accounts 
    |- payments 
    |- other 

行家-JAXB2-插件設置這樣的:

<plugin> 
    <groupId>org.jvnet.jaxb2.maven2</groupId> 
     <artifactId>maven-jaxb2-plugin</artifactId> 
     <version>0.13.1</version> 
     <executions> 
      <execution> 
       <id>unipayments</id> 
       <goals> 
        <goal>generate</goal> 
       </goals> 
       <configuration> 
        <schemaLanguage>WSDL</schemaLanguage> 
        <args> 
         <arg>-npa</arg> 
        </args> 
        <schemas> 
         <schema> 
          <url>http://...accounts?wsdl</url> 
         </schema> 
        </schemas> 
       </configuration> 
      </execution> 
      <execution> 
       <id>accounts</id> 
       <goals> 
        <goal>generate</goal> 
       </goals> 
       <configuration> 
        <schemaLanguage>WSDL</schemaLanguage> 
        <args> 
         <arg>-npa</arg> 
        </args> 
        <schemas> 
         <schema> 
          <url>http://...payments?wsdl</url> 
         </schema> 
        </schemas> 
       </configuration> 
      </execution> 
    </executions> 
</plugin> 

生成的類的(任何位置幾乎相同)的一項所述的註釋:

@XmlAccessorType(XmlAccessType.FIELD) 
@XmlType(name = "inputTemplate", namespace = "http://...payments", propOrder = {}) 
public class InputTemplate {...} 

問題是SOAP accounts JAXB類具有嵌套的elem上面指定的類別來自另一個payments方案。所以,的Marshaller拋出該異常這樣的,當我查詢到accounts服務的對象,有支付的inputTemplate爲孩子:

unexpected element (uri:"http://...payments", local:"inputTemplate"). 
Expected elements are <{}inputTemplate> 

不知道爲什麼會發生,雖然,指定每個類都有命名空間。

那麼,如何讓具有交叉方案依賴性的JAXB類使用這個插件工作?

回答

1

此:

意想不到的元素(URI: 「http://...payments」,當地 「inputTemplate」)。預計 元素是<} {inputTemplate>

實際上指向不與架構依賴關係,而是與命名空間的一個問題一個問題。 inputTemplate元素是已知的,但它在默認名稱空間中是預期的。可能是錯誤的elementFormDefault或類似的東西。

要回答你的問題,如果你分別編譯你的模式(單獨的Maven模塊)和包含依賴項作爲劇集,最好處理架構間依賴關係。

https://github.com/highsource/maven-jaxb2-plugin/wiki/Using-Episodes