Loading ...
Sorry, an error occurred while loading the content.

Required and optional sequence elements

Expand Messages
  • Hrvoje Nezic
    Hi, I have a question related to sequence elements. For example, in case of a sequence:
    Message 1 of 3 , Nov 4, 2003
    • 0 Attachment
      Hi,

      I have a question related to sequence elements.
      For example, in case of a sequence:

      <s:complexType name="Common">
      <s:sequence>
      <s:element minOccurs="1" maxOccurs="1" name="Outcome"
      type="s0:OutcomeTypes" />
      <s:element minOccurs="0" maxOccurs="1" name="Message"
      type="s:string" />
      <s:element minOccurs="0" maxOccurs="1" name="Identity"
      type="s:string" />
      <s:element minOccurs="0" maxOccurs="1" name="Delay"
      type="s:string" />
      </s:sequence>
      </s:complexType>
    • Hrvoje Nezic
      Hi, I have a question related to sequence elements specified with minOccurs and maxOccurs. For example:
      Message 2 of 3 , Nov 4, 2003
      • 0 Attachment
        Hi,

        I have a question related to sequence elements
        specified with minOccurs and maxOccurs.

        For example:

        <s:complexType name="Common">
        <s:sequence>
        <s:element minOccurs="1" maxOccurs="1" name="Outcome"
        type="s0:OutcomeTypes" />
        <s:element minOccurs="0" maxOccurs="1" name="Message"
        type="s:string" />
        <s:element minOccurs="0" maxOccurs="1" name="Identity"
        type="s:string" />
        <s:element minOccurs="0" maxOccurs="1" name="Delay"
        type="s:string" />
        </s:sequence>
        </s:complexType>

        This means that elements with minOccurs="0" can be absent
        from the SOAP message.

        MyQuestion is how one can take advantage of optional
        elements (both on client and server side) if s/he is using
        some web services framework, like .NET, WASP, etc.

        On client side, when a proxy is built this sequence
        will be mapped into a class:

        public class Common {
        public OutcomeTypes Outcome; // required
        public string Message; // optional
        public string Identity; // optional
        public string Delay; // optional
        }

        If this class is an input argument, all sequence element
        will always be present. If the cleint don't want to supply
        optional element, how s/he can achieve it. I think the
        only way is to set null values (or perhaps empty values)
        for these arguments. Is this allowed?

        On server side it is the same situation. If there is a method:

        bool SomeMethod (Common commonArg) {
        }

        how can I know if user had supplied optional
        elements or not?

        I suppose that unsupplied elements will have empty
        values, or, more probably, null values, but I would
        like to be sure.

        Is this specified in some WS specification?

        I wasn't able to find this information in WSDL and SOAP
        specifications. Is there any other place or book where
        such topics are discussed?

        Thanks in advance.

        Best regards,
        Hrvoje Nezic
      • Dinesh_Shahane
        From XML instace perspective optional is different from a nillable element and there are ways indicate that an element is nil rather than not serializing
        Message 3 of 3 , Nov 4, 2003
        • 0 Attachment
          From XML instace perspective "optional" is different from a "nillable"
          element and there are ways indicate that an element is "nil" rather
          than not serializing it. There are also implications of having
          a "default" value in the schema definition of an element.

          The proxy generated using a toolkit may not make these features
          available if it doesn't map well the base programming language.


          --- In wsdl@yahoogroups.com, "Hrvoje Nezic" <hrvoje.nezic@e...> wrote:
          > Hi,
          >
          > I have a question related to sequence elements
          > specified with minOccurs and maxOccurs.
          >
          > For example:
          >
          > <s:complexType name="Common">
          > <s:sequence>
          > <s:element minOccurs="1" maxOccurs="1" name="Outcome"
          > type="s0:OutcomeTypes" />
          > <s:element minOccurs="0" maxOccurs="1" name="Message"
          > type="s:string" />
          > <s:element minOccurs="0" maxOccurs="1" name="Identity"
          > type="s:string" />
          > <s:element minOccurs="0" maxOccurs="1" name="Delay"
          > type="s:string" />
          > </s:sequence>
          > </s:complexType>
          >
          > This means that elements with minOccurs="0" can be absent
          > from the SOAP message.
          >
          > MyQuestion is how one can take advantage of optional
          > elements (both on client and server side) if s/he is using
          > some web services framework, like .NET, WASP, etc.
          >
          > On client side, when a proxy is built this sequence
          > will be mapped into a class:
          >
          > public class Common {
          > public OutcomeTypes Outcome; // required
          > public string Message; // optional
          > public string Identity; // optional
          > public string Delay; // optional
          > }
          >
          > If this class is an input argument, all sequence element
          > will always be present. If the cleint don't want to supply
          > optional element, how s/he can achieve it. I think the
          > only way is to set null values (or perhaps empty values)
          > for these arguments. Is this allowed?
          >
          > On server side it is the same situation. If there is a method:
          >
          > bool SomeMethod (Common commonArg) {
          > }
          >
          > how can I know if user had supplied optional
          > elements or not?
          >
          > I suppose that unsupplied elements will have empty
          > values, or, more probably, null values, but I would
          > like to be sure.
          >
          > Is this specified in some WS specification?
          >
          > I wasn't able to find this information in WSDL and SOAP
          > specifications. Is there any other place or book where
          > such topics are discussed?
          >
          > Thanks in advance.
          >
          > Best regards,
          > Hrvoje Nezic
        Your message has been successfully submitted and would be delivered to recipients shortly.