Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Services > mandatory fields....

Reply
Thread Tools

mandatory fields....

 
 
Ollie
Guest
Posts: n/a
 
      10-13-2004
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(Namespac e="uk.org.XXX.esm.v1")]
[System.Xml.Serialization.XmlRootAttribute(Namespac e="uk.org.XXX.esm.v1",
IsNullable=false)]
public class Session
{
/// <remarks/>
public int Id;
/// <remarks/>
public string Name;
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(DataT ype="date")]
public System.DateTime StartDate;
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(DataT ype="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






 
Reply With Quote
 
 
 
 
Dan Rogers
Guest
Posts: n/a
 
      11-12-2004
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" <(E-Mail Removed)>
>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: <(E-Mail Removed)>
>Newsgroups:

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

cpmsftngxa10.phx.gbl!TK2MSFTNGXA03.phx.gbl!TK2MSFT NGP08.phx.gbl!TK2MSFTNGP14
..phx.gbl
>Xref: cpmsftngxa10.phx.gbl

microsoft.public.dotnet.framework.webservices:6965
microsoft.public.dotnet.framework.aspnet.webservic es:26100
>X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webservic es
>
>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(Namespac e="uk.org.XXX.esm.v1")]
>[System.Xml.Serialization.XmlRootAttribute(Namespac e="uk.org.XXX.esm.v1",
>IsNullable=false)]
>public class Session
>{
> /// <remarks/>
> public int Id;
> /// <remarks/>
> public string Name;
> /// <remarks/>
> [System.Xml.Serialization.XmlElementAttribute(DataT ype="date")]
> public System.DateTime StartDate;
> /// <remarks/>
> [System.Xml.Serialization.XmlElementAttribute(DataT ype="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
>
>
>
>
>
>
>


 
Reply With Quote
 
 
 
 
Ollie
Guest
Posts: n/a
 
      11-13-2004
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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" <(E-Mail Removed)>
>>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: <(E-Mail Removed)>
>>Newsgroups:

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

> cpmsftngxa10.phx.gbl!TK2MSFTNGXA03.phx.gbl!TK2MSFT NGP08.phx.gbl!TK2MSFTNGP14
> phx.gbl
>>Xref: cpmsftngxa10.phx.gbl

> microsoft.public.dotnet.framework.webservices:6965
> microsoft.public.dotnet.framework.aspnet.webservic es:26100
>>X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webservic es
>>
>>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(Namespac e="uk.org.XXX.esm.v1")]
>>[System.Xml.Serialization.XmlRootAttribute(Namespac e="uk.org.XXX.esm.v1",
>>IsNullable=false)]
>>public class Session
>>{
>> /// <remarks/>
>> public int Id;
>> /// <remarks/>
>> public string Name;
>> /// <remarks/>
>> [System.Xml.Serialization.XmlElementAttribute(DataT ype="date")]
>> public System.DateTime StartDate;
>> /// <remarks/>
>> [System.Xml.Serialization.XmlElementAttribute(DataT ype="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
>>
>>
>>
>>
>>
>>
>>

>



 
Reply With Quote
 
Dan Rogers
Guest
Posts: n/a
 
      11-16-2004
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: <(E-Mail Removed)>

<(E-Mail Removed)>
>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: <(E-Mail Removed)>
>Newsgroups: microsoft.public.dotnet.framework.aspnet.webservic es
>NNTP-Posting-Host: host81-154-233-26.range81-154.btcentralplus.com

81.154.233.26
>Path:

cpmsftngxa10.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSFT NGP08.phx.gbl!TK2MSFTNGP14
phx.gbl
>Xref: cpmsftngxa10.phx.gbl

microsoft.public.dotnet.framework.aspnet.webservic es:26520
>X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webservic es
>
>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" <(E-Mail Removed)> wrote in message
>news:(E-Mail Removed)...
>> 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" <(E-Mail Removed)>
>>>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: <(E-Mail Removed)>
>>>Newsgroups:

>>

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

>>

cpmsftngxa10.phx.gbl!TK2MSFTNGXA03.phx.gbl!TK2MSFT NGP08.phx.gbl!TK2MSFTNGP14
>> phx.gbl
>>>Xref: cpmsftngxa10.phx.gbl

>> microsoft.public.dotnet.framework.webservices:6965
>> microsoft.public.dotnet.framework.aspnet.webservic es:26100
>>>X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webservic es
>>>
>>>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(Namespac e="uk.org.XXX.esm.v1")

]
>>>[System.Xml.Serialization.XmlRootAttribute(Namespac e="uk.org.XXX.esm.v1",
>>>IsNullable=false)]
>>>public class Session
>>>{
>>> /// <remarks/>
>>> public int Id;
>>> /// <remarks/>
>>> public string Name;
>>> /// <remarks/>
>>> [System.Xml.Serialization.XmlElementAttribute(DataT ype="date")]
>>> public System.DateTime StartDate;
>>> /// <remarks/>
>>> [System.Xml.Serialization.XmlElementAttribute(DataT ype="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
>>>
>>>
>>>
>>>
>>>
>>>
>>>

>>

>
>
>


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
mandatory output binding? valentin tihomirov VHDL 1 07-04-2005 08:26 AM
SSL HandshakeCompletedListener mandatory? Pete Barrett Java 0 06-08-2005 07:29 PM
mandatory text fields Srinivas ASP .Net 1 03-22-2005 12:58 PM
Schema question regarding some mandatory/some optional values Piers Chivers XML 2 03-02-2004 09:49 AM
XSD mandatory element Chris West XML 1 06-27-2003 08:50 AM



Advertisments