You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by "Davanum Srinivas (JIRA)" <ax...@ws.apache.org> on 2005/06/11 14:39:47 UTC
[jira] Commented: (AXIS-1437) Wrong behavior on
[ http://issues.apache.org/jira/browse/AXIS-1437?page=comments#action_12313368 ]
Davanum Srinivas commented on AXIS-1437:
----------------------------------------
Can someone please upload a complete wsdl?
thanks,
dims
> Wrong behavior on <xsd:choice>
> ------------------------------
>
> Key: AXIS-1437
> URL: http://issues.apache.org/jira/browse/AXIS-1437
> 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="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
> <soapenv:Body>
> <getSubscriberRequest xmlns="http://www.xxx.com/yyy">
> <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 all!
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira