Specifying Package Name When Using Maven to Generate Java from WSDL

后端 未结 3 2150
孤独总比滥情好
孤独总比滥情好 2021-02-19 20:15

I am using a maven script to generate the Java code I need to communicate with a WCF service. I have gotten communication working and am ready to integrate my maven script, and

相关标签:
3条回答
  • 2021-02-19 21:03

    This works very well for me:

    <wsdlOption>
                                    <wsdl>src/main/resources/wsdl/my_wsdl.wsdl</wsdl>
                                    <extraargs>
                                        <extraarg>-p</extraarg>
                                        <extraarg>http://services.demo.es/=com.my.package.demo1</extraarg>
                                        <extraarg>-p</extraarg>
                                        <extraarg>http://tempuri.org/=com.my.package.demo2</extraarg>
                                        <extraarg>-exsh</extraarg>
                                        <extraarg>true</extraarg>
                                        <extraarg>-client</extraarg>
                                        <extraarg>-wsdlLocation</extraarg>
                                        <extraarg></extraarg>
                                    </extraargs>
                                </wsdlOption>
    
    0 讨论(0)
  • 2021-02-19 21:08

    The above solution with

    <extraarg>-p</extraarg>
    <extraarg>com.name.server.cxf</extraarg>
    

    Is changing package name of generated source under one single package ,because of which ObjectFactory classes are getting override.I need like package structure as it as based on wsld. Along with addition package.

    example java classes are generated as com.service.name.mypackage.a,com.service.name.mypackage.b,com.service.name.mypackage.c

    0 讨论(0)
  • 2021-02-19 21:19

    Add <extraarg>-p</extraarg><extraarg>com.name.server.cxf</extraarg> to your <extraargs> section inside the <wsdlOption> tag. The following (slightly different version) works for me.

           <plugin>
                <groupId>org.apache.cxf</groupId>
                <artifactId>cxf-codegen-plugin</artifactId>
                <version>${cxf.version}</version>
                <executions>
                    <execution>
                        <id>generate-sources</id>
                        <phase>generate-sources</phase>
                        <configuration>
                            <wsdlOptions>
                                <wsdlOption>
                                    <wsdl>src/com/server/cxf/code-generation/service.xml</wsdl>
                                    <bindingFiles>
                                        <bindingFile>src/com/server/cxf/code-generation/javabindings.xml</bindingFile>
                                    </bindingFiles>
                                    <extraargs>
                                        <extraarg>-validate</extraarg>
                                        <extraarg>-client</extraarg>
                                        <extraarg>-verbose</extraarg>
                                        <extraarg>-xjc-verbose</extraarg>
                                        <extraarg>-p</extraarg>
                                        <extraarg>com.name.server.cxf</extraarg>
                                    </extraargs>
                                </wsdlOption>
                            </wsdlOptions>
                        </configuration>
                        <goals>
                            <goal>wsdl2java</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
    

    Alternatively, create a file service-options in src/com/server/cxf/code-generation/ with the content -p com.name.server.cxf

    0 讨论(0)
提交回复
热议问题