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


Chapter 7 Transaction Pipeline Processing : Transformations (XSLT Mapping)

Transformations (XSLT Mapping)
To define the XSLT mapping for facade or target request and response messages, files are defined in the Mapping tab of the Config UI. See XSLT Mapping Type.
For the XSLT mapping, the Response Type indicates the output of the transformations, which can be as follows:
Payload
If the Response Type is specified as Payload, the output document of the transformation contains just the payload and is used as the request payload for the next stage in the request pipeline processing.
The output document of the mapping transformation either becomes a canonical request or a southbound request, just depending on where you are in the request processing pipeline.
For example, the output document from the northbound forward mapping is a payload XML document. This becomes the canonical request and is populated as the input for the southbound forward mapping.
Full
If the Response Type is specified as Full, you can access additional fields from the transaction object. The main field is the request context field which contains the HTTP headers information, URI, user name, and other authentication fields.
This provides the mapping and transformations of the full transaction (request) object. The transaction context contains the header information and the payload. After the transformation is done, the Core Engine processes the request as follows:
You can do the following using the Response Type as Full transformation:
The following functionality is implemented using the Full Response Type of mapping transformation capability:
Set error codes for content validation
With the mapping transformation with Response Type as Full, you can set the error code when the validation of the contents fails. The output of the transformation is a document which contains the updated transaction object with the error code.
For example, in case of extra validation of requests like semantic validation using XPath, it sets the error code if it fails. With the Full mapping type, the error code is updated in the transaction object. The request message processing follows the error handler path in the request processing pipeline, and is sent back to the original requestor with the error message. See Implement Request Validation.
Validation
Using the validation feature, you can do the schema validation against XSD for an incoming request message. Request validation is performed during the request parsing step and after the authorization step in the request processing pipeline.
Enabling Validation
To enable the request validation, follow these steps:
In the ROUTING > Facade Operations tab of the Config UI, set the Operation Features parameter as follows:
Operation Features Validation
In the MAPPING > Schemas tab of the Config UI, set the XSD file reference as follows:
New XSD File location of the XSD file
Implement Request Validation
Validation of requests is supported for the following stages:
The request message can be validated at the request parsing stage. The following elements exist in the schema for the output message to be used by the Parse XSLT:
<errorCode>
<errorMessage>
If errorCode is set, the request is handled by the error processing path of the processing pipeline. An error XSLT, as defined, for the operation generates an error response message by executing the FaultReportXSLT that is defined for the operation. The request is rejected with the error message sent back as the response to the request.
Extended request or response validation can be implemented at any of the four mapping steps. If the message does not pass the validation rules, an error message is constructed and returned in the message.
To set an Error Code in the transformation step, follow these steps:
xmlns:map="http://www.tibco.com/asg/mapping"
xmlns:err="http://www.tibco.com/schemas/asg/error"
<map:mapping-result>
<map:error>
Within "http://www.tibco.com/schemas/asg/error" namespace, use the following error elements to set error code and message details:
<errorCode>
<errorMessage>
<errorBody>
<errorDetails>
<nestedError>
</errorDetails>
With the mapping registered as Full mode, if an error element within the registered namespaces is found in the output message, the error attributes for the request object are set with the corresponding values in the elements from the /schemas/asg/error schema from the output message.
This instructs the Core Engine to follow the error handling path of the processing pipeline. An error XSLT, as defined, for the operation generates an error message. The request is rejected and the error message is sent back as the request response.
In the Parsing step, you can only set the errorCode and errorMessage.
In any of the four mapping steps, you can return four error elements: errorCode, errorMessage, and additional elements as errorBody and errorDetails. In case, if errorCode and errorMessage are only set, then the request processing is handled in same way as in the parse step. The additional elements, errorBody and errorDetails elements allows you to construct the actual error response message for the request, which can override the creation of error message by the FaultReportXSLT. This helps to speed up processing as no second XSLT action have to be executed.
Map the Protocol Headers in Request Context
You can transform the protocol headers within the request and response messages which includes the transport related information.
Use the responseType as Full to access the request context field. The request context field contains the transport level information and is available for any transformations. The request context field is used for the following purposes:
Enumeration Orchestration
Enumeration Orchestration is implemented using the mapping capability of TIBCO API Exchange Gateway.
With parallel orchestration, a single inbound request is split into a set of multiple outbound sub-requests. Each sub-request may be routed differently to various service endpoints. After processing and receiving the responses for each sub-requests, all responses are recombined into a single response message for the original inbound request.
Define the transformations for the northbound request forward mapping in such a way that the output document contains the sequence that defines the enumeration orchestration. This output document from this transformation serves as an input for the southbound forward request mapping. This contains the <asg_map:repeat> tag for enumeration and instructs the Core Engine to split the requests.
Enumeration orchestration is done at the southbound forward mapping meaning that one payload is split into multiple sub-requests independently. It also allows you to override the routing key. For each sub-request, the routing key can be defined so that each sub-request is forwarded to a separate service endpoint. Enumeration orchestration modifies the routing of sub-requests to a different service at the southbound forward mapping boundary.
The following example shows the snippet of forward southbound mapping transformation for enumeration orchestration:

 
<asg_map:repeat>
<asg_map:payload-xml>
<asg_map:mapping-result>
<asg_map:routingKey>getbookbyAuthor_AAA.HTTP</asg_map:routingKey>
<asg_map:payload>
<SOAP-ENV:Envelope>
<SOAP-ENV:Body>
<...>
<..>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
</asg_map:payload>
</asg_map:mapping-result>
</asg_map:payload-xml>
<asg_map:payload-xml>
<asg_map:mapping-result>
<asg_map:routingKey>getbookbyTitle_BBB.JMS</asg_map:routingKey>
<asg_map:payload>
<SOAP-ENV:Envelope>
<SOAP-ENV:Body>
<...>
<...>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
</asg_map:payload
</asg_map:mapping-result>
</asg_map:payload-xml>
</asg_map:repeat>

 
For example, GetLocation is a service which finds the location for a single service. This service can be exposed as a service to find location for a group of services. This means that the gateway has to map one request to multiple requests per service. For this case, the payload in the operation request contains a sequence of multiple requests which has to be spilt and sent individually to each service endpoint.
Re-combination of Response Documents
Transformations are defined at the southbound reverse response mapper boundary to re-join the multiple response documents for each sub-request into a single response document.

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