Difference between revisions of "Development"
From Agility
(Created page with "==Tips & Tricks== ===Specifying minOccurs=0 for non-string fields in WSDL generated from C# Web service method=== If tthere is a need for Xml element to be optional for non-s...") |
(→Tips & Tricks) |
||
| Line 1: | Line 1: | ||
| − | + | =Tips & Tricks= | |
| − | + | ==Specifying minOccurs=0 for non-string fields in WSDL generated from C# Web service method== | |
If tthere is a need for Xml element to be optional for non-string field in generated WSDL, the field definition needs to be coupled with the ''XXXSpecified'' boolean field definition within the same class. To stop the logical field from being included in the WSDL, ''[XmlIgnore]'' attribute can be used. Example below: | If tthere is a need for Xml element to be optional for non-string field in generated WSDL, the field definition needs to be coupled with the ''XXXSpecified'' boolean field definition within the same class. To stop the logical field from being included in the WSDL, ''[XmlIgnore]'' attribute can be used. Example below: | ||
<code><pre> | <code><pre> | ||
Revision as of 07:51, 28 April 2016
Tips & Tricks
Specifying minOccurs=0 for non-string fields in WSDL generated from C# Web service method
If tthere is a need for Xml element to be optional for non-string field in generated WSDL, the field definition needs to be coupled with the XXXSpecified boolean field definition within the same class. To stop the logical field from being included in the WSDL, [XmlIgnore] attribute can be used. Example below:
/// <remarks/>
public Decimal? PurchaseCost
{
get
{
return this.purchaseCostField;
}
set
{
this.purchaseCostField = value;
}
}
// this has been provided to force WSDL generator to put minoccurs=0 into PurchaseCost element definition
[System.Xml.Serialization.XmlIgnore]
public bool PurchaseCostSpecified
{
get
{
return true;
}
}