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 "Lanigan, Ronan" <Ro...@ie.fid-intl.com> on 2003/06/23 18:46:29 UTC

Newbie: Making an element required

Is there a way of specifying that an element is required in the Schema of
the wsdl. I have tried using nillable="false", minoccurs = 1.....No matter
what I put in the wsdl, when I use wsdl2java, it goes back to nillable =
"true".

Here are my steps:

1. Write java interface etc.
2. Use java2wsdl to generate wsdl - the schema includes something like this:

	<complexType name="CarListRequest">
		<sequence>
  			<element name="id" nillable="true" type="xsd:string"
/> 
  			<element name="enddate" nillable="true"
type="xsd:dateTime" /> 
  			<element name="maxrecords" type="xsd:int" /> 
  			<element name="number" nillable="true"
type="xsd:string" /> 
  			<element name="sortdirection" nillable="true"
type="xsd:string" /> 
  			<element name="sortfield" nillable="true"
type="xsd:string" /> 
  			<element name="startdate" nillable="true"
type="xsd:dateTime" /> 
  			<element name="startrecord" type="xsd:int" /> 
  		</sequence>
  	</complexType>

    I want the "number" element to be required i.e. it cannot be passed a
null value (I really want to ensure it is exactly 5 numeric characters -
doesn't matter if the rest are null). So I have tried changing the nillable
attribute to "false" among other things. But no matter what I do, the
wsdl2java seems to change it back to <element name="number" nillable="true"
type="xsd:string" />.

I have tried changing it a second time, after the wsdl2java step, but when I
go to the wsdl link (http://localhost:8080/axis/services/service?wsdl) after
deployment, it is back to <element name="number" nillable="true"
type="xsd:string" />. 

Is this something that I should be able to do in the schema or should I
worry about it in the java code?

Thanks in advance.

Ronan