XML elements defined with minOccurs="0" not recognized as optional

Created on 3 September 2019, about 5 years ago
Updated 2 November 2023, 11 months ago

All XML elements that has minOccurs="0" are not detected as optional and they are set as (Not Set) which is confusing to those trying to explore the service. Also if the value is not provided in the form for those, the empty XML element is added to the request causing errors with the XML validation.

<xs:element name="retrieve-owner-request">
    <xs:complexType>
        <xs:sequence>
             <xs:element ref="login-info"/>
             <xs:element minOccurs="0" ref="reference-number"/>
             <xs:element minOccurs="0" ref="client-request"/>
             <xs:element minOccurs="0" ref="audit-user"/>
             <xs:choice maxOccurs="1" minOccurs="1">
                  <xs:element ref="owner-number"/>
                  <xs:element ref="unique-pac"/>
                  <xs:element ref="sso:external-system"/>
                  <xs:element name="conferenceCode" type="xs:string"/>
             </xs:choice>
             <xs:element maxOccurs="1" minOccurs="0" name="comments" type="cmt:comments"/>
        </xs:sequence>
    </xs:complexType>
</xs:element>

Request generated where only mandatory fields were provided

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://intercall.com/ownerAPI" xmlns:ns2="http://intercall.com/cmt">
  <SOAP-ENV:Body>
    <ns1:retrieve-owner-request>
      <ns1:login-info>
        <ns1:user-name>user</ns1:user-name>
        <ns1:password>password</ns1:password>
        <ns1:account-number/>
      </ns1:login-info>
      <ns1:reference-number/>
      <ns1:client-request/>
      <ns1:audit-user/>
      <ns1:owner-number>9999999</ns1:owner-number>
      <ns1:comments>
        <ns2:comment operation="" external="false">
          <ns2:commentId>0</ns2:commentId>
          <ns2:commentDate/>
          <ns2:userName/>
          <ns2:commentType/>
          <ns2:commentText/>
        </ns2:comment>
      </ns1:comments>
    </ns1:retrieve-owner-request>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

Response:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
  <soapenv:Header/>
  <S:Body xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
    <soapenv:Fault>
      <faultcode>soapenv:Server</faultcode>
      <faultstring>Invalid SOAP Message.</faultstring>
      <faultactor>Client</faultactor>
    </soapenv:Fault>
  </S:Body>
</soapenv:Envelope>
πŸ› Bug report
Status

Fixed

Version

4.0

Component

Code

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024