Software AG Products 10.7 | Integrating On-Premises and Cloud Applications | DSPs and building output templates | Using Output Templates to Format Service Output | %invoke%
 
%invoke%
You use the %invoke% tag to execute a service from a DSP. When you use this tag, the server executes the specified service at run time and returns the results of the service to the DSP. You may optionally include the %onerror% tag within the %invoke% block to define a block of code that executes if an exception occurs while the service executes or the service returns an error.
This tag can only be used in DSPs. It cannot be used in an output template.
Syntax
%invoke serviceName%
Block of Code
[%onerror%

Block of Code]
%end%
Arguments
serviceName specifies the fully qualified name of the service that you want to invoke.
Effect on Scope
Within an %invoke% block, the scope switches to the results of the service. If the service fails, the scope within the %onerror% block contains the following:
Key
Description
error
A String containing the Java class name of the exception that was thrown (e.g., com.wm.app.b2b.server.AccessException).
errorMessage
A String containing the exception message.
errorInput
The IData object that was passed to the invoked service.
errorOutput
The IData object containing the output returned by the invoked service. If the service returned an error, errorOutput will contain $error. If the service experienced an exception, errorOutput will not exist.
errorService
The name of the invoked service.
Examples
The following example invokes a service that returns shipping information and a form allowing the user to optionally edit or cancel an order. This example also includes a %onerror% block that displays error information if the service fails.
%invoke orders:getShipInfo%
<H2>Shipping Details for Order %value /oNum%</H2>
<P>Date Shipped: %value shipDate%<BR>
Carrier: %value carrier% %value serviceLevel%
</P>
<HR>
%ifvar shipDate -isnotempty%
<FORM ACTION="http://rubicon:5555/orders/editShipInfo.dsp" METHOD="get">
<P><B>Change this Shipment:</B></P>
<P><INPUT TYPE="RADIO" NAME="action" VALUE="edit">
Edit Shipment Details</P>
<P><INPUT TYPE="RADIO" NAME=action" VALUE="cancel">
Cancel this shipment</P>
<INPUT TYPE="SUBMIT" VALUE="Submit">
<INPUT TYPE="HIDDEN" NAME="oNum" VALUE="%value /oNum">
</FORM>
<HR>
%endifvar%
<P><A HREF="http://rubicon:5555/orders/getorder.dsp
?action=showorder&oNum=%value /oNum%">View Entire Order</A></P>
%onerror%
<HR>
<P><FONT COLOR="#FF0000">The Server could not process your request
because the following error occurred. Contact your server
administrator.</FONT></P>
<TABLE WIDTH="50%" BORDER="1">
<TR><TD><B>Service</B></TD><TD>%value errorService%</TD></TR>
<TR><TD><B>Error</B></TD><TD>%value error% &nbsp;
%value errorMessage%</TD></TR>
</TABLE>
<HR>
%endinvoke%
.
.
.