Designer 10.15 | webMethods Service Development Help | Mapping Data in Flow Services | About Assigning Values to Pipeline Variables | Assigning Global Variables to Pipeline Variables
 
Assigning Global Variables to Pipeline Variables
A global variable is a key/value pair that you define using Integration Server Administrator. You can use a global variable in a flow service by assigning the global variable to a variable in the pipeline (specifically a variable in Service In or Pipeline Out). At run time, Integration Server uses the value of the global variable as the value of the pipeline variable.
Using global variables makes it easy to change the value assigned to a pipeline variable at run time or after you deploy a solution to a different Integration Server. Instead of changing the hard-coded value of a pipeline variable, you change the value of the global variable. For example, you could create global variables for the connection parameters required by pub.client:ftp service. You might create global variables for the FTP server name, a user on the FTP server, and password for that user. In flow services that invoke pub.client:ftp you could assign the global variables to the serverhost, username, and password input parameters. After deploying the flow service to different servers, you may need to use different values for the serverhost, username, and password input parameters. You can use Integration Server Administrator to change the value of the global variables on the target servers. This is more efficient than editing the services to change the hard-coded values.
You can define global variables at the server level or package level. All services in Integration Server have access to a server-level global variable, whereas a package-level global variable is only accessible within the same package as the service. For more information about defining global variables, see webMethods Integration Server Administrator’s Guide.
When Integration Server encounters global variable substitution during service execution, Integration Server first looks for the global variable in the same package as the service. If not found, Integration Server looks for the global variable at the server level. You can override this default behavior by specifying whether the service must use a server-level or a package-level global variable. To use a server-level global variable, prefix the variable name like this: %server:variablename%. To use a package-level global variable, prefix the variable name like this: %package:variablename%.
Keep the following points in mind when using global variables in flow services:
*To specify a global variable as the value for a pipeline variable, you enclose the name of the global variable in % symbols (for example, %myFTPServer%).
*You can use global variables to specify values for variables of type String, String List, and String Table only. For more information, see Assigning a Value to a Pipeline Variable.
*You can mix literal and global variables. For example, if you specify (%areaCode%) %Phone%, the resulting String would be formatted to include the parentheses and space. If you specify %firstName% %initial%. %lastName%, the period and spacing would be included in the value.
*You can assign a pipeline variable a value comprised of a global variable and a pipeline variable. For more information, see Assigning String Variables and Global Variables to the Same Pipeline Variable.
*If global variables at the server and package level are identical, use the server: or package: prefix to indicate the global variable that you want to use.
*You must select the Perform global variable substitution checkbox for the variable substitution to occur at run time.
*If the specified global variable has the same name as a pipeline variable name and you select the Perform global variable substitution checkbox and the Perform pipeline variable substitution checkbox, Integration Server uses the value of the pipeline variable at runtime.
*If the global variable that you specified for performing a variable substitution is not defined in Integration Server, at runtime Integration Server throws an exception and service execution fails.
For more information about defining global variables, see webMethods Integration Server Administrator’s Guide.