Using the Compliance XQuery Policy

Learn about using the Compliance XQuery Policy to execute an XQuery statement on a service or message model to determine compliance.

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

Table of Contents

About the Compliance XQuery policy

XQuery is a query language that queries and transforms collections of structured and unstructured data, usually XML. XPath is a subset of XQuery.

The Compliance XQuery policy executes an XQuery statement on the service or message model to determine compliance.

Creating a Compliance XQuery 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.

Configuring a Compliance XQuery policy

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

To configure a Compliance XQuery 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 XQuery policy.
  3. In the second section, click Modify. The Modify Compliance XQuery Policy page opens, as shown below.

    The XQuery compliance policy page

  4. Choose an asset type. For information on the individual options, see Compliance XQuery Policy Options below.
  5. Follow the steps for the specific asset type, to populate the Query Builder:
  6. When the Query Builder pane is populated, choose elements that you want to include in your Compliance XQuery policy. Use the arrow buttons to copy elements to the Namespace Declarations and/or XQuery fields.
  7. Click Evaluate to test the information, and debug as needed.
  8. When done, click Finish. The policy definition is saved.

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

Compliance XQuery policy options

The Modify Compliance XQuery 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, or 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 XQuery 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 XQuery policy. The applicable screen is displayed, depending on the asset type:
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.akana.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
Evaluates the XQuery statement 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 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
Warning Message
Specify the warning message to be displayed if the XQuery statement evaluates to a warning (#4 above).
Error Message
Specify the error message to be displayed if the XQuery statement evaluates to an error (#5 above).

Populating an XQuery policy with schema or WSDL data

To populate a XQuery 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.

Populating an XQuery policy with service data

To populate a XQuery 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 XQuery policy (Step 6 onwards).

Populating an XQuery 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 go to the Modify XQuery Policy page.

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.

Activating a policy

When you create and configure a policy, the policy is in Draft state. When the policy configuration is complete, activate the policy: click Activate Policy and then confirm. See Activate a Policy.

A policy in Draft state is not available for general use. Once you activate the policy, it is in Active state and is available for use.

Attaching a policy

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