Copyright © Cloud Software Group, Inc. All Rights Reserved
Copyright © Cloud Software Group, Inc. All Rights Reserved


Chapter 2 ActiveMatrix Implementation Type for Microsoft CLR Component Development : Context Parameters

Context Parameters
A context parameter is a name-value pair passed to a service operation invocation. The values are populated by bindings, which map transport and binding headers to context parameters. Context parameters allow component developers to access transport and binding metadata that could affect the execution of an operation but which is not passed in the input, output, and fault messages defined by an abstract WSDL.
For additional conceptual information about the use of context parameters in ActiveMatrix, see TIBCO ActiveMatrix Service Grid Component Development.
Using Context Parameters with ActiveMatrix Implementation Type for Microsoft CLR
Because ActiveMatrix Implementation Type for Microsoft CLR uses a bottom-up development approach, context parameters are defined in the WCF project implementation code. Context parameters are then automatically populated in the service model when the implementation is imported into TIBCO Business Studio.
Using the code-first approach (it is not possible to create context parameters when using the WSDL-first approach), you expose the context parameters in the WCF implementation by decorating methods with the ContextParameter attribute. The ContextParameter attribute and its properties determine the Operation, Type, and Direction of the context parameters available to ActiveMatrix Implementation Type for Microsoft CLR components in ActiveMatrix.
Expose the ContextParameter Attribute in the WCF Service
Add the ContextParameter attribute to the desired methods using the syntax:
[ContextParameter("Parameter-Name", Direction.INPUT|OUTPUT)]
Parameter-Name must match either a field or a property in the same class as the service method, while the Direction setting identifies whether the data will be injected (INPUT) into the operation, or pulled out of (OUTPUT) the operation.
For example:

 
[ContextParameter("InputParameter", Direction.INPUT)]
[ContextParameter("OutputParameter", Direction.OUTPUT)]
public string TellTime(string helloRequest) {...}

 
The method name in the code equates to the operation name in the WSDL, so the method you decorate with the attribute determines the context parameter’s Operation name in TIBCO Business Studio. The Parameter-Name determines the name of the context parameter, while the Direction setting determines the direction.
Table 4 shows how the values in the Context Parameters table in TIBCO Business Studio are determined:
The name of the data item specified by the Parameter-Name in the ContextParamter attribute. This value identifies where the context parameter data is injected or pulled from, as determined by the Direction.
The name of the method that the ContextParameter is decorating.
To configure a Fault, the Parameter-Name must point to a declared fault.
Bag - the data item is a .NET Dictionary<string, string> type.
Message - the data item is a complex object that is declared with a MessageContract. Any context variable that you want to pass as a message type must be declared using MessageContract. See Define Message Types for additional information about defining Message types.
Define Message Types
Context parameters that refer to complex objects, or messages, require additional configuration in the WCF implementation code.
1.
Identify the data item specified by the Parameter-Name as a Message type by declaring the item using MessageContract.
Do not set IsWrapped to false. The IsWrapped property must be true.
Also do not use the MessageHeaderAttribute in a message context parameter.
2.
For example:

 
[MessageContract()]
public class LocalTime
{
  public LocalTime()
  {
  }
 
  public LocalTime(string time, string location)
  {
    this.time = time;
    this.location = location;
  }
 
  [MessageBodyMember]
  public string time;
  [MessageBodyMember]
  public string location;
 
...

 
Message contracts are commonly used to insert custom SOAP headers. For more information, see Microsoft documentation on using message contracts in operations.
 

Copyright © Cloud Software Group, Inc. All Rights Reserved
Copyright © Cloud Software Group, Inc. All Rights Reserved