There should not be any issue or anything wrong in using choice. Your
recommendation is correct.
The choice element is used to imply that elements inside the choice
groups are mutual exclusive. 
The use of minOccurs="0" implies the element is optional.

>From what you said the service contract is too vague. It implies that
you need not send any criteria or just one of the criteria or even both.
If that's the intension then it should fine. 

But if the intension is to require only one then choice should be used.
However, there's one catch. Older version of webservice stack (Axis 1.1
etc) which is the default on WAS 5.1 might not support these XML
constructs (like choice, group etc) when it comes to generating java
artifacts WSDLs and hence the provider (if they are using these version)
might have resorted to using minOccurs="0" to work-around and
programmatically enforce the "choice" functionality.


-----Original Message-----
From: Glen Mazza [mailto:[email protected]] 
Sent: Friday, May 15, 2009 10:32 AM
To: [email protected]
Subject: Anything wrong with xsd:choice in WSDLs?


Hello,

At work we're a client to a web service that allows either or both of
two
search criteria for a "Get" SOAP request input that can cause
inconsistent
results when both values are supplied.  They are using an xsd:sequence
with
a minOccurs="0" for both, although supplying neither nor both does not
make
sense for this particular operation.  I am about to recommend that they
switch to xsd:choice, which could be used to enforce exactly one of the
two
input options be used, but first wanted to check whether there's
anything
wrong with usage of xsd:choice within WSDLs in particular.

For example, imagine a web service FindConvenienceStores that allows for
searching by ZIP code and by State (with an xsd:sequence allowing
that)-- it
is not useful to supply both values, and undefined results can happen
when
you supply both a ZIP code and a state that that ZIP code is not in.
I'd
like to recommend they switch to xsd:choice unless I'm missing something
here.

Thanks,
Glen
-- 
View this message in context:
http://www.nabble.com/Anything-wrong-with-xsd%3Achoice-in-WSDLs--tp23562
197p23562197.html
Sent from the cxf-user mailing list archive at Nabble.com.

Reply via email to