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

Is using xs:nillable and xs:minOccurs getting better?

Expand Messages
  • erikj999
    Does anyone know if the state of the art is improving for handling xs:nillable and xs:minOccurs in SOAP toolkits? I looked around the soapbuilders archives and
    Message 1 of 10 , Jan 12, 2006
    • 0 Attachment

      Does anyone know if the state of the art is improving for handling xs:nillable and xs:minOccurs in SOAP toolkits?

      I looked around the soapbuilders archives and saw a 12/2003 discussion.  But the conclusion by the user was to prohibit xs:nillible in his company's WSDL set altogether because toolkits were unpredictable – ugh.  Also, we talked about this problem in the WS-I Schema Working Group (which I chaired), but the XSD spec wasn't seen as the problem here.  It was deemed a toolkit issue (synonymous with "militantly out of scope" in the WS-I).

      Anyway, I submitted an issue to the W3C XSD Databinding working group this week and I whipped up a use-case (below) to refresh memories, but I'd love to know if the toolkit vendors are actively trying to provide a solution.  Thanks,

      Erik Johnson
      Epicor Software Corp.

      Use-Case -------------------------------

      I have a schema for a message for updating, say, an *existing* customer record.  Each element is a column in my CUSTOMER table.  Some columns like "FAX" can contain NULL values.  The message to update a customer can omit elements that are not to be changed, so all elements (except maybe the customer ID) are declared with the attribute xs:minOccurs="0".  Customer record values that can be set to NULL are declared in the schema with the attribute xs:nillable="true"

      So, the elements in the update message will either (a) contain content or (b) contain no content, but have an attribute xsi:nil="true".  Case (a) writes the content to the data column corresponding to the element name and (b) writes a NULL value into that database column.  Finally, if an element is missing, the caller is indicating that no change to the data value should occur.

      The problem is that type generators can't seem to handle this (I think common) situation.  As an example, .NET (2.0) types generated from the schema will serialize all class members with null values into elements with no content and xsi:nil="true".  The result is that all customer fields not explicitly assigned a value are summarily set to NULL. There is no way to instantiate the generated type, set a member value, and have the serialization ignore members that were unassigned.

    • Simon Fell
      ... The vast majority of tools continue to merge minOccurs= 0 and nillable= 1 into NULL. .NET for reasons which only make sense to MSFT will treat it as 2
      Message 2 of 10 , Jan 12, 2006
      • 0 Attachment
        On Fri, 13 Jan 2006 02:29:52 -0000, in ws you wrote:

        >Does anyone know if the state of the art is improving for handling xs:nillable and xs:minOccurs in SOAP toolkits? I looked around the soapbuilders archives and saw a 12/2003 discussion. But the conclusion by the user was to prohibit xs:nillible in his company's WSDL set altogether because toolkits were unpredictable – ugh. Also, we talked about this problem in the WS-I Schema Working Group (which I chaired), but the XSD spec wasn't seen as the problem here. It was deemed a toolkit issue (synonymous with "militantly out of scope" in the WS-I).Anyway, I submitted an issue to the W3C XSD Databinding working group this week and I whipped up a use-case (below) to refresh memories, but I'd love to know if the toolkit vendors are actively trying to provide a solution. Thanks,
        >Erik Johnson
        >Epicor Software Corp.
        >Use-Case -------------------------------I have a schema for a message for updating, say, an *existing* customer record. Each element is a column in my CUSTOMER table. Some columns like "FAX" can contain NULL values. The message to update a customer can omit elements that are not to be changed, so all elements (except maybe the customer ID) are declared with the attribute xs:minOccurs="0". Customer record values that can be set to NULL are declared in the schema with the attribute xs:nillable="true". So, the elements in the update message will either (a) contain content or (b) contain no content, but have an attribute xsi:nil="true". Case (a) writes the content to the data column corresponding to the element name and (b) writes a NULL value into that database column. Finally, if an element is missing, the caller is indicating that no change to the data value should occur.The problem is that type generators can't seem to handle this (I think common) situation. As an example,
        >.NET (2.0) types generated from the schema will serialize all class members with null values into elements with no content and xsi:nil="true". The result is that all customer fields not explicitly assigned a value are summarily set to NULL. There is no way to instantiate the generated type, set a member value, and have the serialization ignore members that were unassigned.

        The vast majority of tools continue to merge minOccurs='0' and
        nillable='1' into NULL.

        .NET for reasons which only make sense to MSFT will treat it as 2
        different things, but only for a subset of simple types.

        AFAIK, the start of the art in toolkits is moving no-where, tools that
        are still under active development seem to be concentrating on WS-*
        features, despite their rocky underpinning.

        Cheers
        Simon
      • Glen Daniels
        Hi Simon, all: ... And what you d like to happen is what exactly? In the Java world, for instance, you can typically choose to process SOAP messages either
        Message 3 of 10 , Jan 12, 2006
        • 0 Attachment
          Hi Simon, all:

          Simon Fell wrote:
          > The vast majority of tools continue to merge minOccurs='0' and
          > nillable='1' into NULL.
          >
          > .NET for reasons which only make sense to MSFT will treat it as 2
          > different things, but only for a subset of simple types.
          >
          > AFAIK, the start of the art in toolkits is moving no-where, tools that
          > are still under active development seem to be concentrating on WS-*
          > features, despite their rocky underpinning.

          And what you'd like to happen is what exactly?

          In the Java world, for instance, you can typically choose to process
          SOAP messages either with a databinding layer that maps the XML onto
          Java classes, or by simply getting access to the "raw" XML with a DOM or
          SAX or SAAJ. In the latter case, no problem - you can simply walk the
          XML and notice if an element simply isn't there or if it's there and
          something like "element.isNil()" is true. In the databinding case,
          though, if you to map something like:

          class Container {
          Item item;
          }

          and distinguish this:

          <container>
          <item xsi:nil="true"/>
          </container>

          from this:

          <container/>

          then you need to do something tricky, like have a special NIL Item or
          some out-of-band data indicating the difference. You can also have
          application-specific code which knows that you're in the kind of
          updating scenario that Erik described, and that code ties in with the
          deserialization logic... but it's hard to get that kind of help from a
          generic tool like Axis or .NET.

          The best we've done so far is to correctly map a language null onto
          either xsi:nil or missing elements in XML depending on the schema, and
          vice versa.

          So how would you guys like to see this solved?

          --Glen
        • Simon Fell
          ... For tools that map to objects, what I d like is for it to be mapped to something like private String myFoo; private boolean myFooExists; public void
          Message 4 of 10 , Jan 12, 2006
          • 0 Attachment
            On Thu, 12 Jan 2006 22:51:35 -0500, in ws you wrote:

            >Hi Simon, all:
            >
            >Simon Fell wrote:
            >> The vast majority of tools continue to merge minOccurs='0' and
            >> nillable='1' into NULL.
            >>
            >> .NET for reasons which only make sense to MSFT will treat it as 2
            >> different things, but only for a subset of simple types.
            >>
            >> AFAIK, the start of the art in toolkits is moving no-where, tools that
            >> are still under active development seem to be concentrating on WS-*
            >> features, despite their rocky underpinning.
            >
            >And what you'd like to happen is what exactly?
            >
            >In the Java world, for instance, you can typically choose to process
            >SOAP messages either with a databinding layer that maps the XML onto
            >Java classes, or by simply getting access to the "raw" XML with a DOM or
            >SAX or SAAJ. In the latter case, no problem - you can simply walk the
            >XML and notice if an element simply isn't there or if it's there and
            >something like "element.isNil()" is true. In the databinding case,
            >though, if you to map something like:

            For tools that map to objects, what I'd like is for it to be mapped to
            something like

            private String myFoo;
            private boolean myFooExists;

            public void getMyFoo() {
            return myFoo;
            }

            public void getMyFooExists {
            return myFooExists;
            }

            public void setMyFoo(String foo) {
            myFoo = foo;
            myFooExists = true;
            }

            This doesn't seem like rocket science to me, and .NET comes so close,
            except the missed the myFooExists = true in the MyFoo setter, which
            makes the client code the somewhat bizzare looking

            x.MyFoo = "fred"
            x.MyFooSpecified = true;

            Except that they only do the specified thing for a subset of simple
            types, so you don't actually get the specified thing on Strings.
            I've lost count of the number of people that run into this, they just
            have x.MyFoo = 123 then wonder why the server is ignoring their MyFoo.

            Cheers
            Simon
          • Paul Downey
            ... correctly being the key here: I ve encountered many databinding tools that send xsi:nil= true regardless. AIUI elements without nillable= true in the
            Message 5 of 10 , Jan 13, 2006
            • 0 Attachment
              On 13 Jan 2006, at 03:51, Glen Daniels wrote:

              > The best we've done so far is to correctly map a language null onto
              > either xsi:nil or missing elements in XML depending on the schema, and
              > vice versa.

              'correctly' being the key here:

              I've encountered many databinding tools that send xsi:nil='true'
              regardless. AIUI elements without nillable='true' in the XML Schema
              shouldn't have this annotation.

              --
              http://blog.whatfettle.com
            • Glen Daniels
              ... Absolutely. It would be nice to run another series of interops with the current state-of-the-art tools and see which packages do this right/wrong. --Glen
              Message 6 of 10 , Jan 13, 2006
              • 0 Attachment
                Paul Downey wrote:
                > On 13 Jan 2006, at 03:51, Glen Daniels wrote:
                >
                >
                >>The best we've done so far is to correctly map a language null onto
                >>either xsi:nil or missing elements in XML depending on the schema, and
                >>vice versa.
                >
                > 'correctly' being the key here:
                >
                > I've encountered many databinding tools that send xsi:nil='true'
                > regardless. AIUI elements without nillable='true' in the XML Schema
                > shouldn't have this annotation.

                Absolutely.

                It would be nice to run another series of interops with the current
                state-of-the-art tools and see which packages do this right/wrong.

                --Glen
              • Glen Daniels
                ... Gotcha. A little clunky, but usable. I could see enhancing Axis/Axis2 to do this.... ... Wow. Well, one hopes that they ll have fixed that well before
                Message 7 of 10 , Jan 13, 2006
                • 0 Attachment
                  Hi Simon:

                  > For tools that map to objects, what I'd like is for it to be mapped to
                  > something like
                  >
                  > private String myFoo;
                  > private boolean myFooExists;
                  >
                  > public void getMyFoo() {
                  > return myFoo;
                  > }
                  >
                  > public void getMyFooExists {
                  > return myFooExists;
                  > }
                  >
                  > public void setMyFoo(String foo) {
                  > myFoo = foo;
                  > myFooExists = true;
                  > }

                  Gotcha. A little clunky, but usable. I could see enhancing Axis/Axis2
                  to do this....

                  > This doesn't seem like rocket science to me, and .NET comes so close,
                  > except the missed the myFooExists = true in the MyFoo setter, which
                  > makes the client code the somewhat bizzare looking
                  >
                  > x.MyFoo = "fred"
                  > x.MyFooSpecified = true;
                  >
                  > Except that they only do the specified thing for a subset of simple
                  > types, so you don't actually get the specified thing on Strings.
                  > I've lost count of the number of people that run into this, they just
                  > have x.MyFoo = 123 then wonder why the server is ignoring their MyFoo.

                  Wow. Well, one hopes that they'll have fixed that well before the WCF
                  release....

                  --Glen
                • Paul Downey
                  ... The W3C XML Schema patterns for databinding WG aims to build a test suite. One of the proposals on the table surrounds building the tests in such a way
                  Message 8 of 10 , Jan 13, 2006
                  • 0 Attachment
                    On 13 Jan 2006, at 13:38, Glen Daniels wrote:


                    > It would be nice to run another series of interops with the current
                    > state-of-the-art tools and see which packages do this right/wrong.

                    The W3C XML Schema patterns for databinding WG aims to build a test
                    suite.
                    One of the proposals on the table surrounds building the tests in such
                    a way that they can be easily published inside a WSDL wrapper, probably
                    at the end of a uniform 'echo' operation.

                    When we hit CR, I'd expect to enlist help from soapbuilders in
                    demonstrating running such tests against real toolkits, and of course we
                    continue to solicit example patterns of schema known to work well
                    (or not :) with tools. Send them in to:

                    http://www.w3.org/2002/ws/databinding/

                    Paul
                    --
                    http://blog.whatfettle.com
                  • erikj999
                    ... Hi Glen, I agree it s hard to build tools when you have to divine the schema author s intent. Schemas in the wild differ, um, wildly on what minOccurs and
                    Message 9 of 10 , Jan 13, 2006
                    • 0 Attachment
                      --- In soapbuilders@yahoogroups.com, Glen Daniels <glen@t...> wrote:
                      >
                      > And what you'd like to happen is what exactly?
                      >

                      Hi Glen,

                      I agree it's hard to build tools when you have to divine the schema
                      author's intent. Schemas in the wild differ, um, wildly on what
                      minOccurs and nillable really mean, so a standard solution probably
                      starts with the industry settling on a standard intent (God help us).

                      I think the toolkits need to support the notion that minOccurs="0"
                      means "can be left unsaid" and give users some way to easily
                      distiguish that from "set to NULL". Schema authors should use
                      xs:nillible="true" and messages should use xsi:nil="true" to
                      explicitly mean a NULL value. That would avoid relying on empty
                      content to play some role in all this.

                      Allowing empty content to imply NULL is problematic because, (IMO)
                      as bad a practice as it is, some services need to distinguish NULLs
                      from zero-length strings. Also schema validators insert default
                      values when empty content is presented, which might further confuses
                      the meaning.

                      Finally, a soapbox: In the December 2003 discussion on this list
                      (see message 9643), one sentiment was that having a schema where
                      optional elements mean "leave the value as it was before"
                      potentially opened "the whole mess of assuming data aspects of the
                      data model on the other side".

                      The minOccurs="0" in my schema only says the caller can omit the
                      element -- it's value is "unsaid". There's obviously precedent in
                      databases where my message (in SQL) can omit columns and there is no
                      ambiguity in how to handle that. The semantic implications are no
                      better or worse than having the caller understand whether the
                      message is an invoice or a command to launch nukes.
                    • Steve Loughran
                      ... If you were to host the test files on a publicly accessible CVS or SVN repository, with a license that everyone was happy with (like the apache one), then
                      Message 10 of 10 , Jan 15, 2006
                      • 0 Attachment
                        On 1/13/06, Paul Downey <paul.downey@...> wrote:
                        >
                        > On 13 Jan 2006, at 13:38, Glen Daniels wrote:
                        >
                        >
                        > > It would be nice to run another series of interops with the current
                        > > state-of-the-art tools and see which packages do this right/wrong.
                        >
                        > The W3C XML Schema patterns for databinding WG aims to build a test
                        > suite.
                        > One of the proposals on the table surrounds building the tests in such
                        > a way that they can be easily published inside a WSDL wrapper, probably
                        > at the end of a uniform 'echo' operation.
                        >
                        > When we hit CR, I'd expect to enlist help from soapbuilders in
                        > demonstrating running such tests against real toolkits, and of course we
                        > continue to solicit example patterns of schema known to work well
                        > (or not :) with tools. Send them in to:
                        >
                        > http://www.w3.org/2002/ws/databinding/
                        >

                        If you were to host the test files on a publicly accessible CVS or SVN
                        repository, with a license that everyone was happy with (like the
                        apache one), then Apache Gump (gump.apache.org) could run the latest
                        test suite against Axis and other OSS implementations as part of its
                        nightly build.

                        -steve
                      Your message has been successfully submitted and would be delivered to recipients shortly.