DateTimes and MinOccurs

A

ads

I'm writing a webservice where all of the data elements should have a
minOccurs = 0. I'm using VS2005.

This is fine for most of my elements, but all of my datetime elements
automatically receive a minOccurs = 1 in the auto generated WSDL
file.

For example , if these were some fields in my Web Service code:
public string category;

public string condition;

public datetime dateOfPurchase;

My WSDL file turns out like this:
<s:element minOccurs="0" maxOccurs="1" name="category"
type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="condition"
type="s:string" />
<s:element minOccurs="1" maxOccurs="1" name="dateOfPurchase"
type="s:dateTime" />

Any thoughts? I'm working on another project where I've been given a
WSDL file generated from VS2008 - and this WSDL does have dateTimes
with minOccurs = 0. Is this a VS2005 limitation? Or am I doing
something wrong?

Any thoughts?
Thanks so much!

ami
 
J

John Saunders

ads said:
I'm writing a webservice where all of the data elements should have a
minOccurs = 0. I'm using VS2005.

This is fine for most of my elements, but all of my datetime elements
automatically receive a minOccurs = 1 in the auto generated WSDL
file.

What value would you want assigned to your DateTime parameter if it isn't
supplied in the SOAP? There is no really good answer to that, as
DateTime.MinValue is a valid DateTime.

Instead, try using DateTime? (System.Nullable<DateTime>) for the parameter
type and see if that changes the WSDL that is generated.

Finally, if you ever get into a situation where the generated WSDL doesn't
match what you want, remember that you don't have to allow .NET to generate
the WSDL. You can create your own WSDL instead.
 
P

Priya

Try using the "Specified" attribute:
If you have a public property called

dateOfPurchase
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,565
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top