2016-05-23 160 views
0

我正在使用maven插件从WSDL生成webservice。我希望此服务接受&流程附件。我了解到webservice的服务接口应该有注释Apache CXF wsdl2Java指定消耗

@Consumes("multipart/form-data") 

但是通过Maven生成的存根不包括这个。我怎样才能实现它?有没有办法将它指定为插件或外部绑定文件的参数? 目前我的插件看起来像下面(的一部分)

<plugin> 
     <groupId>org.apache.cxf</groupId> 
     <artifactId>cxf-codegen-plugin</artifactId> 
     <version>${cxf.version}</version> 
     <executions> 
      <execution> 
       <id>generate-sources</id> 
       <configuration> 
        <sourceRoot>${basedir}/target/generated/src/main/java</sourceRoot> 
        <wsdlOptions> 
         <wsdlOption> 
          <wsdl>${basedir}/src/main/resources/wsdl/answersheetService.wsdl</wsdl> 
          <extraargs> 
           <extraarg>-b</extraarg> 
           <extraarg>${basedir}/src/main/resources/wsdl/answersheet_binding.xml</extraarg> 
           <extraarg>-validate</extraarg> 
           <extraarg>-autoNameResolution</extraarg> 
           <extraarg>-client</extraarg> 
          </extraargs> 
         </wsdlOption> 

回答

0

我也面临着类似的问题。 cxf-codegen-plugin没有必要的代码容量,我使用maven-replacer-plugin。在我的例子中,我们用包名称替换了全名。

<plugin> 
    <groupId>com.google.code.maven-replacer-plugin</groupId> 
    <artifactId>replacer</artifactId> 
    <executions> 
     <execution> 
      <id>replace-fault-names</id> 
      <goals> 
       <goal>replace</goal> 
      </goals> 
      <phase>generate-sources</phase> 
      <configuration> 
       <file> 
        ${basedir}/target/generated-sources/src/package/YourClass.java 
       </file> 
       <replacements> 
        <replacement> 
         <token>source-value</token> 
         <value>target-value</value> 
        </replacement> 
       </replacements> 
      </configuration> 
     </execution> 
    </executions> 
</plugin>