Web Services

In a connected world, a ticket system needs to be able to react to requests from other systems and also to send requests or information to other systems:

  • CRM systems

  • Project management systems

  • Documentation management systems

  • and many more

The ticket system must be reachable by other services without manual intervention by an agent.

OTRS supports this requirement by the Generic Interface. It empowers the administrator to create a web service for a specific task without scripting language knowledge. OTRS reacts on incoming REST or SOAP requests and create objects or provides object data to other systems transparently.

A web service is a communication method between two systems, in our case OTRS and a remote system. In its configuration, the operation or invoker determine the direction of communication, and the mapping and transport take care of how the data is received and interpreted.

In its configuration it can be defined what actions the web service can perform internally (operation), what actions the OTRS request can perform remote system (invokers), how data is converted from one system to the other (mapping), and over which protocol the communication will take place (transport).

The generic interface is the framework that makes it possible to create web services for OTRS in a predefined way, using already made building blocks that are independent from each other and interchangeable.

Generic Interface

The generic interface consists of a multiple layer framework that lets OTRS communicate with other systems via a web service. This communication could be bi-directional:

  • OTRS as provider: OTRS acts as a server listening to requests from the external system, processing the information, performing the requested action, and answering the request.

  • OTRS as requester: OTRS acts as a client collecting information, sending the request to the remote system, and waiting for the response.

Generic Interface Layers

The generic interface is build based on a layer model, to be flexible and easy to customize.

A layer is a set of files, which control how the generic interface performs different parts of a web service. Using the right configuration, one can build different web services for different external systems without creating new modules.

Note

If the remote system does not support the current bundled modules of the generic interface, special modules need to be developed for that specific web service.

Generic Interface Layers

Generic Interface Layers

Network Transport

This layer is responsible for the correct communication with the remote system. It receives requests and generates responses when acting as provider, and generates requests and receives responses when acting as requester.

Requester communication could be initiated during an event triggered by a generic interface module or any other OTRS module. This event is caught by the event handler and depending on the configuration the event will be processed directly by the requester object or delegated to the scheduler (a separated daemon designed to process tasks asynchronously).

Data Mapping

This layer is responsible for translating data structures between OTRS and the remote system (data internal and data external layers). Usually remote systems have different data structures than OTRS (including different values and names for those values), and here resides the importance of the layer to change the received information into something that OTRS can understand and on the opposite way send the information to each remote system using their data dictionaries.

Example: Priority (OTRS) might be called Prio in a remote system and it could be that value 1 very low (OTRS) should be mapped to Information in the remote system.

Controller

Controllers are collections of similar operations or invokers. For example, a ticket controller might contain several standard ticket operations. Custom controllers can be implemented, for example a TicketExternalCompany controller which may contain similar functions as the standard ticket controller, but with a different data interface, or function names (to adapt to the remote system function names) or complete different code.

One application for generic interface could be to synchronize information with one remote system that only can talk with another remote system of the same kind. In this case new controllers needs to be developed and the operations and invokers has to emulate the remote system behavior in such way that the interface that OTRS exposes is similar to the interface of the remote system.

Operation (OTRS as a provider)

An operation is a single action that can be performed within OTRS. All operations have the same programming interface, they receive the data into one specific parameter, and return a data structure with a success status, potential error message and returning data.

Normally operations uses the already mapped data (internal) to call core modules and perform actions in OTRS like: create a ticket, update a user, invalidate a queue, send a notification, etc. An operation has full access to the OTRS API to perform the action.

Invoker (OTRS as a requester)

An invoker is an action that OTRS performs against a remote system. Invokers use the OTRS core modules to process and collect the needed information to create the request. When the information is ready it has to be mapped to the remote system format in order to be sent to the remote system, that will process the information, execute the action and send the response back, to either process the success or handle errors.

Generic Interface Communication Flow

The generic interface has a defined flow to perform actions as a provider and as a requester. These flows are described below:

OTRS as Provider

Remote Request:

  1. HTTP request

    • OTRS receives HTTP request and passes it through the layers.

    • The provider module is in charge to execute and control these actions.

  2. Network transport

    • The network transport module decodes the data payload and separates the operation name from the rest of the data.

    • The operation name and the operation data are returned to the provider.

  3. Data external

    • Data as sent from the remote system (this is not a module based layer).

  4. Mapping

    • The data is transformed from the external system format to the OTRS internal format as specified in the mapping configuration for this operation (mapping for incoming request data).

    • The already transformed data is returned to the provider.

  5. Data internal

    • Data as transformed and prepared to be passed to the operation (This is not a module based layer).

  6. Operation

    • Receives and validates data.

    • Performs user access control.

    • Executes the action.

OTRS Response:

  1. Operation

    • Returns result data to the provider.

  2. Data internal

    • Data as returned from operation.

  3. Mapping

    • The data is transformed back to the remote system format as specified in the mapping configuration (mapping for outgoing response data).

    • The already transformed data is returned to the provider.

  4. Data external

    • Data as transformed and prepared to be passed to network transport as response.

  5. Network transport

    • Receives the data already in the remote system format.

    • Constructs a valid response for this network transport type.

  6. HTTP response

    • The response is sent back to the web service client.

    • In the case of an error, an error response is sent to the remote system (e.g. SOAP fault, HTTP error, etc).

OTRS as Requester

OTRS Request:

  1. Event trigger handler

    • Based on the web service configuration determines if the request will be synchronous or asynchronous.

      • Synchronous

        • A direct call to the requester is made in order to create a new request and to pass it through the layers.

      • Asynchronous

        • Create a new generic interface (requester) task for the OTRS daemon (by delegating the request execution to the scheduler daemon, the user experience could be highly improved, otherwise all the time needed to prepare the request and the remote execution will be added to the OTRS events that trigger those requests).

        • In its next cycle the OTRS daemon process reads the new task and creates a call to the requester that will create a new request and then passes it through the layers.

  2. Invoker

    • Receives data from the event.

    • Validates received data (if needed).

    • Call core modules to complement the data (if needed).

    • Return the request data structure or send a stop communication signal to the requester, to gracefully cancel the request.

  3. Data internal

    • Data as passed from the invoker (this is not a module based layer).

  4. Mapping

    • The data is transformed to the remote system format as specified in the mapping configuration (mapping for outgoing response data).

    • The already transformed data is returned to the requester.

  5. Data external

    • Data as transformed and prepared for sending to the remote system.

  6. Network transport

    • Receives the remote operation name and the data already transformed to the remote system format from the requester.

    • Constructs a valid request for the network transport.

    • Sends the request to the remote system and waits for the response.

Remote Response:

  1. Network transport

    • Receives the response and decodes the data payload.

    • Returns the data to the requester.

  2. Data external

    • Data as received from the remote system.

  3. Mapping

    • The data is transformed from the external system format to the OTRS internal format as specified in the mapping configuration for this operation (mapping for incoming response data).

    • The already transformed data is returned to the requester.

  4. Data internal

    • Data as transformed and ready to be passed back to the requester.

  5. Invoker

    • Receives return data.

    • Handles the data as needed specifically by each invoker (included error handling if any).

    • Return the Invoker result and data to the Requester.

  6. Event handler or OTRS daemon

    • Receives the data from the requester. In the case of the OTRS daemon this data might contain information to create a task in the future.

Manage Web Services

A web service is a communication method between two systems, in our case OTRS and a remote system.

The heart of the web service is its configuration, where it is defined what actions the web service can perform internally (operation), what actions the OTRS request can perform remote system (invokers), how data is converted from one system to the other (mapping), and over which protocol the communication will take place (transport).

The generic interface is the framework that makes it possible to create web services for OTRS in a predefined way, using already made building blocks that are independent from each other and interchangeable.

Use this screen to manage web services in the system. A fresh OTRS installation contains no web service by default. The web service management screen is available in the Web Services module of the Processes & Automation group.

Web Service Management Screen

Web Service Management Screen

To create a web service:

  1. Click on the Add Web Service button in the left sidebar.

  2. Fill in the required fields.

  3. Click on the Save button.

Create New Web Service Screen

Create New Web Service Screen

To edit a web service:

  1. Click on a web service in the list of web services.

  2. Modify the fields.

  3. Click on the Save or Save and finish button.

Edit Web Service Screen

Edit Web Service Screen

To delete a web service:

  1. Click on a web service in the list of web services.

  2. Click on the Delete Web Service button in the left sidebar.

  3. Click on the Delete button in the confirmation dialog.

Delete Web Service Screen

Delete Web Service Screen

To clone a web service:

  1. Click on a web service in the list of web services.

  2. Click on the Clone Web Service button in the left sidebar.

  3. Enter a new name for the web service.

Clone Web Service Screen

Clone Web Service Screen

To export a web service:

  1. Click on a web service in the list of web services.

  2. Click on the Export Web Service button in the left sidebar.

  3. Choose a location in your computer to save the Export_ACL.yml file.

Warning

All stored passwords in the web service configuration will be exported in plain text format.

To see the configuration history of a web service:

  1. Click on a web service in the list of web services.

  2. Click on the Configuration History button in the left sidebar.

Web Service Configuration History Screen

Web Service Configuration History Screen

To use the debugger for a web service:

  1. Click on a web service in the list of web services.

  2. Click on the Debugger button in the left sidebar.

Web Service Debugger Screen

Web Service Debugger Screen

To import a web service:

  1. Click on the Add Web Service button in the left sidebar.

  2. Click on the Import Web Service button in the left sidebar.

  3. Click on the Browse… button in the dialog.

  4. Select a previously exported .yml file.

  5. Add a name for the imported web service (optional). Otherwise the name will be taken from the configuration file name.

  6. Click on the Import button.

Ready2Adopt Web Services

Not only do you use a single instance of OTRS, but you may also use additional OTRS installations and other tools. This can make accessing data inconvenient.

Several examples of predefined web services created by experts are included.

  • AIServiceDescription to update service descriptions automatically by analyzing past support.

  • AIServiceUpdate to synchronize service descriptions automatically between framework and AI.

  • AITicketServiceClassification to recommend the most relevant service for a ticket by analyzing its communication and matching it with available service options.

  • AITicketSummary to produce AI-driven summaries of ticket content and append them as notes.

  • BaramundiInventoryConnector to synchronize configuration items between OTRS and a remote Baramundi server.

  • BugzillaConnector to create or update bugs on a remote Bugzilla server.

  • EVReachConnector to synchronize items between OTRS and a remote EV Reach server.

  • FileWaveConnector to synchronize devices between OTRS and a remote FileWave server.

  • JIRAConnector to create or update issues on a remote JIRA server.

  • OTRSConnector to create or update tickets on a remote OTRS server.

  • SIGNL4 to integrate SIGNL4 with OTRS, see SIGNL4 documentation for more information.

To import a Ready2Adopt web service:

  1. Click on the Add Web Service button in the left sidebar.

  2. Select a web service from the Ready2Adopt Web Services widget in the left sidebar.

  3. Click on the Import Ready2Adopt web service button.

  4. Click on the imported web service in the list of web services.

  5. Click on the Configure button next to the Network transport field in the OTRS as requester widget and add the Endpoint and/or the credentials for the remote server.

  6. In the edit web service screen, click on each invoker in the Invokers section and review all settings. The XSLT mappings may contain placeholder values that need to be changed.

  7. Click on the Save or Save and finish button.

During the import process, the system takes care of creating the needed dynamic fields and/or any needed updates to the system configuration.

Note

These web services may depend on other modules only available with certain contract levels. There will be a notification with further details when importing.

Web Service Settings

The web service configuration needs to be saved on each level. This means that if a setting is changed, links to other, deeper parts of the configuration will be disabled forcing you to save the current configuration level. After saving the disabled links will be re-enabled again allowing you to continue with the configuration.

The following settings are available when adding or editing this resource. The fields marked with an asterisk are mandatory.

General Web Service Settings

Web Service Settings - General

Web Service Settings – General

The following settings are available when adding or editing this resource. The fields marked with an asterisk are mandatory.

Name *

The name of this resource. Any type of characters can be entered to this field including uppercase letters and spaces. The name will be displayed in the overview table.

Description

Like comment, but longer text can be added here.

Remote system

This field can be used to add a description for the remote system.

Debug threshold

The default value is Debug. When configured in this manner all communication logs are registered in the database. Each subsequent debug threshold value is more restrictive and discards communication logs of lower order than the one set in the system.

Debug threshold levels (from lower to upper):

  • Debug

  • Info

  • Notice

  • Error

Validity

Set the validity of this resource. Each resource can be used in OTRS only, if this field is set to valid. Setting this field to invalid or invalid-temporarily will disable the use of the resource.

Provider Web Service Settings

Web Service Settings - OTRS as Provider

Web Service Settings – OTRS as Provider

The following settings are available when adding or editing this resource. The fields marked with an asterisk are mandatory.

Network transport

Select which network transport would you like to use with the web service. Possible values are HTTP::REST and HTTP::SOAP.

Note

After selecting the transport method, you have to save the configuration with clicking on the Save button. A Configuration button will be displayed next to this field.

Configuration

The Configure button is visible only, after a network transport was selected and saved. See the configuration for OTRS as Provider – HTTP::REST and OTRS as Provider – HTTP::SOAP below.

Add Operation

This option is visible only, after a network transport was selected and saved. Selecting an operation will open a new screen for its configuration.

Web Service Settings - OTRS as Provider - Operation

Web Service Settings – OTRS as Provider – Operation

Each operation requires a valid agent user login name and a password or a session ID. This session ID can be obtained using the AccessToken::Create operation that is available by default in OTRS.

ConfigItem::ConfigItemCreate

This operation is used to create a configuration item.

ConfigItem::ConfigItemDelete

This operation is used to delete a configuration item.

ConfigItem::ConfigItemGet

This operation is used to get a configuration item.

ConfigItem::ConfigItemSearch

This operation is used to search a configuration item.

ConfigItem::ConfigItemUpdate

This operation is used to update a configuration item.

Link::LinkAdd

This operation is used to create a link between two objects.

Link::LinkDelete

This operation is used to remove a link between two objects.

Link::LinkDeleteAll

This operation is used to remove all link of an object.

Link::LinkList

This operation shows all links of an object, optionally restricted by another object, link type and link direction.

Link::PossibleLinkList

This operation shows all possible link types between objects that are registered in the OTRS system.

Link::PossibleObjectsList

This operation shows all objects that can be used for linking.

Link::PossibleTypesList

This operation shows all possible link types between two given objects.

See also

Check the API references in Process Management chapter for more information.

See also

For more information please take a look at the WSDL file located in development/webservices/GenericConfigItemConnectorSOAP.wsdl of your instance.

The following examples give a quick look about how to use the API for basic actions.

  1. Create configuration item

    • URL: /api/agent/config-item/create

    • Method: POST

    • Payload:

      {
          "ConfigItem": {
              "Class": "Computer",
              "Name": "test name for new config item",
              "DeplState": "Production",
              "InciState": "Operational",
              "CIXMLData": {
                  "Seriennummer": "SNR1"
                  "NIC": {
                       "NIC": "test",
                       "IPoverDHCP": "Yes"
                  }
              }
          }
      }
      
  2. Update configuration item

    • URL: /api/agent/config-item/4/update where 4 is the ID of the configuration item to be updated

    • Method: POST

    • Payload:

      {
          "ConfigItemID": "4",
          "ConfigItem": {
              "Class": "Computer",
              "Name": "test name for new config item",
              "DeplState": "Production",
              "InciState": "Operational",
              "CIXMLData": {
                  "Seriennummer": "SNR2"
                  "NIC": {
                       "NIC": "test",
                       "IPoverDHCP": "Yes"
                  }
              }
          }
      }
      

    Note

    The Class is required to be transmitted but will not affect the configuration item when updating. If you update a configuration item in the class Location and transmit the class Computer the configuration item will stay in the class Location.

  3. Get configuration item

    • URL: /api/agent/config-item/4 where 4 is the ID of the configuration item to be fetched

    • Method: GET

  4. List configuration items

    • URL: /api/agent/config-item/list

    • Method: POST

There are more detailed explanation and usage examples in the Link Object Connector section of the Tutorials chapter.

Due to the nature of the generic interface and the operations included in OTRS an external software is needed to send the requests to the OTRS system.

For testing we recommend the use of:

  • OTRS Perl SOAP Requester script: some of the variables in this script such as URL, NameSpace and Operation will need to be changed to match the current web service, the operation to be executed and the data to be sent.

  • SoapUI by SMARTBEAR: this is an open source software designed to test web services using SOAP messages.

OTRS as Provider – HTTP::REST

The configuration might be a bit more complicated, as it grows dynamically for each configured operation by adding route mapping for each operation and valid request methods for each operation to the default transport settings.

Web Service Settings - OTRS as Provider - HTTP\:\:REST

Web Service Settings – OTRS as Provider – HTTP::REST

The following settings are available when adding or editing this resource. The fields marked with an asterisk are mandatory.

Route mapping for Operation ‘<OperationName>’ *

Define the route that should get mapped to this operation. Variables marked by a : will get mapped to the entered name and passed along with the others to the mapping (e.g. /Ticket/:TicketID).

In this setting a resource path is set. This path must be defined according to the needs of the web service considering that the path in conjunction with the HTTP request method determines the generic interface operation to be executed.

Path can contain variables in the form of :<VariableName>. Each path string that fits on the position of the variable name will be added to the request payload using the variable name defined in this setting. Examples:

Valid requests for /Resource route mapping:

https://localhost/otrs/nph-genericinterface.pl/Webservice/Test/Resource
https://localhost/otrs/nph-genericinterface.pl/Webservice/Test/Resource?Param1=One

Invalid requests for /Resource route mapping:

https://localhost/otrs/nph-genericinterface.pl/Webservice/Test/Resource/
https://localhost/otrs/nph-genericinterface.pl/Webservice/Test/Resource/OtherResource
https://localhost/otrs/nph-genericinterface.pl/Webservice/Test/Resource/OtherResource?Param1=One

Valid requests for /Resource/:ID route mapping:

https://localhost/otrs/nph-genericinterface.pl/Webservice/Test/Resource/1
https://localhost/otrs/nph-genericinterface.pl/Webservice/Test/Resource/1?Param1=One

In both cases ID = 1 will be sent to the operation as part of the payload. In the second case also Param1 = One will be added, depending on the HTTP request method other parameters will be added if they come as a JSON string in the request header.

Invalid requests for /Resource/:ID route mapping:

https://localhost/otrs/nph-genericinterface.pl/Webservice/Test/Resource
https://localhost/otrs/nph-genericinterface.pl/Webservice/Test/Resource?Param1=One

Valid requests for /Resource/OtherResource/:ID/:Color route mapping:

https://localhost/otrs/nph-genericinterface.pl/Webservice/Test/Resource/OtherResource/1/Red
https://localhost/otrs/nph-genericinterface.pl/Webservice/Test/Resource/OtherReosurce/123/Blue?Param1=One

In the first example ID = 1 and Color = Red, while in the second ID = 123 and Color = Blue.

Invalid requests for /Resource/OtherResource/:ID/:Color route mapping:

https://localhost/otrs/nph-genericinterface.pl/Webservice/Test/Resource/1
https://localhost/otrs/nph-genericinterface.pl/Webservice/Test/Resource/OtherResource/1
https://localhost/otrs/nph-genericinterface.pl/Webservice/Test/Resource/OtherResource/1?Param1=One

In the first example the part of the path /OtherResource is missing as well as the :Color variable. In the second example just the :Color variable is missing.

Valid request methods for Operation ‘<OperationName>’

Limit this operation to specific request methods. If no method is selected all requests will be accepted.

The HTTP request methods to determine the operation to use together with the route mapping, possible options: CONNECT, DELETE, GET, HEAD, OPTIONS, PATCH, POST, PUT and TRACE.

Totally different operations can share exactly the same mapping path, but the request method must be unique for each operation, in order to determine correctly the operation to use on each request.

Maximum message length *

Specifies the maximum size (in bytes) for REST messages that OTRS will process.

Send Keep-Alive *

This configuration defines if incoming connections should get closed or kept alive.

Additional response headers (all operations)

Optionally, you may want to define additional response headers for all operations. These may be used to add static header values to every response. Just click on the Add header button and fill both header and value fields. There is no limit in number of additional header lines.

Header value variables marked by a : will get replaced by the corresponding data value (e.g. :TicketID becomes 1).

Additional response headers (operation specific)

These headers will be set in responses for the selected operation. The purpose of this setting is the same as above.

Header value variables marked by a : will get replaced by the corresponding data value (e.g. :TicketID becomes 1).

OTRS as Provider – HTTP::SOAP

It is quite simple to configure the HTTP::SOAP protocol as provider.

Web Service Settings - OTRS as Provider - HTTP\:\:SOAP

Web Service Settings – OTRS as Provider – HTTP::SOAP

The following settings are available when adding or editing this resource. The fields marked with an asterisk are mandatory.

Check SOAPAction *

Set to Yes in order to check the received SOAPAction header (if not empty). Set to No in order to ignore the received SOAPAction header.

SOAPAction scheme *

Select how SOAPAction should be constructed. Some web services send a specific construction.

SOAPAction separator *

Character to use as separator between name space and SOAP operation. Usually .Net web services use / as separator.

Namespace *

URI to give SOAP methods a context, reducing ambiguities.

Request name scheme *

Select how SOAP request function wrapper should be constructed. FunctionName is used as example for actual invoker or operation name. FreeText is used as example for actual configured value.

Response name scheme *

Select how SOAP response function wrapper should be constructed. FunctionName is used as example for actual invoker or operation name. FreeText is used as example for actual configured value.

Maximum message length *

Specifies the maximum size (in bytes) for SOAP messages that OTRS will process.

Additional response headers (all operations)

Optionally, you may want to define additional response headers for all operations. These may be used to add static header values to every response. Just click on the Add header button and fill both header and value fields. There is no limit in number of additional header lines.

Header value variables marked by a : will get replaced by the corresponding data value (e.g. :TicketID becomes 1).

Additional response headers (operation specific)

These headers will be set in responses for the selected operation. The purpose of this setting is the same as above.

Header value variables marked by a : will get replaced by the corresponding data value (e.g. :TicketID becomes 1).

Additional response SOAP namespaces (all operations)

These namespaces will be used in every response.

Additional response SOAP namespaces (operation specific)

These namespaces will be used in responses for this specific operation.

Note

Some headers are blocked for safety purposes. If needed, the list of blocked headers can be changed in the following system configuration using the settings:

  • GenericInterface::Invoker::OutboundHeaderBlacklist

  • GenericInterface::Operation::OutboundHeaderBlacklist

Sort options

Outbound sort order for XML fields (structure starting below function name wrapper) – see documentation for SOAP transport.

Web Service Operation

The actions that can be performed when you are using OTRS as a provider are called operations. Each operation belongs to a controller. Controllers are collections of operations or invokers, normally operations from the same controller need similar settings and share the same configuration dialog. But each operation can have independent configuration dialogs if needed.

Add Web Service Operation Screen

Add Web Service Operation Screen

The following settings are available when adding or editing this resource. The fields marked with an asterisk are mandatory.

Name *

The name of this resource. Any type of characters can be entered to this field including uppercase letters and spaces. The name will be displayed in the overview table.

Description

Add additional information to this resource. It is recommended to always fill this field as a description of the resource with a full sentence for better clarity, because the description will be also displayed in the overview table.

Operation backend

This OTRS operation back end module will be called internally to process the request, generating data for the response.

The operation back end is pre-populated and cannot be edited. You will see this parameter when you choose the operation on the web service edit screen. The field is only informative.

Mapping for incoming request data

The request data will be processed by this mapping, to transform it to the kind of data OTRS expects.

Mapping for outgoing response data

The response data will be processed by this mapping, to transform it to the kind of data the remote system expects.

Include Ticket Data

Whether to include ticket data in response or not.

Mappings are fields that normally appear on every operation, but other special fields can appear in non default configuration dialogs to fulfill specific needs of the operation.

Normally there are two mapping configuration sections for each operation, one for the incoming data and another one for the outgoing data. You can choose different mapping types (back ends) for each mapping direction, since their configuration is independent from each other and also independent from the operation back end. The normal and most common practice is that the operation uses the same mapping type in both cases (with inverted configuration). The complete mapping configuration is done in a separate screen which depends on the mapping type.

In the left part of the screen on the action column you have the options to go back to web service (discarding all changes since the last save) and delete. If you click on the last one, a dialog will open and ask you if you like to remove the operation. Click on the Delete button to confirm the removal of the operation and its configuration or click on the Cancel button to close the delete dialog.

Requester Web Service Settings

The network transport configuration for the requester is similar to the configuration for the provider.

Web Service Settings - OTRS as Requester

Web Service Settings – OTRS as Requester

The following settings are available when adding or editing this resource. The fields marked with an asterisk are mandatory.

Network transport

Select which network transport would you like to use with the web service. Possible values are HTTP::REST and HTTP::SOAP.

Note

After selecting the transport method, you have to save the configuration with clicking on the Save button. A Configuration button will be displayed next to this field.

Configuration

The Configure button is visible only, after a network transport was selected and saved. See the configuration for OTRS as Requester – HTTP::REST and OTRS as Requester – HTTP::SOAP below.

It is possible to use both object and array format as a JSON response of the remote system. However, in the case it is an array, system stores it as an object internally, where ArrayData is used as a key and a value is an array. Because of that, responded JSON array can be mapped efficiently, but has to be considered as an object described above (key is ArrayData, but * can also be used as wildcard).

Add error handling module

This option is visible only, after a network transport was selected and saved. Selecting an error handling module will open a new screen for its configuration.

Web Service Settings - OTRS as Provider - Error Handling Module

Web Service Settings – OTRS as Provider – Error Handling Module

The following settings are available when adding or editing this resource. The fields marked with an asterisk are mandatory.

Name *

The name of this resource. Any type of characters can be entered to this field including uppercase letters and spaces. The name will be displayed in the overview table.

Description

Add additional information to this resource. It is recommended to always fill this field as a description of the resource with a full sentence for better clarity, because the description will be also displayed in the overview table.

Invoker filter

Only execute error handling module for selected invokers.

Error message content filter

Enter a regular expression to restrict which error messages should cause error handling module execution. Error message subject and data (as seen in the debugger error entry) will be considered for a match.

Example: Enter ^.*401 Unauthorized.*$ to handle only authentication related errors.

Error stage filter

Only execute error handling module on errors that occur during specific processing stages.

Example: Handle only errors where mapping for outgoing data could not be applied.

Error code

An error identifier for this error handling module. This identifier will be available in XSLT mapping and shown in debugger output.

Error message

An error explanation for this error handling module. This message will be available in XSLT mapping and shown in debugger output.

Stop after match

Defines if processing should be stopped after module was executed, skipping all remaining modules or only those of the same back end. Default behavior is to resume, processing the next module.

Add Invoker

With this option you can add invokers. Selecting an invoker from the drop-down list will open a new settings window.

Available Invokers

Here is the list of invokers which can be selected in Add Invoker drop-down list.

Generic Operations Invoker

The Generic::Operations invoker allows you to define Stages where each mapping defined as stage are executed next to each other. The output of one stage will be the input of the next stage.

Web Service Settings - Generic\:\:Operations Invoker

Web Service Settings – Generic::Operations Invoker

The following settings are available when adding or editing this resource. The fields marked with an asterisk are mandatory.

Name *

The name of this resource. Any type of characters can be entered to this field including uppercase letters and spaces. The name will be displayed in the overview table.

Description

Add additional information to this resource. It is recommended to always fill this field as a description of the resource with a full sentence for better clarity, because the description will be also displayed in the overview table.

Operation backend

This OTRS operation back end module will be called internally to process the request, generating data for the response.

The operation back end is pre-populated and cannot be edited. You will see this parameter when you choose the operation on the web service edit screen. The field is only informative.

Mapping for outgoing response data

The response data will be processed by this mapping, to transform it to the kind of data the remote system expects.

Mapping for incoming request data

The request data will be processed by this mapping, to transform it to the kind of data OTRS expects.

User for operations *

The operations will be processed by using this user.

Stages

Here you can add stages which will be processed next to each other. It is possible to add as many stages as needed by the Add stage button.

Click on the Save button to have a Configure button next to each stage. Here you can add XSLT stylesheet for each stage.

Event Triggers

This invoker will be triggered by the configured events.

Add Event Trigger

To add a new event select the event object and event name and click on the + button.

Configuration Item Invoker

The ITSM::ConfigItem invoker provides the functionality to request a list of configuration items from a remote system with the generic interface. A complete mapping between the name of remote value keys to the local configuration item class definitions is possible. In order to give the possibility to define all class attributes in the mapping, an advanced mapping is provided.

For handling remote configuration items and links, an advanced mapping is provided with this feature. To use this functionality select the ITSMConfigItem in the mapping select box.

Invoker Details for ``ITSM::ConfigItem``

Invoker Details for ITSM::ConfigItem

One of those advanced mapping features are static values. These make it possible to define static values for defined keys, for example setting the configuration item class for each item. These entries can overwrite data send from the remote system.

Static Mapping for ``ITSM::ConfigItem``

Static Mapping for ITSM::ConfigItem

Another feature provided by the advanced mapping are transforming strings to list structures. For creating a list out of a string, a list separator can be defined, for example ;. The separator field takes a regular expressions which make a more complex separators like ;(?:\s+)? (a ; optionally followed by multiple white spaces) possible.

Key Mapping for ``ITSM::ConfigItem``

Key Mapping for ITSM::ConfigItem

It is possible to define where the index of the elements should take place in the configuration item structure. For this the placeholder ###INDEX### has to be placed in the key mapping. The configuration in the screenshot would store the separated IP address list into a new interface each. If no index is defined in the mapping, the index will increase the main attribute counter, like a suffix.

The configuration item Number attribute is used to make the logical connection between the remote data and the data stored in the OTRS database. To create and update configuration items with this invoker values for the following keys are required:

- Name
- Class
- Number
- DeploymentState
- IncidentState

The values for these keys (except Number) can be static or provided by the remote system.

Configuration Item Synchronization Invoker

The ITSM::ConfigItemSync invoker provides the functionality to synchronize configuration items between two OTRS instances using a special synchronization invoker. That invoker allows to define invokers for create, update and delete synchronizations, that gets called automatically if needed.

To synchronize configuration items between two systems, it is needed to add a web service with an invoker of type ITSM::ConfigItemSync. This invoker is the basic (search) invoker that is used to perform ITSM object searches on the remote system to determine configuration items to be modified.

It works with two steps on every sync action:

  1. At first depending on the change that was made in the local system (add, update or delete a configuration item) the invoker performs a related search on the remote system to determine, if it is needed to create, update or delete a remote configuration item.

  2. On the second step, a related invoker for create actions, update actions or delete actions is called, which executes the main changes on the remote system. Those invokers have to be created as well and needs to be of invoker type ITSM::ConfigItem to make sure the communication works properly.

See the enclosed overview of example invokers:

Invoker Overview

Invoker Overview

Within the search invoker configuration, the worker invokers to perform the changes needs to be configured separately for every action in the related drop-down menus.

If an invoker is not configured for the related action, it will be omitted. The configured invoker will be listed within every drop-down and can be selected easily for the different actions.

The different invokers needs to map their data. For this to work properly, it is recommend to use the mapping module ITSMConfigItem, which will be described through this documentation, but in fact it is also possible to use other types of mappings like XSLT if configured properly.

Search Invoker Details

Search Invoker Details

Since this structure calls remote systems, it is needed to configure at least the connection credentials to access the remote CMDB.

Search Invoker Mapping

Search Invoker Mapping

All other configurations can be set optional, but they are not needed for the basic feature to work.

To be sure the search invoker just listens on specific events, this functionality extends the possibilities of the Invoker event filter feature from OTRS, that can be used to add additional conditions to the event triggers, which are configured for the search invoker. One example could be, that just configuration items of ITSM class Computer gets synchronized to the remote system.

The configuration of the remote system, that gets synchronized does not need to be special but for it needs to provide at least an operation for the search executions and a separate operation for each sync action that needs to be performed.

Operation Overview

Operation Overview

Ticket Invoker

This feature adds the functionality of the invokers TicketCreate and TicketUpdate for web services.

In addition, the package follows HTTP redirect responses (HTTP code 301, 307 and 308) for outbound communication of HTTP::REST and HTTP::SOAP based web services.

Further the package allows to send empty body HTTP requests (POST, PUT, PATCH) for outbound communication of HTTP::REST based web services.

TicketCreate and TicketUpdate invoker returns the complete ticket and article data based on ticket ID and article ID of the triggered event.

Prepare the invocation of the configured remote web service. Event data:

my $Result = $InvokerObject->PrepareRequest(
    Data => {                                               # data payload
        TicketID => 123,
        ArticleID => 123,                                   # optional
    },
);

Invoker result:

{
    Data => {
        Ticket => {
            Title         => 'some ticket title',
            Queue         => 'some queue name',
            Lock          => 'some lock name',              # optional
            Type          => 'some type name',              # optional
            Service       => 'some service name',           # optional
            SLA           => 'some SLA name',               # optional
            State         => 'some state name',
            Priority      => 'some priority name',
            Owner         => 'some user login',             # optional
            Responsible   => 'some user login',             # optional
            CustomerUser  => 'some customer user login',
            PendingTime {       # optional
                Year   => 2011,
                Month  => 12
                Day    => 03,
                Hour   => 23,
                Minute => 05,
            },
        },
        Article => {
            SenderType       => 'some sender type name',    # optional
            AutoResponseType => 'some auto response type',  # optional
            From             => 'some from string',         # optional
            Subject          => 'some subject',
            Body             => 'some body'
            ContentType      => 'some content type',        # ContentType or MimeType and Charset is required
            MimeType         => 'some mime type',
            Charset          => 'some charset',
            TimeUnit         => 123,                        # optional
        },
        DynamicField => [                                   # optional
            {
                Name   => 'some name',
                Value  => 'Value',                          # value type depends on the dynamic field
            },
            # ...
        ],
         Attachment => [
            {
                Content     => 'content'                    # base64 encoded
                ContentType => 'some content type'
                Filename    => 'some fine name'
            },
            # ...
        ],
    },
};

Note

The invoker will return the newest article of the ticket if no article ID is given.

Note

The invoker will not return dynamic fields with undefined values, because the same named operations TicketCreate and TicketUpdate does not handle dynamic fields with undefined values.

Advanced Filtering for Outgoing Data

For outgoing data, it is possible to define what kind of ticket fields, article fields or dynamic fields the request should contain. Furthermore it is possible to filter by article type and article sender type.

The different filter options can be selected within every single invoker configuration and are listed in section Settings for outgoing request data.

In the left part of the screen on the action column you have the options to go back to web service (discarding all changes since the last save) and delete. If you click on the last one, a dialog will open and ask you if you like to remove the invoker. Click on the Delete button to confirm the removal of the invoker and its configuration or click on the Cancel button to close the delete dialog.

Add Web Service Invoker Screen

Add Web Service Invoker Screen

The following settings are available when adding or editing this resource. The fields marked with an asterisk are mandatory.

General Invoker Data

Name *

The name of this resource. Any type of characters can be entered to this field including uppercase letters and spaces. The name will be displayed in the overview table.

Description

Add additional information to this resource. It is recommended to always fill this field as a description of the resource with a full sentence for better clarity, because the comment will be also displayed in the overview table.

Invoker backend

This invoker back end module will be called to prepare the data to be sent to the remote system, and to process its response data. The field is read-only, it was selected in the previous screen.

Settings for Outgoing Request Data

Ticket fields

A multi-select menu containing the available ticket attributes (fields), that can be submitted to a remote system. Just the fields that are selected will be included in outgoing requests.

Article fields

A multi-select menu containing the available article attributes (fields), that can be submitted to a remote system. Just the fields that are selected will be included in outgoing requests.

Ticket dynamic fields

A multi-select menu containing the available ticket dynamic fields, that can be submitted to a remote system. Just the dynamic fields that are selected will be included in outgoing requests.

Article dynamic fields

A multi-select menu containing the available article dynamic fields, that can be submitted to a remote system. Just the dynamic fields that are selected will be included in outgoing requests.

Number of articles

A text field containing the maximum number of articles, that will be transmitted during an outgoing request. The articles will be selected from newest (latest) to oldest. If no number is given, just the latest article will be transmitted.

Communication channels

The outgoing request data will only consider articles of the selected communication channels. If left empty, articles created by all communication channels will be used.

Customer visibility

The outgoing request data will only consider articles created with the selected customer visibility.

Sender Types

The outgoing request data will only consider articles created by the selected sender types. If left empty, articles created by all sender types will be used.

Mapping

Normally there are two mapping configuration sections for each invoker, one for the incoming data and another one for the outgoing data. You can choose different mapping types (back ends) for each mapping direction, since their configuration is independent from each other and also independent from the invoker back end. The normal and most common practice is that the invoker uses the same mapping type in both cases, with inverted configuration. The complete mapping configuration is done in a separate screen, which depends on the mapping type.

Mapping for outgoing request data

The data from the invoker will be processed by this mapping, to transform it to the kind of data the remote system expects.

Mapping for incoming response data

The response data will be processed by this mapping, to transform it to the kind of data the invoker expects.

Settings for Incoming Response Data

It is possible to automatically save certain data of incoming responses to local dynamic fields. The different filter options can be selected within every single invoker configuration.

Remote Ticket ID dynamic field

A drop-down menu containing the available ticket dynamic fields in the system. If such a dynamic field is selected, the received ticket ID from the remote system will be used, to be saved within the selected dynamic field.

Ticket dynamic fields

A multi-select menu containing the available ticket dynamic fields in the system. All selected dynamic fields, that also available in the response data and containing values, will be saved to the local dynamic fields.

The dynamic field values of the response data will be used from the following data structure:

<Ticket>
    <DynamicField>..</DynamicField>
</Ticket>

and/or

<Ticket>
    <Article>
        <DynamicField>..</DynamicField>
    </Article>
</Ticket>

The system configuration option GenericInterface::Invoker::Settings::ResponseDynamicField was added as a fallback for the dynamic fields that should contain the result ticket ID of the related response data. It shall be used, if the configuration was not added via the invoker GUI and both configurations should not be used at the same time!

Event Triggers

Event triggers are events within OTRS such as TicketCreate, ArticleSend, etc. These can act as triggers to execute the invoker. Each invoker needs to have at least one event trigger registered, or the invoker will be useless, because it will never be called. Additionally a set of rules (conditions) for each event can be defined to have more control over the triggering of the events. These rules depend on the data of the object associated with the event. The asynchronous property of the event triggers define if the OTRS process will handle the invoker or if it will be delegated to the OTRS daemon.

Note

The OTRS daemon is a separate set of process that executes tasks in the background. Using this the OTRS process itself will not be affected if the remote system takes a long time to respond, if it is not available or if there are network problems. If you do not use the OTRS daemon using web services can make OTRS slow or non-responsive. Therefore it is highly recommend to use asynchronous event triggers as often as possible.

In order to access this section you have to save the current invoker by clicking on the Save button.

Event

This invoker will be triggered by the configured events.

Add Event Trigger

To add a new event select the event object and event name and click on the plus button. Asynchronous event triggers are handled by the OTRS daemon in background (recommended). Synchronous event triggers would be processed directly during the web request.

To add an event trigger:

  1. Select the event family from the first list.

  2. Select the event name from the second list.

  3. Set the asynchronous property. If unchecked means that the event trigger will not be asynchronous.

  4. Click on the plus button. A new event trigger will be created and it will be listed on the invoker event triggers list.

From the event triggers list each events shows if it contains conditions or not. The edit button next to the condition property allows to add or edit the current conditions of the event.

To delete an event trigger, simply locate the event trigger to be deleted in the event triggers list and click on the trash icon at the end of the row. This will open a dialog that asks you if you are sure to delete the event trigger. Click on the Delete button to remove the event trigger from the list, or click on the Cancel button to close the dialog.

Sometimes defining an event to trigger an invoker could result in many unnecessary or wrong request to a remote server. Event conditions could be set to restrict the triggering of the invoker in such cases.

Add Web Service Invoker Event Screen

Add Web Service Invoker Event Screen

To access the event settings screen where the conditions can be defined is necessary to be in the invoker screen and from there click on the edit icon next to the condition status on the event where this condition should take effect.

Within the event settings screen in the action bar there is a button to go back to the invoker screen as well as a button to remove all the event conditions. By default the screen is pre-populated with the first condition. Update the type of linking between conditions if more than one condition is planned, then change the type of linking from Condition 1 if more than one field is planned. Both linking fields accept and, or or xor as values.

Fill the field name, set the matching type (String for exact match, Regexp for regular expression or Validation Module) and set the value to match (in case of validation module the full class name like Kernel::GenericInterface::Event::Validation::ValidateDemo).

To add more fields to the condition, click on the plus button in the fields header. To remove a field, click on the minus button in the field row. It is necessary to keep at least one field per condition.

To add more conditions click on the button below the last condition box. To remove a condition, click on the minus button in the condition header. It is necessary to keep at least one condition in the set. To remove all conditions use the button in the sidebar.

OTRS as Requester – HTTP::REST

In the case of HTTP::REST, this configuration also grows dynamically depending on the configured invokers. Authentication and SSL options are similar to the ones in HTTP::SOAP.

Web Service Settings - OTRS as Requester - HTTP\:\:REST

Web Service Settings – OTRS as Requester – HTTP::REST

The following settings are available when adding or editing this resource. The fields marked with an asterisk are mandatory.

Endpoint *

URI of the remote system to indicate specific location for accessing a web service.

Timeout *

Timeout value for requests.

Authentication

An optional authentication mechanism to access the remote system. Select an authentication mechanism from the list and additional fields will appear.

Credential *

Select a credential that has been added in the Credentials screen. Click on the Add credential button to open the credential management screen.

Certification Authority (CA) Certificate

The full path and name of the certification authority certificate file that validates SSL certificate.

Certification Authority (CA) Directory

The full path of the certification authority directory where the CA certificates are stored in the file system.

Use Proxy Options *

Show or hide proxy options to connect to the remote system.

Controller mapping for Invoker ‘<InvokerName>’ *

The controller that the invoker should send requests to.

Variables marked by a : will get replaced by the data value and passed along with the request (e.g. /Ticket/:TicketID?UserLogin=:UserLogin&Password=:Password).

Valid request command for Invoker ‘<InvokerName>’

A specific HTTP command to use for the requests with this invoker (optional).

Default command

The default HTTP command to use for the requests. Possible options: CONNECT, DELETE, GET, HEAD, OPTIONS, PATCH, POST, PUT and TRACE. If no command is selected, Default command is used.

Additional request headers (all invokers)

Optionally, you may want to define additional request headers for all invokers. These may be used to add static header values to every request. Just click on the Add header button and fill both header and value fields. There is no limit in number of additional header lines.

Header value variables marked by a : will get replaced by the corresponding data value (e.g. :TicketID becomes 1).

Additional request headers (invoker specific)

These headers will be set in requests for the selected invoker. The purpose of this setting is the same as above.

Header value variables marked by a : will get replaced by the corresponding data value (e.g. :TicketID becomes 1).

Note

Some headers are blocked for safety purposes. If needed, the list of blocked headers can be changed in the following system configuration using the settings:

  • GenericInterface::Invoker::OutboundHeaderBlacklist

  • GenericInterface::Operation::OutboundHeaderBlacklist

If at least two invokers are added the requester transport screen for HTTP::REST is extended with two fields.

Controller mapping for Invoker ‘<InvokerName>’ *

In this setting a resource path is set. This path must be defined according to the needs of the remote web service and following its definition.

Path can contain variables in the form of :<VariableName> for each variable name that matches the current data (to be sent), will be replaced by the corresponding data value. This matched variable names and values will be removed from the current data. Depending on the HTTP request command the remaining data could be sent as a JSON string in the request body or as query parameters within the URI.

Examples for data Var1 = One, Var2 = Two, Var3 = Three and Var4 = Four.

  • Controller mapping: /Resource, after replacements: /Resource, remaining data: Var1 = One, Var2 = Two, Var3 = Three and Var4 = Four

  • Controller mapping: /Resource/:Var1, after replacements: /Resource/One, remaining data: Var2 = Two, Var3 = Three and Var4 = Four

  • Controller mapping: /Resource/:Var1?Param1=:Var2&Var3=:Var3, after replacements: /Resource/One?Param1=Two&Var3=Three, remaining data: Var4 = Four

Valid request command for Invoker ‘<InvokerName>’

This determines the HTTP request method to use. Possible options: CONNECT, DELETE, GET, HEAD, OPTIONS, PATCH, POST, PUT and TRACE. If no command is selected, Default command is used.

OTRS as Requester – HTTP::SOAP

For the requester HTTP::SOAP network transport there are more fields to be set.

Web Service Settings - OTRS as Requester - HTTP\:\:SOAP

Web Service Settings – OTRS as Requester – HTTP::SOAP

The following settings are available when adding or editing this resource. The fields marked with an asterisk are mandatory.

Endpoint *

URI of the remote system to indicate specific location for accessing a web service.

Timeout *

Timeout value for requests.

Set SOAPAction *

Set to Yes in order to send a filled SOAPAction header. Set to No in order to send an empty SOAPAction header.

SOAPAction scheme *

Select how SOAPAction should be constructed. Some web services require a specific construction.

SOAPAction separator *

Character to use as separator between name space and SOAP operation. Usually .Net web services use / as separator.

Namespace *

URI to give SOAP methods a context, reducing ambiguities.

Request name scheme *

Select how SOAP request function wrapper should be constructed. FunctionName is used as example for actual invoker or operation name. FreeText is used as example for actual configured value.

Response name scheme *

Select how SOAP response function wrapper should be constructed. FunctionName is used as example for actual invoker or operation name. FreeText is used as example for actual configured value.

Encoding

The character encoding for the SOAP message contents.

Authentication

An optional authentication mechanism to access the remote system. Select an authentication mechanism from the list and additional fields will appear.

Credential *

Select a credential that has been added in the Credentials screen. Click on the Add credential button to open the credential management screen.

Certification Authority (CA) Certificate

The full path and name of the certification authority certificate file that validates SSL certificate.

Certification Authority (CA) Directory

The full path of the certification authority directory where the CA certificates are stored in the file system.

Use Proxy Options *

Show or hide proxy options to connect to the remote system.

Additional request headers (all invokers)

Optionally, you may want to define additional request headers for all invokers. These headers will be set in every request.

Header value variables marked by a : will get replaced by the corresponding data value (e.g. :TicketID becomes 1).

Additional request headers (invoker specific)

These headers will be set in requests for the selected invoker. The purpose of this setting is the same as above.

Header value variables marked by a : will get replaced by the corresponding data value (e.g. :TicketID becomes 1).

Additional request SOAP namespaces (all invokers)

These namespaces will be used in every request.

Additional request SOAP namespaces (invoker specific)

These namespaces will be used in requests for this specific invoker.

Note

Some headers are blocked for safety purposes. If needed, the list of blocked headers can be changed in the following system configuration using the settings:

  • GenericInterface::Invoker::OutboundHeaderBlacklist

  • GenericInterface::Operation::OutboundHeaderBlacklist

Sort options

Outbound sort order for XML fields (structure starting below function name wrapper) – see documentation for SOAP transport.

Web Service Mapping

There are cases where you need to transform the data from one format to another (map or change data structure), because normally a web service is used to interact with a remote system, that is highly probable that is not another OTRS system and/or could not understand the OTRS data structures and values. In these cases some or all values have to be changed, and sometimes even the names of the values (keys) or even the complete structure, in order to match with the expected data on the other end. To accomplish this task the generic interface mapping layer exists.

Simple Web Service Mapping

Simple Web Service Mapping

Each remote system has it own data structures and it is possible to create new mapping modules for each case (e.g. there is a customized mapping module for SAP Solution Manager available as feature), but it is not always necessary. The module Mapping::Simple should cover most of the mapping needs.

Note

When the Mapping::Simple does not cover all mapping needs for a web service, a new mapping module should be created.

This module gives you the opportunity to set default values to map for each key or value for the whole communication data.

At the beginning of the screen you will see a general section where you can set the default rules that will apply for all the unmapped keys and values. There are three options available, these options are listed below:

Keep (leave unchanged)

It does not touch the keys or values in any way.

Ignore (drop key/value pair)

When this is applied to the key it deletes the key and value, because when a key is deleted then in consequence its associated value is deleted too. When this is applied to the value, only the value is deleted, keeping the key, that now will be associated to an empty value.

Map to (use provided value as default)

All keys and/or values without a defined map rule will use this as default. When you select this option a new text field will appear to set this default.

Clicking on the plus button for new key map will display a new box for a single mapping configuration. You can add as many key mappings as needed. Just click on the plus button again and a new mapping box will appear below the existing one. From this mapping boxes you can define a map for a single key, with the next options:

Exact value(s)

The old key string will be changed to a new one if the old key matches exactly.

Regular expression

The key string will be replaced following a regular expression rule.

Pressing the new value map plus button will display a new row for a value map. Here it is also possible to define rules for each value to be mapped with the same options as for the key map (exact value and regular expression). You can add as many values to map as needed, and if you want to delete one of them, just click on the minus button for each mapping value row.

Deleting the complete key mapping section (box) is possible, just push on the minus button located on the up right corner of each box that you want to delete.

If you need to delete a complete mapping configuration, go back to the corresponding operation or invoker screen, look for the mapping direction that you select before and set its value to , and save the configuration to apply the changes.

It is possible to define XSLT templates for mapping.

XSLT Web Service Incoming Mapping

XSLT Web Service Incoming Mapping

XSLT Mapping

XSLT stylesheet *

Here you can add or modify your XSLT mapping code.

The editing field allows you to use different functions like automatic formatting, window resize as well as tag- and bracket-completion.

Use key attribute

For incoming data this option defines if XML key attributes are converted into a Perl data structure or if they are ignored.

Example: Incoming XML data

<Article>
    <Subject>some subject</Subject>
    <Body>some body</Body>
    <ContentType>text/plain; charset=utf8</ContentType>
    <TimeUnit>1</TimeUnit>
</Article>
<Attachment>
    <Content>someTestData</Content>
    <ContentType>text/plain</ContentType>
    <Filename>test1.txt</Filename>
</Attachment>
<Attachment Content="someTestData" ContentType="text/plain" Filename="test2.txt" />

Resulting Perl data with Use key attribute disabled:

$VAR1 = {
    Article => {
        Body => 'some body',
        ContentType => 'text/plain; charset=utf8',
        Subject => 'some subject',
        TimeUnit => '1',
    },
    Attachment => [
        {
            Content => 'someTestData',
            ContentType => 'text/plain',
            Filename => 'test1.txt',
        },
        {},
    ],
};

Resulting Perl data with Use key attribute enabled:

$VAR1 = {
    Article => {
        Body => 'some body',
        ContentType => 'text/plain; charset=utf8',
        Subject => 'some subject',
        TimeUnit => '1',
    },
    Attachment => [
        {
            Content => 'someTestData',
            ContentType => 'text/plain',
            Filename => 'test1.txt',
        },
        {
            Content => 'someTestData',
            ContentType => 'text/plain',
            Filename => 'test2.txt',
        },
    ],
};
Attribute options

This option must be used in order to use key attributes for outgoing elements. First level options define the elements which should receive key attributes. Second level options define which sub elements should be converted into attributes and attached to the surrounding element. Only two levels of options are considered for key attributes. These will be used for any level of elements in the XML structure (not only the first level).

Please note that sorting of elements in the attribute options is possible but will not affect how key attributes are treated.

If every sub element of an element is converted into attributes and the element contains a specific ContentKey sub element, the content of this sub element will be used as value of the surrounding element. Please see the following example as illustration for these options.

XSLT Web Service Outgoing Mapping

XSLT Web Service Outgoing Mapping

Example: XSLT mapping

<?xml version="1.0" encoding="UTF-8"?>
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:date="http://exslt.org/dates-and-times" version="1.0" extension-element-prefixes="date">
        <xsl:template match="RootElement">
        <xsl:copy>
            <header>
                <messageID>someMessageID</messageID>
                <Attachment>
                    <ContentKey>text1.txt</ContentKey>
                    <Content>someValue</Content>
                    <ContentType>text/plain</ContentType>
                </Attachment>
                <Attachment>
                    <Filename>text2.txt</Filename>
                    <Content>someValue</Content>
                    <ContentType>text/plain</ContentType>
                </Attachment>
                <Attachment>
                    <ContentKey>text3.txt</ContentKey>
                    <Content>someValue</Content>
                    <ContentDisposition>inline</ContentDisposition>
                    <ContentType>text/plain</ContentType>
                </Attachment>
            </header>
            <ticketID>someTicketID</ticketID>
            <returnCode>0</returnCode>
        </xsl:copy>
    </xsl:template>
</xsl:transform>
Data includes

Select one or more sets of data that were created at earlier request/response stages to be included in mappable data.

These sets will appear in the data structure at /DataInclude/<DataSetName> (see debugger output of actual requests for details).

Web Service for Dynamic Field

To create a new dynamic field of type web service it is necessary to have an already working web service. It requires to have at least one invoker of the type Generic::PassThrough. This invoker will be called to fetch the data from the remote server. The original data that it is sent in a request is similar to the following example.

{
    DynamicFieldID    => 123,
    DynamicFieldLabel => 'NameX',
    DynamicFieldName  => 'NameX',
    DynamicFieldValue => 'Value',
    Form => {
        # Form fields
        # ...
    },
    Ticket => {
        # Ticket attributes
        # ...
    },
    DynamicField => {
        NameX => 'Value'
        NameY => [ 'Value' ],
    },
    UserID => 123,
},
Form

This section contains the fields in the current form in the web browser. This information changes as the screen is filled in.

Ticket

This section (or another source object, e. g. CustomerUser) contains the attributes of the object where the dynamic field belongs.

For example in the New Phone Ticket screen the section is empty as the ticket is not created yet, but in the Change Free Fields screen it contains the information of the current ticket.

DynamicField

This section contains all non empty values of all configured dynamic fields for the current object.

In most cases the data that the remote server requires will be very different from the data provided, so it is highly recommended to use a mapping module for the outgoing data to format it specifically for the remote server call.

The following outgoing mapping example shows an XSLT mapping that discards any data and sets a fixed UserLogin, Password and TicketID (as needed for a TicketGet operation).

<?xml version="1.0" encoding="UTF-8"?>
<xsl:transform
    xmlns:xsl="https://www.w3.org/1999/XSL/Transform"
    xmlns:date="https://exsalt.org/dates-and-times"
    version="1.0"
    extension-element-prefixes="date">

    <xsl:output method="xml" encoding="utf-8" indent="yes" />

    <!-- Don't return unmached tags -->
    <xsl:template match="text()" />

    <!-- Remove empty elements -->
    <xsl:template match="*[not(node())]" />

    <!-- Root template -->
    <xsl:template match="/">
        <RootElement>
            <UserLogin>someuser</UserLogin>
            <Password>somepassword</Password>
            <TicketID>1</TicketID>
        </RootElement>
    </xsl:template>

</xsl:transform>

The response from the server can also be very different, so in this case is also very recommended to use a mapping module for the incoming data in order to be able to process the information. The response must be a list of key and value elements.

The following incoming mapping example shows an XSLT mapping that converts the results from a TicketGet operation response form the remote server, extracting and formatting the state and queue as needed to be used as options for the dynamic field.

<?xml version="1.0" encoding="UTF-8"?>
<xsl:transform
    xmlns:xsl="https://www.w3.org/1999/XSL/Transform"
    xmlns:date="https://exsalt.org/dates-and-times"
    version="1.0"
    extension-element-prefixes="date">

    <xsl:output method="xml" encoding="utf-8" indent="yes" />

    <!-- Don't return unmached tags -->
    <xsl:template match="text()" />

    <!-- Remove empty elements -->
    <xsl:template match="*[not(node())]" />

    <!-- Root template -->
    <xsl:template match="/">
        <RootElement>
            <xsl:apply-templates />
        </RootElement>
    </xsl:template>

    <xsl:template match="/*/Ticket">
        <PossibleValue>
            <Key>State</Key>
            <Value>
                <xsl:value-of select="/*/Ticket/State" />
            </Value>
        </PossibleValue>
        <PossibleValue>
            <Key>Queue</Key>
            <Value>
                <xsl:value-of select="/*/Ticket/Queue" />
            </Value>
        </PossibleValue>
    </xsl:template>

</xsl:transform>

The following web service definition (importable YAML file) can be used for testing the field, but the endpoint must be adapted to match current system. This web service acts as requester and provider and it always returns the state and queue from TicketID 1, as possible values to the field.

Note

This example should not be used in conjunction with the development web server.

---
Debugger:
  DebugThreshold: debug
  TestMode: '0'
Description: Dynamic Field Web Service Test
FrameworkVersion: 7.0.x git
Provider:
  ErrorHandling: {}
  ErrorHandlingPriority: []
  Operation:
    TicketGet:
      Description: ''
      IncludeTicketData: ''
      MappingInbound: {}
      MappingOutbound: {}
      Type: Ticket::TicketGet
  Transport:
    Config:
      AdditionalHeaders: ~
      MaxLength: '100000000'
      NameSpace: https://www.otrs.org/TicketConnector/
      RequestNameFreeText: ''
      RequestNameScheme: Plain
      ResponseNameFreeText: ''
      ResponseNameScheme: Response
    Type: HTTP::SOAP
RemoteSystem: ''
Requester:
  ErrorHandling: {}
  ErrorHandlingPriority: []
  Invoker:
    TicketGet:
      Description: Get possible values from the other side.
      Events: []
      MappingInbound:
        Config:
          Template: |-
              <?xml version="1.0" encoding="UTF-8"?>
              <!--
              Copyright (C) 2001-2023 OTRS AG, https://otrs.com/
              This software comes with ABSOLUTELY NO WARRANTY. For details, see
              the enclosed file COPYING for license information (GPL). If you
              did not receive this file, see https://www.gnu.org/licenses/gpl.txt.
              -->

              <!-- DOCUMENTATION

              * Example XML Input *
              <RootElement>
                  ...
              </RootElement>


              * Example XML Output *
              <RootElement>
                  <PossibleValues>
                      <Key>???</Key>
                      <Value>???</Value>
                  </PossibleValues>
                  <PossibleValues>
                      <Key>???</Key>
                      <Value>???</Value>
                  </PossibleValues>
                  ...
              </RootElement>

              -->


              <xsl:transform
                  xmlns:xsl="https://www.w3.org/1999/XSL/Transform"
                  xmlns:date="https://exslt.org/dates-and-times"
                  version="1.0"
                  extension-element-prefixes="date">

                  <xsl:output method="xml" encoding="utf-8" indent="yes" />

                  <!-- Don't return unmatched tags -->
                  <xsl:template match="text()" />

                  <!-- Remove empty elements -->
                  <xsl:template match="*[not(node())]" />

                  <!-- Root template -->
                  <xsl:template match="/">
                      <RootElement>
                          <xsl:apply-templates />
                      </RootElement>
                  </xsl:template>

                  <xsl:template match="/*/Ticket">
                      <PossibleValue>
                          <Key>State</Key>
                          <Value><xsl:value-of select="/*/Ticket/State" /></Value>
                      </PossibleValue>
                      <PossibleValue>
                          <Key>Queue</Key>
                          <Value><xsl:value-of select="/*/Ticket/Queue" /></Value>
                      </PossibleValue>
                  </xsl:template>

              </xsl:transform>
        Type: XSLT
      MappingOutbound:
        Config:
          Template: |-
              <?xml version="1.0" encoding="UTF-8"?>
              <!--
              Copyright (C) 2001-2023 OTRS AG, https://otrs.com/

              This software comes with ABSOLUTELY NO WARRANTY. For details, see
              the enclosed file COPYING for license information (GPL). If you
              did not receive this file, see https://www.gnu.org/licenses/gpl.txt.
              -->

              <!-- DOCUMENTATION

              * Example XML Input *
              <RootElement>
                 ...
              </RootElement>


              * Example XML Output *
              <RootElement>
                  <PossibleValues>
                      <Key>???</Key>
                      <Value>???</Value>
                  </PossibleValues>
                  <PossibleValues>
                      <Key>???</Key>
                      <Value>???</Value>
                  </PossibleValues>
                  ...
              </RootElement>

              -->

              <xsl:transform
                  xmlns:xsl="https://www.w3.org/1999/XSL/Transform"
                  xmlns:date="https://exslt.org/dates-and-times"
                  version="1.0"
                  extension-element-prefixes="date">
                  <xsl:output method="xml" encoding="utf-8" indent="yes" />

                  <!-- Don't return unmatched tags -->
                  <xsl:template match="text()" />

                  <!-- Remove empty elements -->
                  <xsl:template match="*[not(node())]" />

                  <!-- Root template -->
                  <xsl:template match="/">
                      <RootElement>
                          <UserLogin>someuser</UserLogin>
                          <Password>somepassword</Password>
                          <TicketID>1</TicketID>
                      </RootElement>
                  </xsl:template>

              </xsl:transform>
        Type: XSLT
      Type: Generic::PassThrough
  Transport:
    Config:
      Encoding: ''
      Endpoint: https://localhost/otrs/nph-genericinterface.pl/Webservice/GenericConfigItemConnectorSOAP
      NameSpace: https://www.otrs.org/TicketConnector/
      RequestNameFreeText: ''
      RequestNameScheme: Plain
      ResponseNameFreeText: ''
      ResponseNameScheme: Response
      SOAPAction: Yes
      SOAPActionSeparator: '#'
      SSL:
        SSLProxy: ''
        SSLProxyPassword: ''
        SSLProxyUser: ''
    Type: HTTP::SOAP
  UseMappedData: '1'
Scroll to Top