005.使用maven外掛cxf-codegen-plugin生成WebService代理類程式碼

weixin_33866037發表於2017-07-11

1.在pom.xml中配置cxf-codegen-plugin外掛

<plugin>
                <groupId>org.apache.cxf</groupId>
                <artifactId>cxf-codegen-plugin</artifactId>
                <version>${cxf.version}</version>
                <executions>
                    <execution>
                        <!--生成第一個客戶端程式碼-->
                        <id>generate-sources-client1</id>
                        <phase>generate-sources</phase>
                        <configuration>
                            <!-- 生成代理類的目錄 -->
                            <sourceRoot>src/main/java</sourceRoot>
                            <wsdlOptions>
                                <wsdlOption>
                                    <!-- wsdl地址 -->
                                    <wsdl>http://localhost:8090/project-name/MyFirstService?wsdl</wsdl>
                                    <!-- 指定代理類包名 -->
                                    <packagenames>
                                        <packagename>com.airkisser.client.first_client</packagename>
                                    </packagenames>
                                    <!-- 是否生成soapheader -->
                                    <extendedSoapHeaders>true</extendedSoapHeaders>
                                </wsdlOption>
                            </wsdlOptions>
                        </configuration>
                        <goals>
                            <goal>wsdl2java</goal>
                        </goals>
                    </execution>
                    <execution>
                        <!--生成第二個客戶端程式碼-->
                        <id>generate-sources-client2</id>
                        <phase>generate-sources</phase>
                        <configuration>
                            <!-- 生成代理類的目錄 -->
                            <sourceRoot>src/main/java</sourceRoot>
                            <wsdlOptions>
                                <wsdlOption>
                                    <!-- wsdl地址 -->
                                    <wsdl>http://localhost:8090/project-name/MySecondService?wsdl</wsdl>
                                    <!-- 指定代理類包名 -->
                                    <packagenames>
                                        <packagename>com.airkisser.client.second_client</packagename>
                                    </packagenames>
                                    <!-- 是否生成soapheader -->
                                    <extendedSoapHeaders>true</extendedSoapHeaders>
                                </wsdlOption>
                            </wsdlOptions>
                        </configuration>
                        <goals>
                            <goal>wsdl2java</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

2.配置maven任務,然後執行即可生成代理類

4304990-152a14054d2b9648.png
image.png

相關文章