Question

I am trying to use the globalBindings element to add serializable + a default UID to my WSDL stub classes so I can get rid of a bunch of annoying warnings from Eclipse.

I am trying to follow the suggestions in this answer, but no luck. Still get all the warnings in Eclipse.

Am I missing something in the pom file perhaps?

I am OK with upgrading to a newer version of the jaxws plugin, or even moving to a different plugin, if required.

Here's my bindings file:

<bindings xmlns="http://java.sun.com/xml/ns/jaxb" xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance"
    xmlns:xs="http://www.w3.org/2001/XMLSchema" version="2.1"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc">
    <globalBindings>
        <xjc:serializable uid="1" />
    </globalBindings>
    <bindings
        schemaLocation="../resources/com/satorisoftware/ws/infuseiac/intladdresscorrection/intladdresscorrection.wsdl#types?schema3"
        version="1.0">

        <schemaBindings>
            <package name="com.satorisoftware.ws.infuseiac-intladdresscorrection" />
        </schemaBindings>
        <!-- Tell JAXB to generate Java class specifically named CorrectRequestElement 
            for this element, to avoid the name clash that automatic naming causes. -->
        <bindings node="//xsd:element[@name='CorrectRequest']">
            <class name="CorrectRequestElement" />
        </bindings>
    </bindings>
</bindings>

And here's the relevant part of my pom.xml file:

        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>jaxws-maven-plugin</artifactId>
            <version>1.12</version>
            <executions>
                <execution>
                    <id>import-iac-wsdl</id>
                    <phase>generate-sources</phase>
                    <goals>
                        <goal>wsimport</goal>
                    </goals>
                    <inherited>false</inherited>
                    <configuration>
                        <packageName>com.satorisoftware.ws.infuseiac.intladdresscorrection</packageName>
                        <wsdlLocation>com/satorisoftware/ws/infuseiac/intladdresscorrection/intladdresscorrection.wsdl</wsdlLocation>
                        <staleFile>${project.build.directory}/jaxws/stale/wsdl.intladdresscorrection.done</staleFile>
                        <sourceDestDir>${project.build.directory}/generated/jaxws-infuseiac-intladdresscorrection</sourceDestDir>
                        <wsdlDirectory>src/main/resources/com/satorisoftware/ws/infuseiac/intladdresscorrection</wsdlDirectory>
                        <bindingFiles>
                            <!-- See http://www.jroller.com/gmazza/entry/enhancing_jaxb_artifacts#BindingFile 
                            for an end-to-end-example of doing bindings files for WSDL files. -->
                            <bindingFile>${basedir}/src/main/bindings/bindings-intladdresscorrection.xjb</bindingFile>
                        </bindingFiles>
                        <!-- <wsdlUrls> <value>https://infuseiac.satorisoftware.com/wsdl/IntlAddressCorrection.2012.12.wsdl</value> 
                            </wsdlUrls> -->

                        <!-- Generate JAX-WS 2.0 compatible stubs -->
                        <target>2.0</target>
                    </configuration>
                </execution>
            </executions>
        </plugin>

Here's an example of a generated class without the UID

package com.satorisoftware.ws.infuseiac.intladdresscorrection;

import javax.xml.ws.WebFault;


/**
 * This class was generated by the JAX-WS RI.
 * JAX-WS RI 2.1.7-b01-
 * Generated source version: 2.0
 * 
 */
@WebFault(name = "DuplicateFieldFaultContract", targetNamespace = "infuse.satorisoftware.com/2012/08")
public class IntlAddressCorrectionCorrectDuplicateFieldFaultContractOfInfuseSingleFieldFaultFaultMessage
    extends Exception
{

    /**
     * Java type that goes as soapenv:Fault detail element.
     * 
     */
    private DuplicateFieldFaultContract faultInfo;

    /**
     * 
     * @param message
     * @param faultInfo
     */
    public IntlAddressCorrectionCorrectDuplicateFieldFaultContractOfInfuseSingleFieldFaultFaultMessage(String message, DuplicateFieldFaultContract faultInfo) {
        super(message);
        this.faultInfo = faultInfo;
    }

    /**
     * 
     * @param message
     * @param faultInfo
     * @param cause
     */
    public IntlAddressCorrectionCorrectDuplicateFieldFaultContractOfInfuseSingleFieldFaultFaultMessage(String message, DuplicateFieldFaultContract faultInfo, Throwable cause) {
        super(message, cause);
        this.faultInfo = faultInfo;
    }

    /**
     * 
     * @return
     *     returns fault bean: com.satorisoftware.ws.infuseiac.intladdresscorrection.DuplicateFieldFaultContract
     */
    public DuplicateFieldFaultContract getFaultInfo() {
        return faultInfo;
    }

}

Here's a little bit of the WSDL as requested:

        <xsd:complexType name="DuplicateFieldFaultContract">
            <xsd:annotation>
                <xsd:appinfo>
                    <GenericType xmlns="http://schemas.microsoft.com/2003/10/Serialization/"
                        Name="DuplicateFieldFaultContract" Namespace="infuse.satorisoftware.com/2012/08">
                        <GenericParameter Name="InfuseField"
                            Namespace="http://schemas.datacontract.org/2004/07/Satori.Infuse.Single" />
                    </GenericType>
                </xsd:appinfo>
            </xsd:annotation>
            <xsd:complexContent mixed="false">
                <xsd:extension base="tns:InfuseFaultContract">
                    <xsd:sequence>
                        <xsd:element
                            xmlns:q4="http://schemas.datacontract.org/2004/07/Satori.Infuse.Single"
                            name="DuplicateFields" nillable="true" type="q4:ArrayOfInfuseField" />
                    </xsd:sequence>
                </xsd:extension>
            </xsd:complexContent>
        </xsd:complexType>
        <xsd:element name="DuplicateFieldFaultContract" nillable="true"
            type="tns:DuplicateFieldFaultContract" />
Was it helpful?

Solution

Anders

This is what i understood from the post for WSimport

  1. By default JAXB generated code isn't serializable
  2. We need to add a mechanism to generate a UID which for POjos
  3. It will not create serialVersionUID for Exception classes

wsdl2java, by default the generated exception class will have a serialVersionUID

please try wsdl2java , hope this will solve your issue

OTHER TIPS

Andres

are you not seeing this

private static final long serialVersionUID="1L" ?

Every class generated will be serializable and have the specified uid: a limitation of this process is that each of your generated class will have the same uid.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top