Specifying the <propertyName>Specified attribute

When you generate a client proxy by using wsdl.exe, wsdl.exe creates a <propertyName>Specified attribute on a class when wsdl.exe maps an optional property that is a primitive data type. Optional properties are defined in the XML schema with the minOccurs="0" parameter.

The wsdl.exe creates a <propertyName>Specified attribute for primitive types, such as enumeration, int, boolean or double, where an unspecified value for the optional property cannot be represented by a null value. The wsdl.exe does not create a <propertyName>Specified attribute for true object references, where an unspecified value can be represented by a null value. If you specify a valid value for an optional property that is a primitive data type, you must set the <propertyName>Specified boolean flag to true.

You can view the XML schema for any class in the API reference for the BlackBerry® Administration API.

Code sample: Using an optional property

In the following code sample, the sortBy property specifies the sort order for the findUsers method. The sortBy property is defined as optional in the XML schema for the FindUsers class, with the minOccurs="0" parameter. When you specify a value for the @enum property, you must set the enumSpecified attribute to true to notify the web server that you are using a valid value for this property.

BASUserSearchResultSortByEnum sortBy = new BASUserSearchResultSortByEnum();
sortBy.@enum = BASUserSearchResultSortByEnumType.DISPLAY_NAME;
sortBy.enumSpecified = true;

Code sample: Using a required property

In the following code sample, the authenticator ID field is used in the encodeUsername object to invoke the encodeUsername method. The identifier property is a primitive data type and it is defined as required in the XML schema for the EncodeUsername class, with the minOccurs="1" parameter. The property is required, and wsdl.exe does not create a corresponding identifierSpecified attribute. Therefore, you do not include an identifierSpecified = true statement when you create an instance of encodeUsername.

encodeUsername request = new encodeUsername();
request.identifier = authenticator.id;

Was this information helpful? Send us your comments.