Hi

We have several wsdl and xsd files from customer and we are using
Axis2 v1.3WSDL2Java task to create client part of Java classes to call
Web Services.

One problematic part of generated code commes from XSD code:

    <xsd:simpleType name="WSTypeDate">
        <xsd:restriction base="xsd:date">
            <xsd:pattern value='[0-9]{4}-[0-9]{2}-[0-9]{2}'/>
        </xsd:restriction>
    </xsd:simpleType>

    <xsd:simpleType name="WSTypeTime8">
        <xsd:restriction base="xsd:string">
            <xsd:maxLength value="6"/>
            <xsd:pattern value='[0-9]{2}:[0-9]{2}:[0-9]{2}'/>
        </xsd:restriction>
    </xsd:simpleType>

    <xsd:simpleType name="WSTypeDateTime">
        <xsd:restriction base="xsd:dateTime">
            <xsd:pattern
value='[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}'/>
        </xsd:restriction>
    </xsd:simpleType>

    <xsd:simpleType name="WSTypeUID38">
        <xsd:restriction base="xsd:string">
            <xsd:pattern
value='\{[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}\}'/>
        </xsd:restriction>
    </xsd:simpleType>



Created classes WSTypeDate, WSTypeTime8, WSTypeDateTime, WSTypeUID38 have
setter methods like:

    public void setWSTypeDate(java.util.Date param) {
        if 
(java.lang.String.valueOf(param).matches("[0-9]{4}-[0-9]{2}-[0-9]{2}"))
{
            this.localWSTypeDate = param;
        } else {
            throw new java.lang.RuntimeException();
        }
    }

    public void setWSTypeTime8(java.lang.String param) {
        if 
(java.lang.String.valueOf(param).matches("[0-9]{2}:[0-9]{2}:[0-9]{2}"))
{
            this.localWSTypeTime8 = param;
        } else {
            throw new java.lang.RuntimeException();
        }
    }

    public void setWSTypeDateTime(java.util.Calendar param) {
        if (java.lang.String.valueOf(param)

.matches("[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}")) {
            this.localWSTypeDateTime = param;
        } else {
            throw new java.lang.RuntimeException();
        }
    }

    public void setWSTypeUID38(java.lang.String param) {
        if (java.lang.String.valueOf(param)

.matches("\\{[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}\\}"))
{
            this.localWSTypeUID38 = param;
        } else {
            throw new java.lang.RuntimeException();
        }
    }


When given parameter is String, then the matching of pattern is OK, BUT if
it is Date or Calendar then it is problem due to used String.valueOf(param)
because Date.toString() and Calendar.toString() alaways use same String
pattern which never match given pattern and furthermore in that case there
is no sense to check any pattern.

My question is: Is it a bug of WSDL2Java task to create this part of code
when XSD use restriction base xsd:date or xsd:dateTime or is it a feature? I
think it is a bug.

Thank you
Regards

-- 
Jozef Krššák

Reply via email to