Skip to main content
This document explains the detailed usage of a specific policy. If you are using Apinizer policies for the first time or want to learn the general working principles of policies, we recommend reading the What is Policy? page first.

Overview

What is its Purpose?

  • Ensures integration compatibility by transforming XML messages on API Proxy to the form expected by target systems.
  • Provides opportunity to apply business rules at message layer with XSLT-based XML2XML transformations.
  • Serves XML-based services to JSON-consuming clients without intermediary with XML2JSON mode.
  • Makes transformation errors traceable by catching them with standardized error messages and status codes.

Working Principle

  1. Request Arrival: For each HTTP/HTTPS request arriving at the API Gateway, the source IP address of the request is identified.
  2. Policy Check: If the XML Transformation policy is active, the system checks in the following order:
    • Is a Condition defined? If so, is the condition met?
    • Is the policy active (active=true)?
    • Is a Variable used or is Apinizer default used?
  3. XML Transformation Rules: If conditions are met, XSLT content or XML→JSON flags are loaded for selected transformationType, necessary validations are performed.
  4. Decision Making:
    • Match Found: XML content is transformed according to selected mode, result body and header values are updated according to new format.
    • No Match: Original message is forwarded unchanged through Gateway.
  5. Error Handling: Customizable HTTP status code and error message are returned for requests that do not comply with the policy rule.

Features and Capabilities

Basic Features

  • Dual Transformation Mode: Manages different integration needs under the same policy with XML2XML (XSLT) and XML2JSON options.
  • XSLT Editor and Preview: Provides validation opportunity before saving XSLT rules with advanced code editor and test tool.
  • JSON Output Optimization: Flexibly manages null, empty and number fields according to target format in XML→JSON transformations.
  • Active/Passive Status Control: Easily change the active or passive status of the policy (active/passive toggle). In passive state, the policy is not applied but its configuration is preserved.
  • Condition-Based Application: Determine when the policy will be applied by creating complex conditions with Query Builder (e.g., only for specific endpoints or header values).

Advanced Features

  • Transformation Test Laboratory: Real-time XSLT trials can be performed on XML inputs with Test Transformation Data component.
  • Conflict Prevention Mechanism: Proactively prevents conflicts between global and local policies with name uniqueness check.
  • XML→JSON Array Mapping: Transforms certain XPath expressions to JSON arrays with Array Path List parameter.
  • Export/Import Feature: Export policy configuration as a ZIP file. Import to different environments (Development, Test, Production). Version control and backup capability.
  • Policy Group and Proxy Group Support: Manage multiple policies within Policy Group. Bulk policy assignment to Proxy Groups. Centralized update and deploy operations.
  • Deploy and Versioning: Deploy policy changes to live environment. See which API Proxies use it (Policy Usage). Proxy Group and Policy Group usage reports.

Usage Scenarios

ScenarioStatusSolution (Policy Application)Expected Behavior / Result
Schema Adaptation with XSLTProducer XML schema is incompatible with consumer expectationtransformationType=XML2XML, add new XSLT.XML schema suitable for target system is sent.
Bridge from XML to JSON APIsLegacy SOAP service will be opened to REST clientstransformationType=XML2JSON, activate null/empty filters.REST client receives JSON response.
Filtering XML FieldsSensitive tags in XML body must be removedXML2XML, remove relevant nodes in XSLT.Content is forwarded without sensitive fields.
Normalizing XML Number FormatsNumbers in XML must be transmitted as stringXML2JSON, xmlToJsonNumbersAsStrings=true.All numbers are converted to string type.
Converting Nil Values to Nullxsi:nil fields should be null in JSONXML2JSON, xmlToJsonUseNullForNil=true.Null values appear in JSON output.
Array ConfigurationSingle nodes must be converted to JSON arrayXML2JSON, add XPath to xmlToJsonArrayPathList.Specified paths become JSON array.
Conditional TransformationTransformation required only in certain endpointsDefine endpoint condition in Query Builder.Transformation is not applied when condition does not hold.

Configuring Policy Parameters

In this step, users can create a new policy or configure existing policy parameters to define access rules. The defined parameters directly affect how the policy works (e.g., which IPs will be allowed, geographical restrictions, conditional activations, etc.). This allows the policy to be customized according to organization-specific requirements and managed centrally.

Creating a New XML Transformation Policy

XML Transformation Policy

Configuration Steps

StepDescription / Operation
Step 1: Going to Creation Page- Go to Development → Global Settings → Global Policies → XML Transformation Policy from the left menu.
- Click the [+ Create] button at the top right.
Step 2: Entering Basic InformationPolicy Status (Policy Status): Shows Active/Passive status. New policies are active by default.

Name (Name) Required: Example: Production_XMLTransform
- Enter a unique name, does not start with space.
- System automatically checks. Green checkmark: available. Red X: existing name.

Description (Description): Example: “Transforms SAP XML responses to JSON REST format”
- Max. 1000 characters.
- Explain the purpose of the policy.
Step 3: Selecting Transformation TypeSelect XML2XML or XML2JSON from transformationType field. Selection determines visibility of sub-parameters. When XML2XML is selected, XSLT editor opens, when XML2JSON is selected, JSON options become active.
Step 4: Managing XSLT Rules (If applicable)Enter transformation template in xsltValue editor in XML2XML mode. Code editor provides syntax highlighting. Validate XSLT on sample XML with Test Transformation button.
Step 5: Configuring XML→JSON Settings (If applicable)In XML2JSON mode, mark xmlToJsonUnwrapElement, xmlToJsonIgnoreNull, xmlToJsonIgnoreEmpty, xmlToJsonNumbersAsStrings, xmlToJsonUseNullForNil flags as needed. Add XPath expressions that should become JSON arrays to xmlToJsonArrayPathList field.
Step 6: Defining Condition (Optional)- Go to the Condition tab.
- Conditions determine when the policy will be active.

Examples:
- Environment-based: Header = X-Environment, Operator = Equals, Value = production
- API Key-based: Header = X-API-Key, Starts With = PROD-
- Endpoint-based: Path = /api/admin/*
If no condition is defined, the policy is always active

For details, see: Conditions
Step 7: Error Message Customization (Optional)- Go to the Error Message Customization tab.
- Customize the message to be returned when access is denied.

Default:
{ "statusCode": 403, "message": "[Default error message]" }

Custom:
{ "statusCode": 403, "errorCode": "[CUSTOM_ERROR_CODE]", "message": "[Custom message]" }
Step 8: Saving- Click the [Save] button at the top right.

Checklist: Unique name. Required fields filled. At least one XSLT or XML→JSON configuration exists

Result:
- Policy is added to the list.
- Can be connected to APIs.
- If global policy, automatically applied.
For the description of Conditions and Error Message Customization panels, you can review the Conditions and Error Message Customization sections on the What is Policy? page.

Deleting the Policy

For the deletion steps of this policy and the operations to be applied while in use, you can refer to the Removing Policy from Flow section on the Policy Management page.

Exporting/Importing the Policy

For the export and import steps of this policy, you can refer to the Export/Import page.

Connecting the Policy to API

For the process of how this policy will be connected to APIs, you can refer to the Connecting Policy to API section on the Policy Management page.

Advanced Features

FeatureDescription and Steps
Dynamic XSLT Distribution- Update XSLT template developed in editor.
- Validate with sample XML in test panel before saving.
- Distribute to all connected API Proxy endpoints by deploying.
JSON Output Shaping- Mark necessary flags when XML2JSON mode is active.
- Define XPaths that will become arrays with xmlToJsonArrayPathList.
- Confirm that options are correctly applied in View screen.
Global-Local Synchronization- Create API-based copy by localizing global policy.
- Apply package-based changes in local copy.
- Use Export/Import to return to global policy when needed.

Best Practices

Things to Do and Best Practices

CategoryDescription / Recommendations
XSLT ManagementBad: Copying production XSLT directly.
Good: Trying changes on test policy.
Best: Storing in version control and distributing with import/export.
JSON ConfigurationsBad: Leaving all flags as default.
Good: Ignoring unnecessary null values.
Best: Documenting client needs and regularly reviewing array path list.
Condition DesignBad: Applying to all traffic without defining condition.
Good: Making environment-based distinction.
Best: Using minimum-scoped condition definitions with endpoint + header combinations.
Error MessagesBad: Not changing default message.
Good: Giving understandable message to client.
Best: Informing support teams with standardized error codes.
Deploy ProcessesBad: Publishing directly to live.
Good: Importing and validating in test environment.
Best: Creating bulk deploy plan through Policy Groups.

Security Best Practices

Security AreaDescription / Warnings
Content ValidationFaulty XSLT may cause sensitive data leakage. Test before saving.
AuthorizationApply role-based authorization for edit and deploy operations, prevent unauthorized changes.
Error Message SanitizationDo not share internal system details in error messages in production, use general descriptions.
Export/Import SecurityStore ZIP files only in trusted repositories, encrypt before sharing.
Version ManagementPreserve export archives to return to old versions in XSLT changes, verify integrity.

Things to Avoid

CategoryDescription / Warnings
Uncontrolled XSLTWhy avoid: Creates performance and security risks.
Alternative: Apply limits and validations in test tool.
General ConditionsWhy avoid: Transforms all unnecessary traffic, causes delay.
Alternative: Define targeted conditions with Query Builder.
Undocumented SettingsWhy avoid: Effect of JSON flags cannot be tracked.
Alternative: Note every change made in policy description.
Uncontrolled Export SharingWhy avoid: Unauthorized persons may copy policy.
Alternative: Use encrypted channel and access records before sharing.

Performance Tips

CriterionRecommendation / Impact
XSLT ComplexityRecommendation: Make templates modular.
Impact: Transformation time decreases.
Condition FiltersRecommendation: Limit transformation to only necessary endpoints.
Impact: Gateway CPU usage decreases.
XML SizeRecommendation: Write streaming-supported XSLT rules for large XMLs.
Impact: Memory consumption is balanced.
JSON FlagsRecommendation: Close unnecessary flags.
Impact: Payload size after transformation remains under control.
Array Path OptimizationRecommendation: Keep XPath expressions minimal.
Impact: XML→JSON transformation time shortens.

Frequently Asked Questions (FAQ)

CategoryQuestionAnswer
GeneralCan I quickly switch between XML2XML and XML2JSON modes?Transformation type can be changed with single click from editor, new mode becomes effective immediately when saved.
GeneralHow do I share the policy with multiple API Proxies?You can configure the policy globally and assign to relevant API Proxies through Policy Group.
TechnicalWhat should I do if I get validation error when saving XSLT?Review error message in editor, repeat error with sample XML in Test Transformation window and save again after fixing.
TechnicalWhat happens if numbers are not converted to string in XML2JSON transformation?By default, numbers remain numeric in JSON; if client expects string, you should open xmlToJsonNumbersAsStrings flag.
UsageHow can I limit transformation conditions?You can create header, path or method-based rules in Condition tab; transformation does not run when condition is not met.
UsageWhat should I pay attention to when transferring policy export file to another project?Import without corrupting ZIP format, system warns if name conflict exists; import with new name if necessary.