1

I have a wsdl that I am generating classes from using wsimport.

I have a need for some of the classes to implement an interface that is defined in another framework.

I was told by a Java developer that this was possible using a wsimport option. I assume that option is -b.

Could not find documentation on how to create a binding file to do what I need. All examples show how to change the packagename.

Below is an example of what I need

Example WSDL

<xsd:complexType name="GetAandBRequest">
<xsd:sequence>
  <xsd:element name="A" type="xsd:int" />
  <xsd:element name="B" type="xsd:int" />
  </xsd:sequence>
</xsd:complexType>

WSImport generates

    public class GetAandBRequest {
    protected int a;
    protected int b;

    public int getA() {
        return a;
    }
    public void setA(int value) {
        this.a = value;
    }
    public int getB() {
        return storeNum;
    }
   public void setB(int value) {
        this.b = value;
    }
    }

What I need from wsimport is:

public class GetAandBRequest implements IMessage {
    protected int a;
    protected int b;

    public int getA() {
        return a;
    }
    public void setA(int value) {
        this.a = value;
    }
    public int getB() {
        return storeNum;
    }
   public void setB(int value) {
        this.b = value;
    }
}

Notice the implements IMessage.

Is this possible with wsimport? If not possible how do you get around something like this. There are many messages. I don't want to have to manually add an implements IMessage everytime I need to regenerate the wsdl and schemas.

Much thanks in advance...

John
  • 203
  • 2
  • 7

1 Answers1

1

xjc options could be passed to wsimport

google xjc inheritance or jaxb2 inheritance

<jaxb:bindings version="1.0"
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"

xmlns:inheritance="http://jaxb2-commons.dev.java.net/basic/inheritance"
jaxb:extensionBindingPrefixes="inheritance">

<jaxb:bindings schemaLocation="customer.xsd" node="/xsd:schema">
    <jaxb:bindings node="xsd:complexType[@name='customer']">
        <inheritance:implements>com.acme.foo.Actor</inheritance:implements>
    </jaxb:bindings>
</jaxb:bindings>

See

http://confluence.highsource.org/display/J2B/Using+JAXB2+Basics+Plugins+with+CXF

http://confluence.highsource.org/display/J2B/JAXB2+Basics+Plugins

http://www.javaworld.com/article/2074330/core-java/adding-common-methods-to-jaxb-generated-java-classes--jaxb2-basics-plugins-.html

Kalpesh Soni
  • 6,879
  • 2
  • 56
  • 59
  • wsimport uses a different binding format that doesn't have `extensionBindingPrefixes` http://stackoverflow.com/q/39640430/476716 – OrangeDog Sep 22 '16 at 13:38