2013-10-15 20 views
0

我试图让CXF(2.7.7)使用JiBX(1.2.5)进行数据绑定。这份文件有点粗略,但有报道称它取得了成功。一个问题是,CXF不会将配置传递给JiBX代码生成器,因此如果您需要执行需要自定义的操作(例如将Joda DateTime映射到XML Schema日期),则需要能够告诉CXF忽略特定的命名空间,然后通过单独致电JiBX处理这些人。当使用JiBX作为CXF数据库时,是否包含工作?

我已经看到了使用CXF -nexclude标志用于此目的的例子,如

<plugin> 
    <groupId>org.apache.cxf</groupId> 
    <artifactId>cxf-codegen-plugin</artifactId> 
    <version>${cxf.version}</version> 
    <executions> 
     <execution> 
      <id>generateSources</id> 
      <phase>generate-sources</phase> 
      <goals> 
       <goal>wsdl2java</goal> 
      </goals> 
      <configuration> 
       <sourceRoot>${generated-sources.dir}/cxf</sourceRoot> 
       <wsdlRoot>${wsdl.dir}</wsdlRoot> 
       <wsdlOptions> 
        <wsdlOption> 
         <wsdl>${wsdl.dir}/GetCounters.wsdl</wsdl> 
         <dataBinding>jibx</dataBinding> 
         <extraargs> 
          <extraarg>-nexclude</extraarg> 
          <extraarg>http://www.example.com/counters/</extraarg> 
         </extraargs> 
        </wsdlOption> 
       </wsdlOptions> 
      </configuration> 
     </execution> 
    </executions> 
</plugin> 

我试图内嵌和命名空间的进口版本,但-nexclude标志没有出现一起工作JiBX的。一种选择可能是让JiBX在不调用CXF插件的情况下完成整个WSDL,但显然这会在生成的服务代码中产生问题。一个丑陋的解决方法可能是让JiBX重新生成该命名空间中的类的代码,覆盖由CXF创建的代码。

-nexclude标志可以工作吗?

回答

0

我在使用jaxb时遇到了类似的问题。这工作对我来说:

将extraargs移出wsdlOption部分并进入defaultOptions部分。

<plugin> 
<groupId>org.apache.cxf</groupId> 
<artifactId>cxf-codegen-plugin</artifactId> 
<version>${cfx.codegen.version}</version> 
<executions> 
    <execution> 
     <id>generate-sources</id> 
     <phase>generate-sources</phase> 
     <configuration> 
      <defaultOptions> 
       <extraargs> 
        <extraarg>-nexclude</extraarg> 
        <extraarg>http://domain.company.org/v1/schema1</extraarg> 
        <extraarg>-nexclude</extraarg> 
        <extraarg>http://domain.company.org/v1/schema2</extraarg> 
       </extraargs> 
      </defaultOptions> 
      <wsdlOptions> 
       <wsdlOption> 
        <wsdlArtifact> 
         <groupId>org.company</groupId> 
         <artifactId>application-contract</artifactId> 
         <version>${contract.version}</version> 
         <type>wsdl</type> 
        </wsdlArtifact> 
       </wsdlOption> 
      </wsdlOptions> 
      <sourceRoot>${project.build.directory}/generated/cxf</sourceRoot> 
     </configuration> 
     <goals> 
      <goal>wsdl2java</goal> 
     </goals> 
    </execution> 
</executions> 

相关问题