mandatory fields....

Discussion in 'ASP .Net Web Services' started by Ollie, Oct 13, 2004.

  1. Ollie

    Ollie Guest

    I have defined a set of SOAP messages using an xsd file, each element in the
    xsd has the minoccurs, maxoccurs & nillable attributes defined when I then
    use xsd.exe to generation C# classes for these message the attributes are
    NOT defined for the class members - e.g.

    <xsd:complexType name="Session">
    <xsd:sequence>
    <xsd:element name="Id" type="xsd:int" nillable="false" minOccurs="1"
    maxOccurs="1" />
    <xsd:element name="Name" type="xsd:string" nillable="false"
    minOccurs="1" maxOccurs="1" />
    <xsd:element name="StartDate" type="xsd:date" nillable="false"
    minOccurs="1" maxOccurs="1" />
    <xsd:element name="EndDate" type="xsd:date" nillable="false"
    minOccurs="1" maxOccurs="1" />
    </xsd:sequence>
    </xsd:complexType>

    when the C# class is generated it appears as:

    [System.Xml.Serialization.XmlTypeAttribute(Namespace="uk.org.XXX.esm.v1")]
    [System.Xml.Serialization.XmlRootAttribute(Namespace="uk.org.XXX.esm.v1",
    IsNullable=false)]
    public class Session
    {
    /// <remarks/>
    public int Id;
    /// <remarks/>
    public string Name;
    /// <remarks/>
    [System.Xml.Serialization.XmlElementAttribute(DataType="date")]
    public System.DateTime StartDate;
    /// <remarks/>
    [System.Xml.Serialization.XmlElementAttribute(DataType="date")]
    public System.DateTime EndDate;
    }

    Can I mark the class members as having minoccurs, maxoccurs & nillable
    attributes or is this impossible?

    Is it possible to make a WS end point not accept a null value(message)? - if
    so will it throw a SOAP exception?

    If I go the contract first way of development for the WS do I have to
    manually create the WSDL file after creating the xsd ?

    Anyone know of a good tool for generating the WSDL with the attributes I
    want....

    Cheers in advance

    Ollie
    Ollie, Oct 13, 2004
    #1
    1. Advertising

  2. Ollie

    Dan Rogers Guest

    Hi Ollie,

    No, there is no way to make the generated classes perform the complex
    validation logic defined in the schema. It is a good idea to do a schema
    validation as a precursor step in a web service validation. This can be
    done either in WebService Extensions, or in an HTTP Filter in IIS - e.g.
    intercept the XML.

    By the time it is in the class, you get what came in, and don't have a
    great way to make the class enforce the schema rules. You CAN make the
    class default missing values, etc, but it won't know any of your complex
    validation rules from your schema. If you're in the class of developers
    that starts with a schema and then generates a program, you can save
    yourself some time by not going over the edge in defining validation rules
    in the schema. You can develop these in code if you want them to run from
    code, but you'll have to do that as adjunct logic, not generated from the
    schema. At least not yet.

    Regards

    Dan Rogers
    Microsoft Corporation
    --------------------
    >From: "Ollie" <>
    >Subject: mandatory fields....
    >Date: Wed, 13 Oct 2004 15:30:35 +0100
    >Lines: 58
    >X-Priority: 3
    >X-MSMail-Priority: Normal
    >X-Newsreader: Microsoft Outlook Express 6.00.2800.1437
    >X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441
    >Message-ID: <>
    >Newsgroups:

    microsoft.public.dotnet.framework.aspnet.webservices,microsoft.public.dotnet
    ..framework.webservices
    >NNTP-Posting-Host: 192.149.119.12
    >Path:

    cpmsftngxa10.phx.gbl!TK2MSFTNGXA03.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP14
    ..phx.gbl
    >Xref: cpmsftngxa10.phx.gbl

    microsoft.public.dotnet.framework.webservices:6965
    microsoft.public.dotnet.framework.aspnet.webservices:26100
    >X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webservices
    >
    >I have defined a set of SOAP messages using an xsd file, each element in

    the
    >xsd has the minoccurs, maxoccurs & nillable attributes defined when I then
    >use xsd.exe to generation C# classes for these message the attributes are
    >NOT defined for the class members - e.g.
    >
    ><xsd:complexType name="Session">
    > <xsd:sequence>
    > <xsd:element name="Id" type="xsd:int" nillable="false"

    minOccurs="1"
    >maxOccurs="1" />
    > <xsd:element name="Name" type="xsd:string" nillable="false"
    >minOccurs="1" maxOccurs="1" />
    > <xsd:element name="StartDate" type="xsd:date" nillable="false"
    >minOccurs="1" maxOccurs="1" />
    > <xsd:element name="EndDate" type="xsd:date" nillable="false"
    >minOccurs="1" maxOccurs="1" />
    > </xsd:sequence>
    ></xsd:complexType>
    >
    >when the C# class is generated it appears as:
    >
    >[System.Xml.Serialization.XmlTypeAttribute(Namespace="uk.org.XXX.esm.v1")]
    >[System.Xml.Serialization.XmlRootAttribute(Namespace="uk.org.XXX.esm.v1",
    >IsNullable=false)]
    >public class Session
    >{
    > /// <remarks/>
    > public int Id;
    > /// <remarks/>
    > public string Name;
    > /// <remarks/>
    > [System.Xml.Serialization.XmlElementAttribute(DataType="date")]
    > public System.DateTime StartDate;
    > /// <remarks/>
    > [System.Xml.Serialization.XmlElementAttribute(DataType="date")]
    > public System.DateTime EndDate;
    >}
    >
    >Can I mark the class members as having minoccurs, maxoccurs & nillable
    >attributes or is this impossible?
    >
    >Is it possible to make a WS end point not accept a null value(message)? -

    if
    >so will it throw a SOAP exception?
    >
    >If I go the contract first way of development for the WS do I have to
    >manually create the WSDL file after creating the xsd ?
    >
    >Anyone know of a good tool for generating the WSDL with the attributes I
    >want....
    >
    >Cheers in advance
    >
    >Ollie
    >
    >
    >
    >
    >
    >
    >
    Dan Rogers, Nov 12, 2004
    #2
    1. Advertising

  3. Ollie

    Ollie Guest

    thanks for the respone Dan,

    The question about 'contract first' development was really to try and get a
    consensus of what it actually is....

    I don't like writing WSDL and just wanted to clairfy that you don't have to
    write the WSDL first to adhere to 'contract first' develpoment and that you
    can just define the contract (xsd definition) to follow this development
    paradigm.....

    As for the answer for the validation logic that is contained in the XSD, it
    would be nice if the xsd.exe could generate this in the class BUT even
    better if it could generate it in the SOAP layer or lower in the HTTP layer
    so that it could the validation even before the message is delivered to the
    application from the SOAP layer - I will keep dreaming about this and may be
    creat a piece of software that does it :)

    Cheers for the answer

    Ollie Riches

    "Dan Rogers" <> wrote in message
    news:...
    > Hi Ollie,
    >
    > No, there is no way to make the generated classes perform the complex
    > validation logic defined in the schema. It is a good idea to do a schema
    > validation as a precursor step in a web service validation. This can be
    > done either in WebService Extensions, or in an HTTP Filter in IIS - e.g.
    > intercept the XML.
    >
    > By the time it is in the class, you get what came in, and don't have a
    > great way to make the class enforce the schema rules. You CAN make the
    > class default missing values, etc, but it won't know any of your complex
    > validation rules from your schema. If you're in the class of developers
    > that starts with a schema and then generates a program, you can save
    > yourself some time by not going over the edge in defining validation rules
    > in the schema. You can develop these in code if you want them to run from
    > code, but you'll have to do that as adjunct logic, not generated from the
    > schema. At least not yet.
    >
    > Regards
    >
    > Dan Rogers
    > Microsoft Corporation
    > --------------------
    >>From: "Ollie" <>
    >>Subject: mandatory fields....
    >>Date: Wed, 13 Oct 2004 15:30:35 +0100
    >>Lines: 58
    >>X-Priority: 3
    >>X-MSMail-Priority: Normal
    >>X-Newsreader: Microsoft Outlook Express 6.00.2800.1437
    >>X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441
    >>Message-ID: <>
    >>Newsgroups:

    > microsoft.public.dotnet.framework.aspnet.webservices,microsoft.public.dotnet
    > framework.webservices
    >>NNTP-Posting-Host: 192.149.119.12
    >>Path:

    > cpmsftngxa10.phx.gbl!TK2MSFTNGXA03.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP14
    > phx.gbl
    >>Xref: cpmsftngxa10.phx.gbl

    > microsoft.public.dotnet.framework.webservices:6965
    > microsoft.public.dotnet.framework.aspnet.webservices:26100
    >>X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webservices
    >>
    >>I have defined a set of SOAP messages using an xsd file, each element in

    > the
    >>xsd has the minoccurs, maxoccurs & nillable attributes defined when I then
    >>use xsd.exe to generation C# classes for these message the attributes are
    >>NOT defined for the class members - e.g.
    >>
    >><xsd:complexType name="Session">
    >> <xsd:sequence>
    >> <xsd:element name="Id" type="xsd:int" nillable="false"

    > minOccurs="1"
    >>maxOccurs="1" />
    >> <xsd:element name="Name" type="xsd:string" nillable="false"
    >>minOccurs="1" maxOccurs="1" />
    >> <xsd:element name="StartDate" type="xsd:date" nillable="false"
    >>minOccurs="1" maxOccurs="1" />
    >> <xsd:element name="EndDate" type="xsd:date" nillable="false"
    >>minOccurs="1" maxOccurs="1" />
    >> </xsd:sequence>
    >></xsd:complexType>
    >>
    >>when the C# class is generated it appears as:
    >>
    >>[System.Xml.Serialization.XmlTypeAttribute(Namespace="uk.org.XXX.esm.v1")]
    >>[System.Xml.Serialization.XmlRootAttribute(Namespace="uk.org.XXX.esm.v1",
    >>IsNullable=false)]
    >>public class Session
    >>{
    >> /// <remarks/>
    >> public int Id;
    >> /// <remarks/>
    >> public string Name;
    >> /// <remarks/>
    >> [System.Xml.Serialization.XmlElementAttribute(DataType="date")]
    >> public System.DateTime StartDate;
    >> /// <remarks/>
    >> [System.Xml.Serialization.XmlElementAttribute(DataType="date")]
    >> public System.DateTime EndDate;
    >>}
    >>
    >>Can I mark the class members as having minoccurs, maxoccurs & nillable
    >>attributes or is this impossible?
    >>
    >>Is it possible to make a WS end point not accept a null value(message)? -

    > if
    >>so will it throw a SOAP exception?
    >>
    >>If I go the contract first way of development for the WS do I have to
    >>manually create the WSDL file after creating the xsd ?
    >>
    >>Anyone know of a good tool for generating the WSDL with the attributes I
    >>want....
    >>
    >>Cheers in advance
    >>
    >>Ollie
    >>
    >>
    >>
    >>
    >>
    >>
    >>

    >
    Ollie, Nov 13, 2004
    #3
  4. Ollie

    Dan Rogers Guest

    Hi Ollie,

    Thanks for clarifying your need -- Contract based programming is indeed
    important to a large slice of today's programming community. To get the
    expression of the contract that you want, what I'd recommend for now is to
    auto-generate the initial WSDL, then save a copy of it, and the schemas it
    referenes, and then update those files with the contract description you
    desire. In the case if multiple schemas, or well versioned web service
    interfaces (e.g. web services that use the WebServiceBindingAttribute and
    WebMethodBindingAttribute pairs), you'll find that the schema is
    externalized into a separate file. This is suitable for this kind of
    changing operation so that you get the schema you started with (by making
    your web server host the appropriate XSD file at the right location).
    Again, you would need to disable automatic documentation to make this
    happen.

    For now, the reflection based generation of class-to-schema information
    relies on information that can be expressed in attributes or in the class
    itself. There is presently no way to express cardinality expectations
    (since they truly are only expectations) - but you can be sure that I've
    requested this ability already.

    Regards,

    Dan Rogers
    Microsoft Corporation
    --------------------
    >From: "Ollie" <why do they need this!!!!>
    >References: <>

    <>
    >Subject: Re: mandatory fields....
    >Date: Sat, 13 Nov 2004 20:22:27 -0000
    >Lines: 132
    >X-Priority: 3
    >X-MSMail-Priority: Normal
    >X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
    >X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
    >X-RFC2646: Format=Flowed; Original
    >Message-ID: <>
    >Newsgroups: microsoft.public.dotnet.framework.aspnet.webservices
    >NNTP-Posting-Host: host81-154-233-26.range81-154.btcentralplus.com

    81.154.233.26
    >Path:

    cpmsftngxa10.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP14
    phx.gbl
    >Xref: cpmsftngxa10.phx.gbl

    microsoft.public.dotnet.framework.aspnet.webservices:26520
    >X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webservices
    >
    >thanks for the respone Dan,
    >
    >The question about 'contract first' development was really to try and get

    a
    >consensus of what it actually is....
    >
    >I don't like writing WSDL and just wanted to clairfy that you don't have

    to
    >write the WSDL first to adhere to 'contract first' develpoment and that

    you
    >can just define the contract (xsd definition) to follow this development
    >paradigm.....
    >
    >As for the answer for the validation logic that is contained in the XSD,

    it
    >would be nice if the xsd.exe could generate this in the class BUT even
    >better if it could generate it in the SOAP layer or lower in the HTTP

    layer
    >so that it could the validation even before the message is delivered to

    the
    >application from the SOAP layer - I will keep dreaming about this and may

    be
    >creat a piece of software that does it :)
    >
    >Cheers for the answer
    >
    >Ollie Riches
    >
    >"Dan Rogers" <> wrote in message
    >news:...
    >> Hi Ollie,
    >>
    >> No, there is no way to make the generated classes perform the complex
    >> validation logic defined in the schema. It is a good idea to do a schema
    >> validation as a precursor step in a web service validation. This can be
    >> done either in WebService Extensions, or in an HTTP Filter in IIS - e.g.
    >> intercept the XML.
    >>
    >> By the time it is in the class, you get what came in, and don't have a
    >> great way to make the class enforce the schema rules. You CAN make the
    >> class default missing values, etc, but it won't know any of your complex
    >> validation rules from your schema. If you're in the class of developers
    >> that starts with a schema and then generates a program, you can save
    >> yourself some time by not going over the edge in defining validation

    rules
    >> in the schema. You can develop these in code if you want them to run

    from
    >> code, but you'll have to do that as adjunct logic, not generated from the
    >> schema. At least not yet.
    >>
    >> Regards
    >>
    >> Dan Rogers
    >> Microsoft Corporation
    >> --------------------
    >>>From: "Ollie" <>
    >>>Subject: mandatory fields....
    >>>Date: Wed, 13 Oct 2004 15:30:35 +0100
    >>>Lines: 58
    >>>X-Priority: 3
    >>>X-MSMail-Priority: Normal
    >>>X-Newsreader: Microsoft Outlook Express 6.00.2800.1437
    >>>X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441
    >>>Message-ID: <>
    >>>Newsgroups:

    >>

    microsoft.public.dotnet.framework.aspnet.webservices,microsoft.public.dotnet
    >> framework.webservices
    >>>NNTP-Posting-Host: 192.149.119.12
    >>>Path:

    >>

    cpmsftngxa10.phx.gbl!TK2MSFTNGXA03.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP14
    >> phx.gbl
    >>>Xref: cpmsftngxa10.phx.gbl

    >> microsoft.public.dotnet.framework.webservices:6965
    >> microsoft.public.dotnet.framework.aspnet.webservices:26100
    >>>X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webservices
    >>>
    >>>I have defined a set of SOAP messages using an xsd file, each element in

    >> the
    >>>xsd has the minoccurs, maxoccurs & nillable attributes defined when I

    then
    >>>use xsd.exe to generation C# classes for these message the attributes are
    >>>NOT defined for the class members - e.g.
    >>>
    >>><xsd:complexType name="Session">
    >>> <xsd:sequence>
    >>> <xsd:element name="Id" type="xsd:int" nillable="false"

    >> minOccurs="1"
    >>>maxOccurs="1" />
    >>> <xsd:element name="Name" type="xsd:string" nillable="false"
    >>>minOccurs="1" maxOccurs="1" />
    >>> <xsd:element name="StartDate" type="xsd:date" nillable="false"
    >>>minOccurs="1" maxOccurs="1" />
    >>> <xsd:element name="EndDate" type="xsd:date" nillable="false"
    >>>minOccurs="1" maxOccurs="1" />
    >>> </xsd:sequence>
    >>></xsd:complexType>
    >>>
    >>>when the C# class is generated it appears as:
    >>>
    >>>[System.Xml.Serialization.XmlTypeAttribute(Namespace="uk.org.XXX.esm.v1")

    ]
    >>>[System.Xml.Serialization.XmlRootAttribute(Namespace="uk.org.XXX.esm.v1",
    >>>IsNullable=false)]
    >>>public class Session
    >>>{
    >>> /// <remarks/>
    >>> public int Id;
    >>> /// <remarks/>
    >>> public string Name;
    >>> /// <remarks/>
    >>> [System.Xml.Serialization.XmlElementAttribute(DataType="date")]
    >>> public System.DateTime StartDate;
    >>> /// <remarks/>
    >>> [System.Xml.Serialization.XmlElementAttribute(DataType="date")]
    >>> public System.DateTime EndDate;
    >>>}
    >>>
    >>>Can I mark the class members as having minoccurs, maxoccurs & nillable
    >>>attributes or is this impossible?
    >>>
    >>>Is it possible to make a WS end point not accept a null value(message)? -

    >> if
    >>>so will it throw a SOAP exception?
    >>>
    >>>If I go the contract first way of development for the WS do I have to
    >>>manually create the WSDL file after creating the xsd ?
    >>>
    >>>Anyone know of a good tool for generating the WSDL with the attributes I
    >>>want....
    >>>
    >>>Cheers in advance
    >>>
    >>>Ollie
    >>>
    >>>
    >>>
    >>>
    >>>
    >>>
    >>>

    >>

    >
    >
    >
    Dan Rogers, Nov 16, 2004
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. valentin tihomirov

    mandatory output binding?

    valentin tihomirov, Jul 2, 2005, in forum: VHDL
    Replies:
    1
    Views:
    476
    Jonathan Bromley
    Jul 4, 2005
  2. Srinivas

    mandatory text fields

    Srinivas, Mar 22, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    488
    Karl Seguin
    Mar 22, 2005
  3. Pete Barrett
    Replies:
    0
    Views:
    555
    Pete Barrett
    Jun 8, 2005
  4. Chris West

    XSD mandatory element

    Chris West, Jun 27, 2003, in forum: XML
    Replies:
    1
    Views:
    5,944
    Colin Mackenzie
    Jun 27, 2003
  5. Piers Chivers
    Replies:
    2
    Views:
    393
    Piers Chivers
    Mar 2, 2004
Loading...

Share This Page