2016-05-23 178 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>