Open the Portico Schema site
Portico Developer Guide
Specified Flags for Optional Elements
Getting Started > Transaction Basics > Specified Flags for Optional Elements

Optional elements are notated in the XML schema by a minOccurs="0" attribute. In order to provide a value in an element that is optional, it may be required to also set a "specified" flag. This is required for optional elements that are of a type that is not nullable. The specified flag is generated in code from the service reference as <fieldname>Specified.

The problem is that fields in .NET that cannot be null will always have a valid value (i.e., "0"). On the other hand, the XML schema defines it as optional:

<xs:element minOccurs="0" name="ID" type="xs:int"/>

Given this, there is no way for the .NET client to know whether the value of "0" means there is no value defined or if the true intent is to send the value "0" to the server.

The Specified flag takes care of this situation:

Unfortunately, this is not only in the "0" value case. For data types such as xs:int, xs:long, xs:decimal, xs:dateTime, and xs:string elements with specific enumeration values (i.e., booleanType, currencyType), the specified flag must be set to true in addition to setting the desired value.

For example, the optional field GatewayTxnId (type xs:int) needs to have an associated flag of GatewayTxnIdSpecified. To send a transaction id of 1234, the client must set GatewayTxnId="1234" and set GatewayTxnIdSpecified="true".