1

I'm trying to connect to a C#/NET (*.svc) webservice. I have to use java, thus wsdl2java is my choice.

Problem: somehow the targeting webservice defines lots of elements dublicate. This might be due to the nature of C# or whatever.

There are like 100+ elements as follows:

<xs:complexType name="Ticket">
    <xs:sequence>
        <xs:element minOccurs="0" name="ASegment"
            nillable="true" type="tns:AnArray" />
    </xs:sequence>
</xs:complexType>
<xs:element name="Ticket" nillable="true" type="tns:Ticket" />

Resulting in:

'Ticket' is already defined (org.apache.cxf:cxf-codegen-plugin:3.0.1:wsdl2java:generate-sources:generate-sources)

How can I cope with this? I read about a jaxb-binding.xml file, where I can "rename" specific elements explicit.

But if I apply this for 100+ elements, well the week has only 5 days...

Is there any way I can though auto generate the classes?

membersound
  • 66,525
  • 139
  • 452
  • 886

1 Answers1

2

Please see this answer:

Prefixing JAXB generated classes

jaxb:nameXmlTransform is your friend.

I normally do <jaxb:elementName suffix="Element"/>.

Community
  • 1
  • 1
lexicore
  • 39,549
  • 12
  • 108
  • 193
  • Interesting. Is it also possible to append a `suffix="Type"` on each `xs:complexType` element?? – membersound Sep 22 '14 at 17:44
  • 1
    Because, if every element is appended the suffix as you described, that would not be of any help for me, as the same-named `xs:complexType` and `xs:element` occur right after each other inside the same wsdl/xsd files. – membersound Sep 22 '14 at 17:49
  • 1
    I'm not sure what the problem is. If you define `elementName` with suffix then elements will be suffixed and types - not. Should be no collissions with that. Anyway, there's also `typeName`, please do read the links I posted. – lexicore Sep 22 '14 at 18:23