axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Davanum Srinivas (JIRA)" <>
Subject [jira] Commented: (AXIS-1437) Wrong behavior on <xsd:choice>
Date Sat, 11 Jun 2005 12:39:47 GMT
    [ ] 

Davanum Srinivas commented on AXIS-1437:

Can someone please upload a complete wsdl?


> Wrong behavior on <xsd:choice>
> ------------------------------
>          Key: AXIS-1437
>          URL:
>      Project: Apache Axis
>         Type: Bug
>   Components: Serialization/Deserialization
>     Versions: 1.1
>  Environment: Win2000/PC/JDK1.4
>     Reporter: easyproglife

> I see Axis client wrong behavior on serializing a message built from schema with xsd:choice.
> I have XML schema with <xsd:choice>:
> <xsd:complexType name="getSubscriberRequest">
>   <xsd:choice minOccurs="0">
>     <xsd:element name="customerID" type="cc:customer"/>
>     <xsd:element name="phoneNumber" type="cc:serviceDetails"/>
>     <xsd:element name="status" type="cc:serviceStatusEnum"/>
>     <xsd:element name="phoneType" type="cc:phoneTypeEnum"/>
>   </xsd:choice>
> </xsd:complexType>
> (The business logic idea is to request some data according to one and only one parameter
(i.e. status, phoneNumber, etc.)).
> In the client code, I do the following:
> GetSubscriberRequest req = new GetSubscriberRequest();		
> req.setPhoneNumber(new ServiceDetails("9412345678"));		
> GetSubscriberResponse res = stub.getSubscriber(req);
> The XML message over the wire is:
> <?xml version="1.0" encoding="UTF-8"?>
> <soapenv:Envelope xmlns:soapenv="" xmlns:xsd=""
>  <soapenv:Body>
>   <getSubscriberRequest xmlns="">
>    <customerID xsi:nil="true"/>
>    <phoneNumber>941234567</phoneNumber>
>    <status xsi:nil="true"/>
>    <phoneType xsi:nil="true"/>
>   </getSubscriberRequest>
>  </soapenv:Body>
> </soapenv:Envelope>
> I am using Castor at the server side, and it fails on validation:
> ValidationException: The element 'phoneNumber' cannot exist at the same time that element
'customerID' also exists.;
>    - location of error: XPATH: getSubscriberRequest
> Castor behavior seems ok to me, since xsd:choice by definition should allow ONLY ONE
ELEMENT of its subelements.
> The wrong behavior, for my opinion, is in Axis. It produces elements with xsi:nil="true"
(in xsd:choice) instead of not generating them at all.
> Looking at the source code, I see that org.apache.axis.encoding.SerializationContext.serialize()
(line 115) get 6 parameters. The one before the last one is "sendNull". If it is false, the
Axis behavior would be perfect for my situation!
> The problem is the all the built-it serializers (i.e. BeanSerializer, line 238) sends
hard-coded "true" for this parameter, hence force Axis to generate an empty element with xsi:nil="true",
that is invalid and cause Castor validation to fail.
> For my opinion, there should be a configurable parameter the controls the behavior of
"sendNull" parameter in SerializationContext. 
> I think that on xsd:choice, the default behavior must be to ommit the null elements at

This message is automatically generated by JIRA.
If you think it was sent incorrectly contact one of the administrators:
For more information on JIRA, see:

View raw message