You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Juha Kononen <Ju...@savonia-amk.fi> on 2005/09/11 01:55:11 UTC

WSDL2Java doesn't work correctly in some situations

Hi, this email is a continuation of my previous topic 'Is there coming a
schema support for facets, lists and regular expressions in Axis?.
I'm at the moment a little bit confused as to generating Java classes
with WSDL2Java.
It seems that the WSDL2Java functions incorrectly when it has to handle
facets, lists and regular expressions.
Here are three examples of the schema definitions I use but which don't
work with WSDL2Java. 

1) Facet and Regular Expression problem 


   <xs:simpleType name="AddressPartType">
      <xs:annotation>
         <xs:documentation>vocSet: D10642
(C-0-D10642-cpt)</xs:documentation>
      </xs:annotation>
      <xs:union memberTypes="AdditionalLocator DeliveryAddressLine
StreetAddressLine">
         <xs:simpleType>
            <xs:restriction base="cs">
               <xs:enumeration value="CAR"/>
               <xs:enumeration value="CEN"/>
               <xs:enumeration value="CNT"/>
               <xs:enumeration value="CPA"/>
               <xs:enumeration value="CTY"/>
               <xs:enumeration value="DEL"/>
               <xs:enumeration value="POB"/>
               <xs:enumeration value="PRE"/>
               <xs:enumeration value="STA"/>
               <xs:enumeration value="ZIP"/>
            </xs:restriction>
         </xs:simpleType>
      </xs:union>
   </xs:simpleType>

<xs:simpleType name="AdditionalLocator">
      <xs:annotation>
         <xs:documentation>specDomain: V10651
(C-0-D10642-V10651-cpt)</xs:documentation>
      </xs:annotation>
      <xs:restriction base="cs">
         <xs:enumeration value="ADL"/>
         <xs:enumeration value="UNID"/>
         <xs:enumeration value="UNIT"/>
      </xs:restriction>
   </xs:simpleType>

<xs:simpleType name="cs">
      <xs:annotation>
         <xs:documentation>
            Coded data in its simplest form, consists of a code.
            The code system and code system version is fixed by
            the context in which the CS value occurs. CS is used
            for coded attributes that have a single HL7-defined
            value set.
         </xs:documentation>
      </xs:annotation>
      <xs:restriction base="xs:token">
         <xs:pattern value="[^\s]+"/>
      </xs:restriction>
   </xs:simpleType>

And the WSDL2Java generates the following class of type
AddressPartType. 

public class AddressPartType  implements java.io.Serializable,
org.apache.axis.encoding.SimpleType {
    private java.lang.String _value;
    public AddressPartType() {
    }

    // Simple Types must have a String constructor
    public AddressPartType(java.lang.String _value) {
        this._value = _value;
    }
    public AddressPartType(org.apache.axis.types.Token _value) {
        setAdditionalLocatorValue(_value);
    }

    public AddressPartType(org.apache.axis.types.Token _value) {
        setDeliveryAddressLineValue(_value);
    }

    public AddressPartType(v3.hl7_org.StreetAddressLine _value) {
        setStreetAddressLineValue(_value);
    }

    // Simple Types must have a toString for serializing the value
    public java.lang.String toString() {
        return _value;
    }

   public void setAdditionalLocatorValue(org.apache.axis.types.Token
_value) {
        this._value = _value == null ? null : _value.toString();
    }

 .....
.....

As you can see the WSDL2Java has generated two identical constructors
(with the org.apache.axis.types.Token parameters) which is an error in
Java.
Axis recognizes the "xs:token" type by using the
org.apache.axis.types.Token type but misses facets like <xs:enumeration
value="ADL"/>


2) List problem


<xs:complexType name="TEL">
      <xs:annotation>
         <xs:documentation>
            A telephone number (voice or fax), e-mail address, or
            other locator for a resource (information or service)
            mediated by telecommunication equipment. The address
            is specified as a Universal Resource Locator (URL)
            qualified by time specification and use codes that help
            in deciding which address to use for a given time and
            purpose.
         </xs:documentation>
      </xs:annotation>
      <xs:complexContent>
         <xs:extension base="URL">
            <xs:sequence>
               <xs:element name="useablePeriod" minOccurs="0"
maxOccurs="unbounded" type="SXCM_TS">
                  <xs:annotation>
                     <xs:documentation>
                     Specifies the periods of time during which the
                     telecommunication address can be used.  For a
                     telephone number, this can indicate the time of
day
                     in which the party can be reached on that
telephone.
                     For a web address, it may specify a time range in
                     which the web content is promised to be available
                     under the given address.
                  </xs:documentation>
                  </xs:annotation>
               </xs:element>
            </xs:sequence>

            <xs:attribute name="use" use="optional"
type="set_TelecommunicationAddressUse">
               <xs:annotation>
                  <xs:documentation>
                     One or more codes advising a system or user which
                     telecommunication address in a set of like
addresses
                     to select for a given telecommunication need.
                  </xs:documentation>
               </xs:annotation>
            </xs:attribute>


         </xs:extension>
      </xs:complexContent>
   </xs:complexType>


 <xs:simpleType name="set_TelecommunicationAddressUse">
      <xs:list itemType="TelecommunicationAddressUse"/>
   </xs:simpleType

<xs:simpleType name="TelecommunicationAddressUse">
      <xs:annotation>
         <xs:documentation>vocSet: D201
(C-0-D201-cpt)</xs:documentation>
      </xs:annotation>
      <xs:union memberTypes="AddressUse">
         <xs:simpleType>
            <xs:restriction base="cs">
               <xs:enumeration value="AS"/>
               <xs:enumeration value="EC"/>
               <xs:enumeration value="MC"/>
               <xs:enumeration value="PG"/>
            </xs:restriction>
         </xs:simpleType>
      </xs:union>
   </xs:simpleType>

And the WSDL2Java generates the following class of type TEL.

public class TEL  extends v3.hl7_org.URL  implements
java.io.Serializable {
    /** Specifies the periods of time during which the
 *                      telecommunication address can be used.  For a
 * telephone number, this can indicate the time of day
 *                      in which the party can be reached on that
telephone.
 * For a web address, it may specify a time range in
 *                      which the web content is promised to be
available
 * under the given address. */
    private v3.hl7_org.SXCM_TS[] useablePeriod;
    private v3.hl7_org.TelecommunicationAddressUse[] use;  //
attribute

    public TEL() {
    }

    public TEL(
           v3.hl7_org.SXCM_TS[] useablePeriod,
           v3.hl7_org.TelecommunicationAddressUse[] use) {
           this.useablePeriod = useablePeriod;
           this.use = use;
    }

   public void setUse(v3.hl7_org.TelecommunicationAddressUse[] use) {
        this.use = use;
    }
   .....
   .....

Here WSDL2Java has generated the 'use' attribute like it was
represented in the schema. But for some reason the WSDL2Java doesn't
create
the 'TelecommunicationAddressUse' class. It creates only the 'use'
attribute of type TelecommunicationAddressUse but misses the creation of
the
actual class. So the developer has to create it on behalf of the
WSDL2Java. Notice also that the WSDL2Java has interpreted the <xs:list
itemType="TelecommunicationAddressUse"/> definition
as a Java array but the code for handling lists is missing.


3) Funny naming clash problem

<xs:simpleType name="real"> 
      <xs:annotation>
         <xs:documentation>
            Fractional numbers. Typically used whenever quantities
            are measured, estimated, or computed from other real
            numbers.  The typical representation is decimal, where
            the number of significant decimal digits is known as the
            precision. Real numbers are needed beyond integers
            whenever quantities of the real world are measured,
            estimated, or computed from other real numbers. The term
            "Real number" in this specification is used to mean
            that fractional values are covered without necessarily
            implying the full set of the mathematical real numbers.
         </xs:documentation>
      </xs:annotation>
      <xs:union memberTypes="xs:decimal xs:double"/>
 </xs:simpleType>

<xs:complexType name="REAL">
      <xs:annotation>
         <xs:documentation>
            Fractional numbers. Typically used whenever quantities
            are measured, estimated, or computed from other real
            numbers.  The typical representation is decimal, where
            the number of significant decimal digits is known as the
            precision. Real numbers are needed beyond integers
            whenever quantities of the real world are measured,
            estimated, or computed from other real numbers. The term
            "Real number" in this specification is used to mean
            that fractional values are covered without necessarily
            implying the full set of the mathematical real numbers.
         </xs:documentation>
         <xs:appinfo>
            <diff>REAL</diff>
            <sch:pattern name="validate REAL">
               <sch:rule abstract="true" id="rule-REAL">
                  <sch:report test="(@nullFlavor or @value) and
not(@nullFlavor and @value)"/>
               </sch:rule>
            </sch:pattern>
         </xs:appinfo>
      </xs:annotation>
      <xs:complexContent>
         <xs:extension base="QTY">
            <xs:attribute name="value" use="optional" type="real"/>
         </xs:extension>
      </xs:complexContent>
   </xs:complexType>

Here we have two types (real and REAL) with the same names but
different letter sizes. Well, when the WSDL2Java interprets this it
generates two classes named 'Real' and 'REAL'. But because Windows XP
doesn't distinguish between uppercase and lowercase in file names, the
WSDL2Java creates a REAL.java file and saves it over the Real.java file
created. :) When compiling the generated Java classes I get a lot of
errors because of the references to the missing Real class. Isn't that
funny? :=) I guess this naming clash is not a problem in Unix? 

I hope you can help me.

Juha