This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

data constraint does not work

 
jim li
Ranch Hand
Posts: 180
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 180
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 180
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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>?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic