# Global Schema Cache

## Contents
Overview Adding Schemas to the Cache Testing WSDL Files for WSI Compliance Organizing Schemas with Schema Containers Schema Validation

## Overview
The Schema Cache contains XML Schemas that can be used globally by Schema Validation filters. You can import XML Schemas from XML Schema files or from WSDL files. WSDL files often contain XML Schemas that define the elements that appear in SOAP messages. To facilitate this, the Policy Studio can import WSDL files from the file system, from a URL, or from a UDDI registry. When the XML Schema has been imported into the cache and selected in a Schema Validation filter, the Enterprise Gateway can retrieve the schema from the cache instead of fetching it from its original location. This improves the runtime performance of the filter, and also ensures that an administrator has complete control over the schemas used to validate messages. The Schema Cache is available as a top-level tree node on the Policy Studio Policies tab. The list schemas present in the Schema Cache are shown in the tree. You can view the contents of any of these schemas by clicking the schema. The schema contents are displayed in the Source tab on the right. At any point, you can manually modify the contents of the schema in the in the Source tab. To save the modified contents to the cache, enter Ctrl-S.
## Adding Schemas to the Cache
To add an XML Schema to the cache, right-click the Schema Cache in the tree, and select Add Schema. Alternatively, click the Add Schema link at the top of the Schema Cache screen on the right. The Load Schema dialog enables you to load a schema from an XML Schema file directly or from a WSDL file. Select the From XML Schema radio button to load the schema directly from a schema file, and click Next. On the next screen, enter or browse to the location of the schema file using the field provided. You can also enter a full URL to pull the schema from a web location. Click the Finish button to import the schema into the cache. Alternatively, if you want to load the schema file from a WSDL file, select the From WSDL radio button on the Select Schema Source screen, and click Next. The WSDL file can be located from the file system, from a URL, or from a UDDI registry. Select the appropriate option and enter or browse to the location of the WSDL file in the fields provided. If you wish to retrieve the WSDL file from a UDDI registry, click the WSDL from UDDI radio button, and click the Browse UDDI button. The Browse UDDI Server for for WSDL dialog enables you to connect to a UDDI and search it for a particular WSDL file. For more information on how to configure this dialog, see the Retrieving WSDL Files from a UDDI Directory topic.
## Testing WSDL Files for WSI Compliance
Before loading the schema from a WSDL file, you can check the WSDL file for compliance with the WS-I Basic Profile. The Basic Profile consists of a set of assertions and guidelines on how to ensure maximum interoperability between different implementations of Web Services. For example, there are recommendations on the SOAP style to use (`document/literal`), how schema information is included in WSDL files, and how message parts are defined to avoid ambiguity for consumers of WSDL files. The Policy Studio uses the Java version of the WS-Interoperability Testing Tools to test imported WSDL files for compliance with the recommendations in the Basic Profile. A report is generated showing which recommendations have passed and which have failed. While you can still import a WSDL file that does not comply with the Basic Profile, there is no certainty that consumers of the Web Service can use it without encountering problems. Important Note: Before you run the WS-I compliance test, you must ensure that the Java version of the Interoperability Testing Tools is installed on the machine on which the Policy Studio is running. You can download these tools from www.ws-i.org. To configure the location of the WS-I testing tools, select Window -> Preferences from the Policy Studio main menu. In the Preferences dialog, select the WS-I Settings, and browse to the location of the WS-I testing tools. You must specify the full path to these tools (for example, `C:\Program Files\WSI_Test_Java_Final_1.1\wsi-test-tools`). For more details on configuring WS-I settings, see the Policy Studio Preferences topic. Running the WS-I Compliance Test To run the WS-I compliance test on a WSDL file, perform the following steps: Select Tools -> Run WS-I Compliance Test from the Policy Studio main menu. In the Run WS-I Compliance Test dialog, browse to the WSDL File or specify the WSDL URL. Click OK. The WS-I Analysis tools run in the background in Policy Studio. The results of the compliance test are displayed in your browser in a WS-I Profile Conformance Report. The overall result of the compliance test is displayed in the Summary section. The results of the WS-I compliance tests are grouped by type in the Artifact: description section. For example, you can access details for a specific port type, operation, or message by clicking the appropriate link in the Entry List table. Each Entry displays the results for the relevant WS-I Test Assertions.
## Organizing Schemas with Schema Containers
If you intend to add large numbers of schemas to validate different types of requests, it makes sense to organize these types of schemas into different groups. For example, if you have a set of schemas that define types used in requests for a StockQuote Web Service and another set of schemas used to validate requests for a PurchaseOrder Web Service, it makes sense to organize each set of schemas into separate groups (for example, StockQuote Schemas and PurchaseOrder Schemas). The Policy Studio enables you to add Schema Containers for this purpose. To add a Schema Container, right-click the Schema Cache tree node, and select the Add Schema Container menu option. Enter a descriptive name for the container in the field provided on the Schema Container dialog. You can add related schemas under this container by right-clicking the container and selecting the Add Schema menu option. You can then load the schema directly from an XML Schema file, or indirectly from a WSDL file in the usual manner. Furthermore, you can create containers within containers to further organize your schemas. To do this, right-click an existing container, and select the Add Schema Container menu option. A useful feature of Schema Containers is the ability to copy and paste schemas from one container to another. For example, you can use this to copy schemas to a Test Schemas container where you can modify them and test them against incoming requests. To do this, right-click a schema, and select the Copy menu option. To copy the schema to another container, right-click the destination container and select the Paste option. Important Notes Only one schema is allowed per target namespace in any one container. This is because schemas are keyed in the cache using the `targetNamespace` in the schema. Therefore, all elements referenced by the imported schema must be in the same container as the schema. The Policy Studio automatically stores imported and included schemas in the same container as the top-level schema. However, deleting schemas from a container that contains elements referenced by other schemas in the container prevents the set of schemas from successfully validating incoming requests. If a schema has no `targetNamespace` defined, it is keyed using the full path to the file on the file system. If you add a schema that includes other schemas (using the `<include>` element) to the Schema Cache, the included schemas are added inline to the top-level parent schema. Because schemas are keyed by target namespace, and because all included schemas must belong to the same namespace as the parent schema, it makes sense to inline the included schemas.
## Schema Validation
The Schema Validation filter is used to validate XML messages against schemas stored in the cache or in the Web Services Repository. This filter is found in the Content Filtering category of filters in the Policy Studio. For more information on configuring this filter, see the Schema Validation topic.