You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@axis.apache.org by "Steve Hardy (JIRA)" <ax...@ws.apache.org> on 2004/12/20 14:22:17 UTC

[jira] Commented: (AXISCPP-250) Errors in handling minOccurs="0" (optional) elemnts in SOAP message

     [ http://nagoya.apache.org/jira/browse/AXISCPP-250?page=comments#action_56891 ]
     
Steve Hardy commented on AXISCPP-250:
-------------------------------------

The same thing happens when you have a

<xs:choice>
  <xs:element name="a" type="xsd:int">
  <xs:element name="b" tpye="xsd:int">
</xs:choice>

because you have minOccurs = 0 for all the fields.

Also, there is no way of creating the struct (class) in c++ to show that a simple type is 'missing'. ie you can't set 'a' to NULL because it is not a pointer. 

The best option would be to have a union-like structure like

struct choice {
  enum type { a,b };
  union {
    int a;
    int b;
  } value;
}

and have the serialiser / deserialiser only send/receive the one field that we want transmitting / receiving. I currently send a union struct with about 20 fields, of which only ever 1 is used. This is currently transmitted as zero's in all the unused fields, which is rather wasteful.

> Errors in handling minOccurs="0" (optional) elemnts in SOAP message
> -------------------------------------------------------------------
>
>          Key: AXISCPP-250
>          URL: http://nagoya.apache.org/jira/browse/AXISCPP-250
>      Project: Axis-C++
>         Type: Bug
>   Components: Serialization/Deserialization
>     Versions: 1.3 Final
>  Environment: All platforrms
>     Reporter: Samisa Abeysinghe
>     Priority: Critical
>  Attachments: WS021A.wsdl
>
> The following is from the mailing list. See http://marc.theaimsgroup.com/?t=109902729200001&r=1&w=2 for more information :
> > All elements in the response have minOccurs="0", so they can be 
> omitted. Is this another issue?
> Good point Adrian! I missed that :(.
> This must be the reason that is causing the problem.
> To my knowledge, WSDL2Ws tool does not deal with this correctly (I came 
> to this conclusion by
> looking at the generated code for the WSDL). It expects all the 
> elements to be there, and throws
> an error, if at least a single element is missing.
> Also, the ordering of the element is very critical for the generated 
> code to work.
> e.g.
> param->names = (xsd__string_Array&)pIWSDZ->getBasicArray(XSD_STRING, 
> "names",0);
> param->addrs = (xsd__string_Array&)pIWSDZ->getBasicArray(XSD_STRING, 
> "addrs",0);
> param->xdirInd = pIWSDZ->getElementAsString("xdirInd",0);
> param->noOfBillRecords = pIWSDZ->getElementAsInt("noOfBillRecords",0);
> (the '0' parameters in above code indicates that namespace is NULL - it 
> must have used NULL
> instead of 0)
> If "xdirInd" is missing in the response, and "noOfBillRecords" is 
> present,
> getElementAsString("xdirInd",0) call on the serializer will see that 
> next element is
> "noOfBillRecords" and will error. 
> If we are looking for an optional element, we are doing a serious 
> mistake here (and thus this is a
> serious bug)
> The correct logic would be to 
> 1. Test if the element is opetional
>    if yes
>        1.1. Test if the current element is what we are looking for
>        if yes
>            1.1.1 return Success
>        if no
>            1.1.2 Back track to point to the start of the elemnt and 
> return Success
>    if no
>        1.2 return Failure
> I hope the above algorithm does not violate the pull model we have. 
> Additionally, can we expect the SOAP message to have the elements in 
> the same order defined by the
> WSDL? If yes (I think it is) we are OK. If not we have another bug :(

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://nagoya.apache.org/jira/secure/Administrators.jspa
-
If you want more information on JIRA, or have a bug to report see:
   http://www.atlassian.com/software/jira