2

I need to identify the files generated by Apache CXF in case of Soap WebServices via WSDL2Java tool. Is there a postprocessor where I can manipulate the byte data for these generated files to add a custom annotation on these files?

Following is my Maven Plugin Configuration

<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>
                        <strict>false</strict>
                        <sourceRoot>${basedir}/src/main/java</sourceRoot>
                        <wsdlOptions>
                            <wsdlOption>
                                <wsdl>${basedir}/src/main/resources/wsdl/CustomerService.wsdl</wsdl>
                                <extraargs>
                                    <extraarg>-xjc annox</extraarg>
                                </extraargs>
                                <bindingFiles>
                                    <bindingFile>${basedir}/src/main/resources/wsdl/binding.xml</bindingFile>
                                </bindingFiles>
                            </wsdlOption>
                        </wsdlOptions>
                        <plugins>
                            <plugin>
                                <groupId>org.jvnet.jaxb2_commons</groupId>
                                <artifactId>jaxb2-basics</artifactId>
                                <version>0.6.0</version>
                            </plugin>
                            <plugin>
                                <groupId>org.jvnet.jaxb2_commons</groupId>
                                <artifactId>jaxb2-basics-annotate</artifactId>
                                <version>0.6.0</version>
                            </plugin>
                        </plugins>
                    </configuration>
                    <goals>
                        <goal>wsdl2java</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

and this is my binding.xml

<jaxws:bindings xmlns:jaxws="http://java.sun.com/xml/ns/jaxws"
xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:annox="http://annox.dev.java.net">
<!-- <jaxws:enableAsyncMapping>true</jaxws:enableAsyncMapping> -->
<jaxws:enableWrapperStyle>true</jaxws:enableWrapperStyle>
<jaxws:bindings node="wsdl:definitions/wsdl:types/xs:schema">
    <jxb:globalBindings>
        <jxb:javaType name="java.util.Date" xmlType="xs:dateTime"
            parseMethod="org.apache.cxf.tools.common.DataTypeAdapter.parseDateTime"
            printMethod="org.apache.cxf.tools.common.DataTypeAdapter.printDateTime" />
        <jxb:javaType name="java.util.Date" xmlType="xs:date"
            parseMethod="org.apache.cxf.tools.common.DataTypeAdapter.parseDate"
            printMethod="org.apache.cxf.tools.common.DataTypeAdapter.printDate" />
    </jxb:globalBindings>

    <jxb:bindings node="/xs:complexType">
        <annox:annotate target="class">
            <annox:annotate annox:class="javax.xml.bind.annotation.XmlRootElement"
                name="GetRecordsType" />
        </annox:annotate>
    </jxb:bindings>
</jaxws:bindings>

lexicore
  • 42,748
  • 17
  • 132
  • 221
Abhishek
  • 1,031
  • 4
  • 16
  • 25
  • Is [this](http://stackoverflow.com/a/8725352/267197) what you want? – dma_k Feb 20 '12 at 19:41
  • I tried using this but I am using it with Apache CXF plugin and it stil is not working. I will edit with Code. – Abhishek Feb 21 '12 at 11:20
  • I think `cxf-codegen-plugin` does not support plugins. Can you use `org.codehaus.mojo:jaxws-maven-plugin`? – dma_k Feb 21 '12 at 11:37
  • Forgot to say that `jaxws-maven-plugin` does not support JAXB plugins... U-f-f. The problem is a bit complex. For JAXB customizations read [here](http://centurion.nfors.com/w/programming/java/web_service#using_jaxb_customizations) where I have provided the solution for some plugins for `jaxws-maven-plugin`. Also worth reading [there](http://www.fransvanbuul.net/?p=98). My advise would be perhaps to use JAX-WS to generate WS-artifacts and run JXC to generate (and overwrite) JAXB atifacts. – dma_k May 16 '14 at 22:28

0 Answers0