| Author |
data constraint does not work
|
jim li
Ranch Hand
Joined: May 20, 2008
Posts: 177
|
|
Hi
i have the following data constraints:
<xs:simpleType name="CHAR1_TYPE">
<xs:restriction base="xs:string">
<xs:minLength value="1"/>
<xs:maxLength value="1"/>
</xs:restriction>
</xs:simpleType>
it is applied to my .xsd schema.
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:tns="http://yang.tao/Test" xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://yang.tao/Test" version="1.0">
<xs:include schemaLocation="datatype.xsd"/>
<xs:element name="getPersonInfo" type="tns:personInfo" nillable="true"/>
<xs:element name="getPersonInfoResponse" type="xs:string" nillable="true"/>
<xs:complexType name="personInfo">
<xs:sequence>
<xs:element name="firstName" type="tns:CHAR1_TYPE"/>
<xs:element name="lastName" type="tns:CHAR10_TYPE"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
but when i run the web service , i am still able to input more than one chars, can anyone please tell me how to make the constraints work?
|
 |
sarbjeet sidhu
Greenhorn
Joined: Jan 24, 2010
Posts: 11
|
|
Hi,
Try the following, this should work.
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:tns="http://yang.tao/Test" xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://yang.tao/Test" version="1.0">
<xs:include schemaLocation="datatype.xsd"/>
<xs:element name="getPersonInfo" type="tns:personInfo" nillable="true"/>
<xs:element name="getPersonInfoResponse" type="xs:string" nillable="true"/>
<xs:complexType name="personInfo">
<xs:sequence>
<xs:element name="firstName" nillable="true">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:maxLength value="20" />
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xs:element name="lastName" nillable="true">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:maxLength value="20" />
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
</xs:sequence>
</xs:complexType>
</xs:schema>
Thanks
:thumbup:
|
 |
jim li
Ranch Hand
Joined: May 20, 2008
Posts: 177
|
|
thank you for help
but i need a separate file to contains all the data constraints so that they are reusable.
can you give me some suggestions?
|
 |
jim li
Ranch Hand
Joined: May 20, 2008
Posts: 177
|
|
|
i pointed my web service to the existing wsdl file with the data constraints, but it does not throw any exception , can anyone tell me why>?
|
 |
 |
|
|
subject: data constraint does not work
|
|
|