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 Miguel Sanders1 <mi...@be.ibm.com> on 2013/06/05 20:46:10 UTC

[Axis2] Question on xsd restriction

Hi guys

I've been asked recently to publish some of our existing POJOs as 
webservices using Axis2.
I'm really impressed how easy this is so thanks a lot for this great 
effort.

However, there's one thing I am currently unable to do, concerning the use 
of xsd:restrictions for my string elements (maxLength).
Currently, the generated schema from the WSDL looks like this:

       <xs:schema attributeFormDefault="qualified" 
elementFormDefault="qualified" targetNamespace="http://dps.tsm.ibm.com/xsd
">
            <xs:complexType name="ArchiveRequest">
                <xs:sequence>
                    <xs:element minOccurs="0" name="archiveFileRequest" 
nillable="true" type="ax225:ArchiveFileRequest"/>
                </xs:sequence>
            </xs:complexType>
            <xs:complexType name="ArchiveFileRequest">
                <xs:sequence>
                    <xs:element minOccurs="0" name="checksumType" 
nillable="true" type="xs:string"/>
                    <xs:element minOccurs="0" name="checksumValue" 
nillable="true" type="xs:string"/>
                    <xs:element minOccurs="0" name="fileName" 
nillable="true" type="xs:string"/>
                    <xs:element minOccurs="0" name="overwrite" 
type="xs:boolean"/>
                    <xs:element minOccurs="0" name="tsmDescription" 
nillable="true" type="xs:string"/>
                    <xs:element minOccurs="0" name="tsmFileSpaceName" 
nillable="true" type="xs:string"/>
                    <xs:element minOccurs="0" name="tsmHighLevelName" 
nillable="true" type="xs:string"/>
                    <xs:element minOccurs="0" name="tsmLowLevelName" 
nillable="true" type="xs:string"/>
                    <xs:element minOccurs="0" name="tsmManagementClass" 
nillable="true" type="xs:string"/>
                </xs:sequence>
            </xs:complexType>
            <xs:complexType name="ArchiveResponse">
                <xs:sequence>
                    <xs:element minOccurs="0" name="archiveFileRequest" 
nillable="true" type="ax225:ArchiveFileRequest"/>
                    <xs:element minOccurs="0" name="archiveFileResponse" 
nillable="true" type="ax225:ArchiveFileResponse"/>
                    <xs:element minOccurs="0" name="resultCode" 
type="xs:int"/>
                    <xs:element minOccurs="0" name="resultMessage" 
nillable="true" type="xs:string"/>
                </xs:sequence>
            </xs:complexType>
            <xs:complexType name="ArchiveFileResponse">
                <xs:sequence>
                    <xs:element minOccurs="0" name="checksumValue" 
nillable="true" type="xs:string"/>
                    <xs:element minOccurs="0" name="tsmObjectArchiveDate" 
nillable="true" type="xs:dateTime"/>
                    <xs:element minOccurs="0" name="tsmObjectID" 
type="xs:long"/>
                </xs:sequence>
            </xs:complexType>
        </xs:schema>

However, for certain string elements in ArchiveFileRequest, I would like 
to enforce a restriction based on the maximum length of the string.
Is there a way for the generated XSD to have this enforced from the POJO 
source?
I have been reading about annotations but it's not really clear if this 
works out of the box with Axis2 or if I need another module to have this.

Any help is appreciated.



Regards,
 
Miguel Sanders
TWS/TSAMP Specialist

Phone: 32-2 339 24 21 | Mobile: 32-478 80 50 23
E-mail: miguel.sanders@be.ibm.com


Avenue Du Bourget, 42
Brussels, 1130
Belgium


International Business Machines of Belgium sprl / bvba
Siège social / Maatschappelijke zetel: Avenue du Bourget 42 Bourgetlaan, 
B-1130 Bruxelles/Brussel
N° d'entreprise / Ondernemingsnr: TVA / BTW BE 0405 912 336
RPM Bruxelles / RPR Brussel

Tenzij hierboven anders aangegeven: / Sauf indication contraire ci-dessus: 
/ Unless otherwise stated above:

International Business Machines of Belgium sprl / bvba
Siège social / Maatschappelijke zetel: Avenue du Bourget 42 Bourgetlaan, 
B-1130 Bruxelles/Brussel
N° d'entreprise / Ondernemingsnr: TVA / BTW BE 0405 912 336
RPM Bruxelles / RPR Brussel

RE: [Axis2] Question on xsd restriction

Posted by Miguel Sanders1 <mi...@be.ibm.com>.
Hi Martin

I know how xsd restrictions work but I was just wondering if we can 
enforce this from the POJO source code (by use of annotations).

Thanks for your help



Regards,
 
Miguel Sanders
TWS/TSAMP Specialist

Phone: 32-2 339 24 21 | Mobile: 32-478 80 50 23
E-mail: miguel.sanders@be.ibm.com


Avenue Du Bourget, 42
Brussels, 1130
Belgium


International Business Machines of Belgium sprl / bvba
Siège social / Maatschappelijke zetel: Avenue du Bourget 42 Bourgetlaan, 
B-1130 Bruxelles/Brussel
N° d'entreprise / Ondernemingsnr: TVA / BTW BE 0405 912 336
RPM Bruxelles / RPR Brussel



From:   Martin Gainty <mg...@hotmail.com>
To:     Miguel Sanders1/Belgium/IBM@IBMBE, 
Date:   06/06/2013 00:32
Subject:        RE: [Axis2] Question on xsd restriction



<!-- definition of the restricted string -->
 <xs:simpleType name="restrictedLength">
 <xs:restriction base="xs:string"> 
       <xs:maxLength value="4" />
 </xs:restriction> 
</xs:simpleType>
 <!-- definition for the element with an attribute and text content -->
 <xs:element name="Xyz">
 <xs:complexType>
  <xs:simpleContent> <xs:extension base="restrictedLength">
   <xs:attribute name="YES" use="required"/>
 </xs:extension> 
</xs:simpleContent>
 </xs:complexType> 
</xs:element> 

Saludos Cordiales desde EEUU
Martin Gainty 
______________________________________________ 
Porfavor...no altere ni interrumpir esta communicacion..Gracias


To: java-user@axis.apache.org
Subject: [Axis2] Question on xsd restriction 
From: miguel.sanders@be.ibm.com
Date: Wed, 5 Jun 2013 20:46:10 +0200

Hi guys 

I've been asked recently to publish some of our existing POJOs as 
webservices using Axis2. 
I'm really impressed how easy this is so thanks a lot for this great 
effort. 

However, there's one thing I am currently unable to do, concerning the use 
of xsd:restrictions for my string elements (maxLength). 
Currently, the generated schema from the WSDL looks like this: 

       <xs:schema attributeFormDefault="qualified" 
elementFormDefault="qualified" targetNamespace="http://dps.tsm.ibm.com/xsd
"> 
            <xs:complexType name="ArchiveRequest"> 
                <xs:sequence> 
                    <xs:element minOccurs="0" name="archiveFileRequest" 
nillable="true" type="ax225:ArchiveFileRequest"/> 
                </xs:sequence> 
            </xs:complexType> 
            <xs:complexType name="ArchiveFileRequest"> 
                <xs:sequence> 
                    <xs:element minOccurs="0" name="checksumType" 
nillable="true" type="xs:string"/> 
                    <xs:element minOccurs="0" name="checksumValue" 
nillable="true" type="xs:string"/> 
                    <xs:element minOccurs="0" name="fileName" 
nillable="true" type="xs:string"/> 
                    <xs:element minOccurs="0" name="overwrite" 
type="xs:boolean"/> 
                    <xs:element minOccurs="0" name="tsmDescription" 
nillable="true" type="xs:string"/> 
                    <xs:element minOccurs="0" name="tsmFileSpaceName" 
nillable="true" type="xs:string"/> 
                    <xs:element minOccurs="0" name="tsmHighLevelName" 
nillable="true" type="xs:string"/> 
                    <xs:element minOccurs="0" name="tsmLowLevelName" 
nillable="true" type="xs:string"/> 
                    <xs:element minOccurs="0" name="tsmManagementClass" 
nillable="true" type="xs:string"/> 
                </xs:sequence> 
            </xs:complexType> 
            <xs:complexType name="ArchiveResponse"> 
                <xs:sequence> 
                    <xs:element minOccurs="0" name="archiveFileRequest" 
nillable="true" type="ax225:ArchiveFileRequest"/> 
                    <xs:element minOccurs="0" name="archiveFileResponse" 
nillable="true" type="ax225:ArchiveFileResponse"/> 
                    <xs:element minOccurs="0" name="resultCode" 
type="xs:int"/> 
                    <xs:element minOccurs="0" name="resultMessage" 
nillable="true" type="xs:string"/> 
                </xs:sequence> 
            </xs:complexType> 
            <xs:complexType name="ArchiveFileResponse"> 
                <xs:sequence> 
                    <xs:element minOccurs="0" name="checksumValue" 
nillable="true" type="xs:string"/> 
                    <xs:element minOccurs="0" name="tsmObjectArchiveDate" 
nillable="true" type="xs:dateTime"/> 
                    <xs:element minOccurs="0" name="tsmObjectID" 
type="xs:long"/> 
                </xs:sequence> 
            </xs:complexType> 
        </xs:schema> 

However, for certain string elements in ArchiveFileRequest, I would like 
to enforce a restriction based on the maximum length of the string. 
Is there a way for the generated XSD to have this enforced from the POJO 
source? 
I have been reading about annotations but it's not really clear if this 
works out of the box with Axis2 or if I need another module to have this. 

Any help is appreciated. 



Regards,   
Miguel Sanders
TWS/TSAMP Specialist 

Phone: 32-2 339 24 21 | Mobile: 32-478 80 50 23
E-mail: miguel.sanders@be.ibm.com 


Avenue Du Bourget, 42
Brussels, 1130
Belgium



International Business Machines of Belgium sprl / bvba
Siège social / Maatschappelijke zetel: Avenue du Bourget 42 Bourgetlaan, 
B-1130 Bruxelles/Brussel
N° d'entreprise / Ondernemingsnr: TVA / BTW BE 0405 912 336
RPM Bruxelles / RPR Brussel

Tenzij hierboven anders aangegeven: / Sauf indication contraire ci-dessus: 
/ Unless otherwise stated above:

International Business Machines of Belgium sprl / bvba
Siège social / Maatschappelijke zetel: Avenue du Bourget 42 Bourgetlaan, 
B-1130 Bruxelles/Brussel
N° d'entreprise / Ondernemingsnr: TVA / BTW BE 0405 912 336
RPM Bruxelles / RPR Brussel


Tenzij hierboven anders aangegeven: / Sauf indication contraire ci-dessus: 
/ Unless otherwise stated above:

International Business Machines of Belgium sprl / bvba
Siège social / Maatschappelijke zetel: Avenue du Bourget 42 Bourgetlaan, 
B-1130 Bruxelles/Brussel
N° d'entreprise / Ondernemingsnr: TVA / BTW BE 0405 912 336
RPM Bruxelles / RPR Brussel