Using the Compliance Script Policy

Learn about using the Compliance Script Policy to select content for analysis and perform the analysis.

About Policies Managing Policies About Compliance Policies

For information about using policies in the context of the developer portal, see Business Policies.

Table of Contents

  1. About the Compliance Script policy
  2. Creating a Compliance Script policy
  3. Configuring a Compliance Script policy
  4. Compliance Script policy options
  5. Populating a Compliance Script policy with schema or WSDL data
  6. Populating a Compliance Script with service data
  7. Populating a Compliance Script with exchange (message) data
  8. Attaching the policy

About the Compliance Script policy

The Compliance Script Policy uses a combination of XQuery and Java to first select the content for analysis and then to perform the analysis.

The first sections of the policy definition allow you to identify the content on which the script will be run. The next step is to define the script that will be run on the content.

back to top

Creating a Compliance Script policy

The first step in creating a policy is to define the basic policy information.

To add a compliance policy
  1. Go to Workbench > Browse > Organization, and select Policies > Compliance Policies. The Policies Summary is displayed.
  2. Click Add Policy.
  3. Choose the policy type and click Next.
  4. Specify a name (required) and description (optional) and click Finish. At the Completion Summary, click Close. The Add Policy Wizard creates a draft policy instance that you can then configure on the Policy Details page.

For more information, see Add Policy.

back to top

Configuring a Compliance Script policy

Once you've created the policy, you can configure the policy options.

You can define a script rule to evaluate exchange, schema, service, or WSDL asset types by defining namespace declaration, an XQuery statement, and a script.

To configure a Compliance Script policy
  1. Go to Workbench > Browse > Organization and select the Policies > Compliance Policies folder. The Policies Summary is displayed.
  2. Find the policy on the list and click to go to the pane for the Compliance Script policy.
  3. In the second section, click Modify. The Modify Script Policy page opens, as shown below.

    Configuring a Compliance Script Policy

  4. Choose the asset type. Specify values for the policy as needed. For information on the individual options, see Compliance Script Policy Options below.
  5. Choose a script language, and define a script.
  6. Save the policy definition.

That completes the policy configuration. You can now assign the policy to a service.

back to top

Compliance Script policy options

The Modify Compliance Script Policy wizard includes the options listed below.

Asset Type
Choose from the list of supported asset types that can be evaluated by the current rule definition including exchange:
Tree Hierarchy
The tree hierarchy stores the asset information that you specify for the current policy definition. You can populate it with any one of the four asset types (message, schema, service, and WSDL). When you choose the asset type, define the source, and click Load Context, the tree hierarchy is populated with the content.
After the tree hierarchy is populated, you can select Namespace Declarations and XPath expressions and transfer them to the target text boxes (Namespace Declarations and XQuery) by clicking the arrow buttons.
Load Context
Once you've specified the asset type, click the Load Context button to populate the tree hierarchy of the Query Builder with data to use in defining your Compliance Script policy. The applicable screen is displayed, depending on the asset type:
  • Exchange—Displays the Select Usage Log screen which allows you to search for a usage log to upload into the tree hierarchy of the Query Builder.
  • Schema—Displays the Upload File screen which allows you to upload a schema into the tree hierarchy of the Query Builder.
  • Service—Displays the Upload Service screen which allows you to navigate a tree hierarchy and select a service to be uploaded tree hierarchy of the Query Builder.
  • WSDL—Displays the Upload File screen which allows you to upload a WSDL into the tree hierarchy of the Query Builder.
Namespace Declaration
You must specify the namespace declaration for the XQuery statement. All namespace declarations are separated by a semi colon (;) and are of the form:
declare namespace compCtx='http://www.soa.com/2007/Compliance-Context';
This provides namespace prefix resolution for the XQuery statement, effectively decoupling the XQuery statement from literal namespace prefixes.
XQuery
The XQuery text box must contain the comp context (compCtx:) for the selected asset.
Evaluate (XQuery statement)
Evaluates the XQuery statement against the current context and displays the results in the associated text box.
The XQuery statement must evaluate as follows:
  1. A Boolean result of true for a passed rule
  2. A Boolean result of false for a failed rule
  3. An integer value of 0 for a passed condition
  4. 1 to denote a warning
  5. 2 to denote an error
Script Language
A drop-down list box that allows you to select a script language to apply to the configuration. Supported script languages:
Script
The script is defined using a scripting language to evaluate the XQuery result and return a result.
Evaluate (Script)
The evaluate button evaluates the script against the current context and displays the results in the associated text box.
Note that the Query Builder implementation is for advanced users and requires a working knowledge of XPath / XQuery.
The script statement must evaluate as follows:
  1. A Boolean result of true for a passed rule
  2. A Boolean result of false for a failed rule
  3. An integer value of 0 for a passed condition
  4. 1 to denote a warning
  5. 2 to denote an error

back to top

Populating a Compliance Script policy with schema or WSDL data

To populate a Compliance Script policy with schema or WSDL data, you'll need to upload the applicable file. From the Asset Type list, select schema or wsdl, and then click Load Context. The Upload File page is displayed, as shown below.

Upload File page

Upload the asset file (schema or WSDL) to be used for testing the current Compliance Policy. Make sure you upload the correct file type, according to the asset type you specified.

The Query Builder tree is populated with the file you uploaded.

back to top

Populating a Compliance Script policy with service data

To populate a Compliance Script policy with service data, choose an Asset Type of service and then click Load Context.

The Select Policy Asset page is displayed, as shown below.

Select Policy Asset page

Here, you can upload an asset file (Service) to be used for testing the Compliance Policy.

Navigate the tree hierarchy, choose a service, and click Next. You are returned to the Modify Policy page, and the service information is displayed in the Query Builder tree, as shown below.

Query Builder, populated

You can now configure the policy further based on the service you selected, following the steps in To configure a Compliance Script policy (Step 6 onwards).

back to top

Populating a Compliance Script policy with exchange (message) data

To populate the policy with message data, choose Exchange from the Asset Type list, and then click Load Context. The Select Usage Log screen is displayed.

On this page, you can filter usage data, as shown below.

Select Usage Log page

Choose a service/operation combination and specify a time range filter. Configure the Observer Filter and Time Range Filter and then click Refresh.

After completing the search, choose the usage logs you would like to use to populate the Query Builder, and then click Next.

To view details for selected usage records, select a usage data report line item and click View Usage Record Details. The Usage Record Details screen displays with a list of usage data fields and associated SOAP messages.

Usage Record Details page

This page includes the following:

Usage Detail
The Usage Detail tab allows you to navigate the list of SOAP messages associated with the current usage record. To navigate to the next SOAP message, click Next or Previous.
Recorded Messages
The Recorded Message section displays SOAP messages associated with the usage record of the current service. To view the message details for the current SOAP message, just click the line item. To view message details in XML format, choose Raw Format. To save the selected SOAP message, click Save.
Transaction Events
The Transaction Events section displays a list of transactions associated with the selected service. Each line item includes the following:
  • Service
  • Operation
  • Elapsed Time
  • Response Time
  • Errors

To view the usage detail for a transaction, just double-click the line item. An example is shown below. The example below combines the display of all three tabs.

Usage Data Report

To exit, click Close.

back to top

Attaching the policy

To use the policy, go to the Policies folder in the Root Organization and attach the policy to a web service, binding, or binding operation.

Back to top