You are on page 1of 26

10

Service Scripts

Copyright © 2009, Oracle. All rights reserved.

Check Point
• You know how to:





Define a BO's data structure (i.e., its schema)
Create plug-ins for a BO
Create a child BO that inherits rules defined on a parent BO
Define a BO's lifecycle
Define rules for the different stages of a BO's lifecycle
Control who can access and update a BO

• In this section, you'll learn how to create service scripts to
encapsulate common logic

10 - 2

Copyright © 2009, Oracle. All rights reserved.

Oracle. All rights reserved.10 What Is A Service Script? Copyright © 2009. .

Oracle. but it doesn't work so well if the logic is a small section of a logical transaction • You can create an algorithm and place it into a common parent BO – But what if the BO's don't share a common parent? 10 .. All rights reserved.g.4 Copyright © 2009. .Problem Statement • What if there exists common logic that needs to be invoked by many BO's • For example: • Many BO's may share common validation logic • Many BO's may share common post processing logic • You've learned several techniques to encapsulate this logic: • You can create an algorithm and plug it in on the various BO's – This works great for "stand-alone" logic (e. create a To Do entry).

.5 Copyright © 2009. you'll learn about service scripts… 10 . All rights reserved. Oracle.Introducing Service Scripts • Service scripts provide another approach • Service scripts are nothing more than common routines that have been developed using the scripting language (rather than Java or Cobol) • In this section.

Oracle. Edit data steps can also invoke service scripts Step Type • Conditional branch • Edit data • Go to a step • Invoke business object • Invoke business service • Invoke service script • Label • Move data • Terminate Copyright © 2009.6 And yes.Service Scripts Are Invoked From Scripts • The main reason to set up a service script is to encapsulate commonly used logic that's needed by your plug-in scripts (and by other service scripts) • The other reason to set these up is something you'll learn later in this class (it's when you need to invoke a service script from the UI) Script (Plug-in & Service) Step 10 . All rights reserved. .

Oracle. All rights reserved. .10 Plug-in Scripts versus Service Scripts Copyright © 2009.

. you created a plug-in script using the Script transaction • You'll find that you use the same transaction to create service scripts • This section explains the similarities and differences between these two types of scripts Script Plug-In 10 .Service Scripts Are Very Similar To Plug-in Scripts • Earlier. Oracle. All rights reserved.8 Foreshadowing: there is a 3rd type of script that will be discussed later in this course (Business Process Assistant scripts) Service Copyright © 2009.

e. Plug-In Scripts Don't • Earlier. .9 You must define a service script’s input and output elements by setting up a schema Plug-In Service <input type="group"> <driversLicenseNo /> </input> <output type="group"> <customerId /> </output> Copyright © 2009. All rights reserved. a service script's schema defines its API (i. its input and output fields) • Note .you can’t declare a schema for a plug-in script because the base-package defines its “input and output” (in its hard parms) Script Algorithm Entity A plug-in script’s “input and output” is defined by its plug-in spot and that's why no schema is allowed for these types of scripts 10 .Service Scripts Have A Schema.. you learned how a BO has a schema in which its data structure is defined • Service scripts also have a schema. Oracle.

.Validating The Input Elements For Service Scripts • Note . Oracle.. 10 ...10 Copyright © 2009.you can use the various schema attributes that you learned about if you want the system to perform basic validation of the service script's elements (e.g. you can use these to validate the input elements) Script Plug-In Service GetPersonAndPremInfo Service Script Schema <personId required="true" fkRef="PER" /> <premiseId required="true" fkRef="PREM" /> <effectiveDate required="true" dataType="date" /> <reasonCode required="true" dataType="lookup" lookup="REAS_FLG" /> . All rights reserved.

11 • Conditional branch • Edit data • Go to a step • Invoke business object • Invoke business service • Invoke service script • Label • Move data • Terminate Copyright © 2009. .Same Step Types • Plug-in and service scripts support the same step types • There are no differences in their features or functions Script (Plug-in & Service) Step Step Type Notice how you can invoke business objects and other service scripts 10 . Oracle. All rights reserved.

Later in this course. Oracle. you’ll learn about business services (these are common routines written in Java or Cobol) .Same Data Areas And Xpath Manipulation • Both plug-in and service scripts have data areas • The superset of all data areas plus the script's schema / hard parms is held in a single XML document that you manipulate using xpath Script (Plug-in & Service) Each entry references an object that has a schema Data Area Notice how neither plug-in nor service scripts can reference a plug-in script (this is because only the base-package modules can invoke plug-in scripts) 10 . BO’s and stand-alone data areas have their API / data structure defined in a schema Service Script Business Service Copyright © 2009. service scripts. All rights reserved.12 BO Standalone As you know.

All rights reserved. Oracle. .10 Access Rights Copyright © 2009.

you learned how a BO's application service governs who can access and update it • Service scripts can optionally reference an application service • If a service script has an application service. All rights reserved.14 Application Service Service This is optional Copyright © 2009. Plug-In Scripts Can't • Earlier.Execute . Oracle.Service Scripts Can Be Secured. the user must have access right to this app services in order to execute the service script Script Plug-In 10 . This type of service has a single valid action .

When Are Access Rights Checked? • Just like for BO interaction. Oracle. DB . access rights are only checked for the initial service script invocation. in turn. All rights reserved. with one exception… 10 . invokes a BO and two other service scripts.15 Copyright © 2009. access rights are checked for the initial service script invoked in a service call Web Server Application Server If a service call invokes a service script which.

All rights reserved.16 Service GetCustomerForDriversLicense Service Script Schema <schema appSecurity="true" > <input type="group"> <driversLicenseNo /> </input> <output type="group"> <customerId /> </output> </schema> Copyright © 2009. • If a "2nd level" BO invokes another BO. access rights will not be checked for the "3rd level" BO • If a "2nd level" service script has this attribute set as shown. access rights will be checked for the "3rd level" BO's and service scripts Script Plug-In 10 . Oracle. access rights are checked for all "2nd level" BO's and service script interactions performed by the script • Note.Checking Access Rights Of 2nd Level Calls • If the schema's root node has an appSecurity="true" attribute. .

10 Transaction Globals Copyright © 2009. Oracle. . All rights reserved.

we'll describe another technique – global variables 10 .There's Another Way To Pass Data To A Service Script • We discussed how a service script has a schema in which its input and output elements are declared • Passing data to a script in its input is the "normal" way to supply input • In this section. . Oracle. All rights reserved.18 Copyright © 2009.

Oracle.Globals Are Ephemeral • Global variables are only available within plug-in and service scripts • The global variable will be available for the duration of the service script and all that it invokes 10 .19 Copyright © 2009. All rights reserved. .

you just have to move something to an element prefixed with $$ • For example. Oracle. All rights reserved.Initiating A Global • To create a global variable. 10 .20 Copyright © 2009. the following Edit Data statement would create a global and populate it with a value of true move 'true' to $$skipValidation. .

10 . end-if. .Using A Global • Once a global is populated. All rights reserved. it can be interrogated in any plug-in or service script that's invoked if ($$skipValidation = 'yes') terminate.21 Copyright © 2009. Oracle.

And Then It Disappears • After the service / plug-in script that initiated it completes. . Oracle. All rights reserved. the global evaporates (so you don't have to worry about turning it off on subsequent updates) 10 .22 Copyright © 2009.

Oracle.23 Copyright © 2009.Defaulting Schema Values From Globals • A global variable can be used as a default value for a schema element • Obviously. the script that invokes the object with the schema needs to initialize the global variable <schemaElement default="$$globalVariable"/> 10 . . All rights reserved.

please prepare a brief checklist of everything that you plan to add / change and have your instructor verify it before adding your data 10 . . All rights reserved.Team Walk Through (90 minutes) • Create a service script that has validation logic • Break up into teams and follow the instructions in the workbook Before you start adding any meta-data.24 Copyright © 2009. Oracle.

25 Copyright © 2009. . Oracle.Review Questions 10 . All rights reserved.

10 . All rights reserved. . Oracle.26 Copyright © 2009.