By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,169 Members | 1,484 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,169 IT Pros & Developers. It's quick & easy.

SOAP C# - Optional Properties

P: n/a
How can you not require parameters in the WSDL of type DateTime, int,
double?

For example:

A DateTime field in a C# web service always serializes as:

<s:element minOccurs="1" maxOccurs="1" name="MyDateField"
type="s:dateTime" />

How does it have to be declared (or manipulated) in the C# code to end
up in the WSDL as:

<s:element minOccurs="0" maxOccurs="1" name="MyDateField"
type="s:dateTime" />

Apr 4 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Hi Ian,

have you tried to use this?

....
public DateTime MyDateField;

[XmlIgnore]
public bool MyDateFieldSpecified;
....

George
Apr 4 '06 #2

P: n/a
George,
Your solution creates a property for my class that is not visible to
the web service. It does not change the minOccurs setting of the
MyDateField. I'm trying to set minOccurs="0" for MyDateField.

Apr 4 '06 #3

P: n/a
Try attributing with DefaultValue[Attribute] (in System.ComponentModel)

public class TestClass {
[DefaultValue(0)]
public int TestField;
private int _testPropField;
[DefaultValue(0)]
public int TestProperty {
get { return _testPropField; }
set { _testPropField = value; }
}
}

this gives:

<s:element minOccurs="0" maxOccurs="1" default="0" name="TestField"
type="s:int" />
<s:element minOccurs="0" maxOccurs="1" default="0" name="TestProperty"
type="s:int" />

Very close...

Marc

"Ian Jenkins, MCSD" <jw*******@gmail.com> wrote in message
news:11**********************@j33g2000cwa.googlegr oups.com...
George,
Your solution creates a property for my class that is not visible to
the web service. It does not change the minOccurs setting of the
MyDateField. I'm trying to set minOccurs="0" for MyDateField.


Apr 11 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.