2016-11-08 89 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