Example name: Type adaptation
Description: This example shows a Flex application:
  • Passing arguments of one type to a remote service, when
  • Its parameters are declared to be of a different type.
Prerequisites:
Client-side code: Browse  Download
Server-side code: Browse  Download
Feature availability:
  • WebORB for .NET Development Mode
  • WebORB for .NET Community Edition
  • WebORB for .NET Enterprise Edition
Run example:
Key points:
  • This is the second of the BasicCalcServer series of samples.
  • It shows two values of String type being passed as arguments to Quotient(), a remote service method.
  • Quotient()'s parameters are declared to be of type int (not String). WTF?
    • BTW, parameters appear in procedure definitions; arguments appear in procedure calls. See this discussion.
  • WebORB "adapts" the method's arguments to match the method's parameters (that is, it converts the Strings to ints).
  • This is similar to the conversion that WebORB must do to adapt the method's result type (C#'s float to ActionScript's Number).
  • It is not recommended that you make a habit of passing Strings where ints are expected. The arguments you pass to a remote service method should be of a type that is as closely-related as possible to the type of the method's corresponding parameters.
Things to try:
  • Enter non-integer or non-numeric strings into the running sample's dividend and/or divisor fields, then press the "=" button.
See also:
Errata:
  • None yet known.