是否可以在maven中使用apache cxf将Web服务客户端代码生成到特殊包中?

发布于 2024-09-19 12:36:12 字数 1272 浏览 7 评论 0原文

我正在尝试在动态构建项目后生成 Web 服务客户端。目前它是这样做的,但将其放入基于 WS 命名空间命名的包中。所以让我们假设命名空间是 google.com ,生成的文件将位于 com.google 中..

<plugin>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-codegen-plugin</artifactId>
            <version>2.2.10</version>
            <executions>
                <execution>
                    <id>generate-sources</id>
                    <phase>generate-sources</phase>
                    <configuration>
                        <sourceRoot>${basedir}/src/main/java/</sourceRoot>
                        <wsdlOptions>
                            <wsdlOption>
                                <wsdl>http://localhost:8080/ProjectName/ProjectWS?wsdl</wsdl>
                            </wsdlOption>
                        </wsdlOptions>
                    </configuration>
                    <goals>
                        <goal>wsdl2java</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

我想将文件生成到不同的包中..让我们将其称为 comWS.gooleClient

可以这样做吗?

谢谢

I am trying to generate the webservices client once i build my project on the fly .. It currently does so but put it in package named based on the namespace of the WS.. so lets assume the name space is google.com , the generated files would be in com.google ..

<plugin>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-codegen-plugin</artifactId>
            <version>2.2.10</version>
            <executions>
                <execution>
                    <id>generate-sources</id>
                    <phase>generate-sources</phase>
                    <configuration>
                        <sourceRoot>${basedir}/src/main/java/</sourceRoot>
                        <wsdlOptions>
                            <wsdlOption>
                                <wsdl>http://localhost:8080/ProjectName/ProjectWS?wsdl</wsdl>
                            </wsdlOption>
                        </wsdlOptions>
                    </configuration>
                    <goals>
                        <goal>wsdl2java</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

I want to generate the files to a different package.. lets call it comWS.gooleClient

Is it possible to do that?

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

—━☆沉默づ 2024-09-26 12:36:12

可以使用自定义绑定或传递 -p 额外参数,如下所示:

<plugin>
  <groupId>org.apache.cxf</groupId>
  <artifactId>cxf-codegen-plugin</artifactId>
  <version>2.2.10</version>
  <executions>
    <execution>
      <id>generate-sources</id>
      <phase>generate-sources</phase>
      <configuration>
        <sourceRoot>${basedir}/src/main/java/</sourceRoot>
        <wsdlOptions>
          <wsdlOption>
            <wsdl>http://localhost:8080/ProjectName/ProjectWS?wsdl</wsdl>
            <extraargs>
              <extraarg>-p</extraarg>
              <extraarg>com.something.else</extraarg>
            </extraargs>
          </wsdlOption>
        </wsdlOptions>
      </configuration>
      <goals>
        <goal>wsdl2java</goal>
      </goals>
    </execution>
  </executions>
</plugin>

It is possible using a custom binding or passing the -p extra argument as shown below:

<plugin>
  <groupId>org.apache.cxf</groupId>
  <artifactId>cxf-codegen-plugin</artifactId>
  <version>2.2.10</version>
  <executions>
    <execution>
      <id>generate-sources</id>
      <phase>generate-sources</phase>
      <configuration>
        <sourceRoot>${basedir}/src/main/java/</sourceRoot>
        <wsdlOptions>
          <wsdlOption>
            <wsdl>http://localhost:8080/ProjectName/ProjectWS?wsdl</wsdl>
            <extraargs>
              <extraarg>-p</extraarg>
              <extraarg>com.something.else</extraarg>
            </extraargs>
          </wsdlOption>
        </wsdlOptions>
      </configuration>
      <goals>
        <goal>wsdl2java</goal>
      </goals>
    </execution>
  </executions>
</plugin>
永言不败 2024-09-26 12:36:12

虽然我迟到了,但这个规范对我有用

<plugin>
     <groupId>org.apache.cxf</groupId>
 <artifactId>cxf-codegen-plugin</artifactId>
 <version>2.7.7</version>
 <executions>
    <execution>
    <id>generate-sources</id>
    <phase>generate-sources</phase>
    <configuration>
         <sourceRoot>${basedir}/src/main/java</sourceRoot>
         <wsdlOptions>
               <wsdlOption>
              <wsdl>wsdl-location</wsdl>
          <extraargs>
            <extraarg>-client</extraarg>
              </extraargs>
        <packagenames> 
                <packagename>desired location</packagename> 
        </packagenames> 
               </wsdlOption>
            </wsdlOptions>                    
       </configuration>
       <goals>
        <goal>wsdl2java</goal>
     </goals>
   </execution>
</executions>
</plugin>

I am very late though , but this specification worked for me

<plugin>
     <groupId>org.apache.cxf</groupId>
 <artifactId>cxf-codegen-plugin</artifactId>
 <version>2.7.7</version>
 <executions>
    <execution>
    <id>generate-sources</id>
    <phase>generate-sources</phase>
    <configuration>
         <sourceRoot>${basedir}/src/main/java</sourceRoot>
         <wsdlOptions>
               <wsdlOption>
              <wsdl>wsdl-location</wsdl>
          <extraargs>
            <extraarg>-client</extraarg>
              </extraargs>
        <packagenames> 
                <packagename>desired location</packagename> 
        </packagenames> 
               </wsdlOption>
            </wsdlOptions>                    
       </configuration>
       <goals>
        <goal>wsdl2java</goal>
     </goals>
   </execution>
</executions>
</plugin>
明媚如初 2024-09-26 12:36:12

你尝试过这个额外参数吗?

<extraarg><!--namespace-->=<!-- new package name--></extraarg>

例子:

<plugin>
  <groupId>org.apache.cxf</groupId>
  <artifactId>cxf-codegen-plugin</artifactId>
  <version>2.2.10</version>
  <executions>
    <execution>
      <id>generate-sources</id>
      <phase>generate-sources</phase>
      <configuration>
        <sourceRoot>${basedir}/src/main/java/</sourceRoot>
        <wsdlOptions>
          <wsdlOption>
            <wsdl>http://localhost:8080/ProjectName/ProjectWS?wsdl</wsdl>
            <extraargs>
                <extraarg>-p</extraarg>
                <extraarg>http://google.com=comWS.gooleClient</extraarg>
            </extraargs>
          </wsdlOption>
        </wsdlOptions>
      </configuration>
      <goals>
        <goal>wsdl2java</goal>
      </goals>
    </execution>
  </executions>
</plugin>

Did you try this for extraarg?

<extraarg><!--namespace-->=<!-- new package name--></extraarg>

Example:

<plugin>
  <groupId>org.apache.cxf</groupId>
  <artifactId>cxf-codegen-plugin</artifactId>
  <version>2.2.10</version>
  <executions>
    <execution>
      <id>generate-sources</id>
      <phase>generate-sources</phase>
      <configuration>
        <sourceRoot>${basedir}/src/main/java/</sourceRoot>
        <wsdlOptions>
          <wsdlOption>
            <wsdl>http://localhost:8080/ProjectName/ProjectWS?wsdl</wsdl>
            <extraargs>
                <extraarg>-p</extraarg>
                <extraarg>http://google.com=comWS.gooleClient</extraarg>
            </extraargs>
          </wsdlOption>
        </wsdlOptions>
      </configuration>
      <goals>
        <goal>wsdl2java</goal>
      </goals>
    </execution>
  </executions>
</plugin>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文