Binding a REST Web Service Data Source to a Mobile Business Object

Bind the attributes and operations of a REST (Representational State Transfer) Web service to a mobile business object.

The main difference with binding to a REST Web service data source and any other Web service data source is the definition page. Other pages (parameter mapping, attributes mapping, role mapping, and so on), are the same. Successfully invoking a REST Web service requires:
  1. A URI template.
  2. An HTTP method.
  3. A request representation using XSD.
  4. A response representation using XSD. For Read operation attributes, the response representation is mandatory. For Create, Update, Delete and Other operations, the request and response representation is optional.
  5. An optional XSLT if necessary, except for Read operation attributes, for which an XSLT is mandatory. You can also can define multiple-XSLTs for a commingled MBO (multiple MBOs from a single operation).
  6. HTTP headers declaration.
  7. Optional authentication configuration.
  1. In the Bind Data Source wizard, enter the following information and click Next:
    Field Action
    Data source type REST Web Service
    Connection profile Select the REST Web Service connection profile to which you are binding your mobile business object attributes. If the required data source is not in the list, click Create to define a new connection profile.
  2. Enter the attributes definition information in the Attributes wizard. This information translates into the detailed tabular view of the REST Web service which is mapped to mobile business object attributes:
    • Resource base URL – the base URL for a REST Web service resource URL, required to construct the resource URI. For example, http://example.com.

      The base URL was defined in the connection profile, and is shown (read-only) in the definition page for attributes or operations.

    • Resource URI template – The URI template is appended to the base URL (for example, customers/{id}). The template determines how the URI is parsed so all possible parameters are retrieved. All parameters are treated as enterprise information system (EIS) operation arguments, enabling MBO create, read, update, and delete (CRUD) operations on the REST Web service resources.
      You can specify the datatype for parameters defined in the URI template using this format:
      {paramName(xsdType)}
      For example, '/getCustomer/{id(int)}'. A string datatype is used if you do not explicitly specify the datatype. You can also specify support of nullable for the parameter as: '/getCustomer/{id(int?)}'. These datatypes can be specified in the URI template and are case-sensitive:
      • boolean
      • string
      • binary
      • char
      • byte
      • short
      • int
      • long
      • integer
      • decimal
      • float
      • double
      • date
      • time
      • dateTime
      You cannot specify the length in the URI template for parameters, but can modify parameter length after the REST MBO is created from the Properties view.
    • HTTP method – the method called, either GET, PUT, POST, or DELETE.
    REST Web service definition
    Tab Description
    Representation – allows you to specify the request or response representation
    • Type – denotes that the representation is used either as a REQUEST or RESPONSE.
    • Name – name of the representation, which must be unique.
    • Referenced representation – All existing representations defined for the same MBO are listed and can be selected, but only the same Type of representation can be referenced. For example, if you previously defined a request representation for a create EIS operation, you can use it as a referenced request representation to define a new update representation for a EIS operation.
    Select Edit to specify the XML schema for a request or response representation, instead of referencing an existing representation:
    • Name – name of the XSD.
    • Type – Request or response.
    • XSD URL – URL to an available XSD.
    • XSD file – allows you to import the XSD from a local file.
    • Root element – The root element used as the XSD request input.
    • Load element – Select this after specifying the XSD URL or XSD file, to retrieve all available load elements defined in the XSD.

    Only one XSD can be defined for a given representation.

    Define XSLT manually – for response representation, after the XSD definition and root element was specified, Unwired WorkSpace automatically generates a default XSLT for the response representation. You can open the XSLT editing dialog to modify the XSLT. Modifying multi-XSLTs for one response representation to support commingled MBOs is also supported. All available XSLT definitions are listed in the table in the XSD definition dialog:
    • Save to file – modify by changing the selections and save to a file.
    • Load from file – since it is difficult to type in the XSLT contents accurately, this option allows you to retrieve the XSLT file from the file system. If you choose this option the XSLT text in the window is replaced by the information contained in the selected file.

    Select OK to save your definition and exit the dialog.

    Authentication
    Supports HTTP Basic Authentication:
    • User name – authenticated user
    • Password – password of the authenticated user.

    The user name and password fields can be entered directly, retrieved from a personalization key, or by selecting New key and creating a new personalization key.

    HTTP header Captures all properties needed to execute or manage the REST Web Service.
    You can enter the existing HTTP header as defined in the HTTP specification, or declare your own HTTP header. For each element of the HTTP header you can:
    • Specify if it is used as an input, output or both.
    • Specify a literal value as the HTTP header’s value.
    • Specify a "Variable" to denote it as a 'parameterized' header. For parameterized headers, Unwired WorkSpace parses and treats the value as an input argument or output column of the EIS operation (depending on whether the definition is input or output).
  3. Click Finish to use default mappings, or Next to modify the columns to attributes mapping, or parameter mapping.
  4. The Parameters Mapping screen provides a graphical view of the parameter-to-remote operation mappings. Modify the default parameter mappings by using Add, Delete and Delete all. Rearrange parameters using Up and Down. Make a connection between parameters by dragging a line from the source to the target. Parameter properties include:
    • Parameters
      • Parameter name – name of the mobile business object parameter. Names cannot contain C# or Java reserved words.
      • Datatype – enter the datatype of the parameter. It must be compatible with the datatype of the remote parameter to which it is mapped.
      • Required – The parameter is required. For example, a deployed MBO that contains user name and password parameters would require this information be supplied by the client.
    • Data Source
      • Argument – include any arguments to be passed to the parameter used by the MBO operation on the Unwired Server side when executing an MBO operation.
      • Datatype – displays the datatype to which the parameter is mapped.
      • Default value – enter a default value for the argument, or select <no default value> from the drop-down list.

    Click Next or Finish when done.

  5. The Attributes Mapping screen provides a graphical view of the columns to table mappings. You can collapse and expand the view and click the navigational buttons to rearrange attributes, remove and add individual attributes, and remove a mapping or all mappings. Click Next or Finish when done. You can remove mappings without removing associated attributes from the graphical view only.
  6. The Role Assignments screen allows you to Create, Add, and Remove role assignments from the mobile business object. Click Finish when done.