DefaultValue
Some methods have complex signatures. For example, the Web service to get SAP customers might take six parameters, three of which might be structures with subparameters. To make it easier for users to call these methods, the Business Data Catalog allows you to specify default values for the parameters in the metadata. This way, users can invoke predefined business logic without having to undertake parameter construction.
The user can override any input parameter for which you have defined a DefaultValue. The user must specify any input parameter that has no DefaultValue, if the parameter is not optional.
For each abstract primitive in a TypeDescriptor object, you can define multiple default values, each of which corresponds to a particular MethodInstance object. At run-time, depending on which MethodInstance object the client executes, a parameter will be instantiated based on the corresponding default values.
Working with Nullable Types
When setting a DefaultValue for System.Nullable, TypeDescriptor objects, do NOT set the Type of the DefaultValue to System.Nullable. If you leave off the default value, the Business Data Catalog will plumb the value NULL; if you set a default value, the explicit default value will get passed through.
Good example
<Parameter Name="1" Direction="In">
<TypeDescriptor Name="X" TypeName="System.Nullable[[LobService.BugEnumTest, PSBugWS]]" AssociatedFilter="test">
<DefaultValues>
<DefaultValue MethodInstanceName="Finder" Type="LobService.BugEnumTest, PSBugWS">Two</DefaultValue>
</DefaultValues>
</TypeDescriptor>
</Parameter>
Bad example
<Parameter Name="1" Direction="In">
<TypeDescriptor Name="X" TypeName="System.Nullable[[LobService.BugEnumTest, PSBugWS]]" AssociatedFilter="test">
<DefaultValues>
<DefaultValue MethodInstanceName="Finder" Type="System.Nullable[[LobService.BugEnumTest, PSBugWS]]">Two</DefaultValue>
</DefaultValues>
</TypeDescriptor>
</Parameter>
Example
<DefaultValues>
<DefaultValue MethodInstanceName="ProductFinderInstance"
Type="System.Int32">0</DefaultValue>
</DefaultValues>
Schema
Child | Type | Occurs | Default | Limits / Accepted Values | Description |
---|---|---|---|---|---|
#text |
Text |
1..1 |
Min. length: 1 |
The default value. If the type is a DateTime, the value is a string in the DateTimeFormatInfo.UniversalSortableDateTimePattern format. If the type is a subclass of Enum, the value is the string representation of the enumeration value. If the type is a GUID, the value is of the format “XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX” If the type is a type a "primitive" (Int16, Int32, Int64, Single, Double, Decimal, Boolean, String, Byte, and so on), the value is a string representation of the type (we use XmlReader.ReadElementContentAsString().) If the type is any other serializable type, the value is a binary-formatted, base64-encoded string. |
|
MethodInstanceName |
Attribute (String) |
1..1 |
The name of the MethodInstance to which this DefaultValue applies. |
||
Type |
Attribute (System.String) |
1..1 |
System.Int16 System.Int32 System.Int64 System.Single System.Double System.Decimal System.Boolean System.String System.Byte System.UInt16 System.UInt32 System.UInt64 System.Guid System.String System.DateTime Any other serializable type (such as where Type.IsSerializable == true) |
The type of the default value. |
See Also
Tasks
AdventureWorks SQL Server 2000 Sample
How to: Get Started with Using the Runtime Object Model
How to: Get Started with Using the Administration Object Model