Hello list!

I'm using WSDL2Java to reverse engineer Java classes from a WSDL web
service; I'm using Axis2 1.3 to do this. The web service in question is
written by some .Net using colleagues of mine and as the only Java guy
around here I've been asked to look it over before any of our Java using
customers seeit. It all works swimmingly -- they were very impressed how all
the data validation rules came over from the XSD correctly -- with one
exception I've found so far.

The web service in question defines lots of different types and then uses an
instance of these types with the same name as the type itself. For example,
in one of the sub XSD files referenced by the WSDL, I have the following
ComplexType and Element defintions for one of the data types, the Locale of
a geographical point:

<xs:schema  ... >
...
  <xs:complexType name="Locale">
    <xs:annotation>
      <xs:documentation>This type is used to define where somewhere actually
is.</xs:documentation>
    </xs:annotation>
    <xs:sequence>
      <xs:element name="CityGUID" type="ctgCommon:GUID">
        <xs:annotation>
          <xs:documentation>Reference to the city where the parent entity
resides.</xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="DistictGUID" type="ctgCommon:GUID">
        <xs:annotation>
          <xs:documentation>The district in the city where the entity
resides.</xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="ResortGUID" type="ctgCommon:GUID">
        <xs:annotation>
          <xs:documentation>Reference to the city where the parent entity
resides.</xs:documentation>
        </xs:annotation>
      </xs:element>
    </xs:sequence>
  </xs:complexType>
...
  <xs:element name="Locale" type="Locale">
    <xs:annotation>
      <xs:documentation>Instance of Locale which defines where the parent
entity resides.</xs:documentation>
    </xs:annotation>
  </xs:element>
...
</xs:schema>

There are more ComplexType and SimpleType defintions, and more Element
defintions, where I have put "..." in.

When I reverse engineer this through WSDL2Java, I get two classes: one,
Locale.java, is the ComplexType declaration. The other is called
Locale120.java and is the instance of the datatype defined in the xs:element
tag; in the class, I see:
    protected net.ctg.schemas.v3_0.geography.Locale localLocale;
i.e. the Locale120 class contains an instance of the Locale class. This
makes sense to me.

As far as I can see this all works perfectly with only one problem. I can
understand that Axis had to change one of the two class names to avoid a
conflict, but where did the number "120" come from? I'm concerned that, if I
developed to the classes that come out of WSDL2Java, I would write code that
performed work on Locale120.java; then, when a new version of the web
service shipped and I regenerated my Java data classes, that "120" value may
change and all my existing code against those classes would break. It would
be ideal if I could specify the suffix, just the fixed string "Value" or
something similar would do the job.

So, am I right in thinking there is a problem here, and what can I do to
address it? Is the underlying WSDL wrong or can I adjust Axis's behaviour to
get around the problem?

Reply via email to