Creating ESB Artifacts
This page describes how to create artifacts for the Enterprise Service Bus (ESB) . It contains the following sections:
Configuring the ESB Version
The ESB editor in Developer Studio can support ESB 4.x (which contains many new mediators) or ESB 3.0.1. To configure the version you want to support, choose Windows -> Preferences (Eclipse -> Preferences on a Mac), expand the Developer Studio category and click ESB, and then select the version you want to support. If you are editing an existing ESB configuration, reload the editor to apply the version change.
Getting Help in the Source View
When working with your ESB configurations in the source view instead of the design view, you can hover your mouse over any element (such as the definitions tag) to see the syntax of that element. You can also press Ctrl + Space to get suggested auto-completion text.
For example, if you view a proxy service in the Source view, and you remove the /
from the <inSequence/>
element and press Ctrl + space, Content Assist appears and lists all the options you can add at this point, including the closing </inSequence>
element.
Creating an ESB Config Project
You can create an ESB Config Project to save all the ESB related artifacts such as proxy services, endpoints, sequences, and Synapse configurations.
To create an ESB Config Project:
- Open the Developer Studio Dashboard and click ESB Config Project in the Enterprise Service Bus category.
- If you want to create this ESB project from existing configuration files, select Point to Existing Synapse-configs Folder. Otherwise, leave New ESB Config Project selected. Click Next.
- Do the following:
- Type a unique name for the project.
- If you selected the option to point to an existing Synapse-configs folder in the previous step, click Browse and navigate to the folder containing the configuration files.
- Optionally specify the location where you want to save the project (or leave the default location specified).
- Optionally specify the working set, if any, that you want to include in this project.
- A Maven POM file will be generated automatically for this project. If you want to include parent POM information in the file from another project in this workspace, click Next, click the Specify Parent from Workspace check box, and then select the parent project.
- Click Finish.
- If you specified a folder with existing configuration files, specify whether you want to open those files now.
The new project has now been created in the workspace. If you browse inside the project, you will see a project structure as below, with folders created for different resources such as endpoints, local entries, proxy services, and sequences.
Sequences
A sequence is a tree of mediators that you can use in your mediation workflow. You can create a sequence in your ESB Config project or in the registry and then add it right to that project's mediation workflow, or you can refer to it from a sequence mediator in this project or another project in this Eclipse workspace.
This section describes how to create a new sequence or import an existing sequence from an XML file (such as a Synapse Configuration file), and how to use the sequence in your mediation flow.
About Dynamic Sequences
Developer Studio allows you to create a Registry Resource Project, which can be used to store Resources and Collections you want to deploy to the registry of a Carbon Server through a Carbon Application Project (C-App). When you create a sequence, you can save it as a dynamic sequence in the Registry Resource Project and refer to that sequence from the mediation flow. At runtime, when you deploy the CAR file with both the Registry Resource Project and mediation flow, WSO2 ESB looks up and uses the sequence from the registry.
Creating a New Sequence
Follow these steps to create a new, reusable sequence that you can add to your mediation workflow or refer to from a sequence mediator, or to create a sequence mediator and its underlying sequence all at once. Alternatively, you can import an existing sequence.
To create a reusable sequence:
- Open the Developer Studio Dashboard (choose Developer Studio -> Open Dashboard) and click Sequence in the ESB Enterprise Service Bus area.
- Select Create New Sequence and click Next.
Type a unique name for the sequence.
Creating a Main Sequence
If you want to create the default main sequence, which just sends messages without mediation, be sure to name it
main
, which automatically populates the sequence with the default in and out sequences.- Do one of the following:
- To save the sequence in an existing ESB Config project in your workspace, click Browse and select that project.
- To save the sequence in a new ESB Config project, click Create new Project and create the new project.
- To save the sequence as a dynamic sequence in a registry resource project, click Make this as Dynamic Sequence, specify the registry space (Governance or Configuration), click the Browse button at the top of the dialog box next to Save Sequence in and select the registry resource project, and then type the sequence name in the Registry Path box.
- (Optional) In the Advanced Configuration section, specify another sequence to run when there is an error and the endpoint where messages should be sent.
- Click Finish.
The sequence is created in the sequences folder under the ESB Config or registry resource project you specified, and the sequence is open in the editor. - Add the endpoints and other sequences you want in this sequence and then choose File > Save.
The sequence is now available in the Defined Sequences section of the tool palette and ready for use.
To create a sequence when creating a sequence mediator:
- With your proxy service open in the editor, click Sequence Mediator in the tool palette and then click the location in the mediation workflow where you want to add this sequence.
The sequence mediator is added to the workflow with a default name, which is highlighted and ready for you to change. - Type the name you want for this sequence mediator and press Enter.
- Double-click the sequence mediator you just added.
A sequence is created and opened in the editor using the same name you entered for the sequence mediator. - Add the endpoints and other sequences you want in this sequence, and then choose File > Save.
The mediation workflow is updated with the endpoints you added to the sequence. The sequence is also now available in the Defined Sequences section of the tool palette and ready for use in other meditation workflows.
Importing a Sequence
Follow these steps to import an existing sequence from an XML file (such as a Synapse configuration file) into an ESB Config project. Alternatively, you can create a new sequence.
- Open the Developer Studio Dashboard (choose Developer Studio -> Open Dashboard) and click Sequence in the ESB Enterprise Service Bus area.
- Select Import Sequence and click Next.
- Specify the sequence file by typing its full pathname or clicking Browse and navigating to the file.
- In the Save Sequence In field, specify an existing ESB Config Project in your workspace where you want to save the sequence, or click Create new Project to create a new ESB Config Project and save the sequence there.
- In the Advanced Configuration section, select the sequences you want to import.
- Click Finish. The sequences you selected are created in the sequences folder under the ESB Config project you specified, and the first sequence is open in the editor.
Using a Sequence
After you create a sequence, it appears in the Defined Sequences section of the tool palette. To use this sequence in a mediation flow, click the sequence in the tool palette and then click the spot on the canvas where you want the sequence to appear in the flow. The editor automatically adds any endpoints you used in your sequence.
If you want to use a sequence from a different project or from the registry, you create a sequence mediator and then refer to the sequence as follows:
- Click Sequence Mediator on the tool palette, and then click the spot on the canvas where you want the sequence to appear in the mediation workflow.
- Press Enter to accept the default name for now.
- In the Properties pane at the bottom of the window, click Static Reference Key, and then click the browse [...] button on the right.
- In the Resource Key Editor, click Registry if the sequence is stored in the registry or Workspace if it's in another ESB Config Project in this Eclipse workspace.
- If you are trying to select a sequence from the registry and no entries appear in the dialog box, click the add registry connection button (the first button in the upper right corner) and connect to the registry where the sequence resides.
- Navigate to the sequence you want, select it and click OK, and then click OK again.
The sequence mediator name and static reference key are updated to point to the sequence you selected.
Endpoints
An endpoint is the address of a service where messages are sent. Typically, the endpoint is the address of a proxy service, which acts as the front end to the actual service.
When you create an endpoint, you give it a name, at which point it appears in the Defined Endpoint section of the tool palette in Developer Studio. To use a defined endpoint, simply drag and drop it from the palette to the sequence, proxy service, or other artifact where you want to reference it.
You can create a new endpoint or import an existing endpoint from an XML file, such as a Synapse Configuration file.
Creating a New Endpoint
Follow these steps to create a new endpoint. Alternatively, you can import an existing endpoint.
- Open the Developer Studio Dashboard (choose Developer Studio -> Open Dashboard) and click Endpoint in the ESB Enterprise Service Bus area.
- Select Create a New Endpoint and click Next.
- Type a unique name for the endpoint, and then specify the type of endpoint you are creating.
- Do one of the following:
- To save the endpoint in an existing ESB Config project in your workspace, click Browse and select that project.
- To save the endpoint in a new ESB Config project, click Create new Project and create the new project.
- To save the endpoint in a registry resource project, click Make this a Dynamic Endpoint, click the Browse button next to Save endpoint in and select the registry, and then select the registry (Configuration or Governance) where you want to save the endpoint. Lastly, type the endpoint name in the Registry Path box.
- In the Advanced Configuration section, which changes based on the type of endpoint you are creating, specify any additional options you need for that endpoint type.
- Click Finish. The endpoint is created in the endpoints folder under the ESB Config or registry resource project you specified, and the endpoint is open in the editor.
Importing an Endpoint
Follow these steps to import an existing endpoint from an XML file (such as a Synapse configuration file) into an ESB Config project. Alternatively, you can create a new endpoint.
- Open the Developer Studio Dashboard (choose Developer Studio -> Open Dashboard) and click Endpoint in the ESB Enterprise Service Bus area.
- Select Import Endpoint and click Next.
- Specify the endpoint file by typing its full pathname or clicking Browse and navigating to the file.
- In the Save Endpoint In field, specify an existing ESB Config Project in your workspace where you want to save the endpoint, or click Create new Project to create a new ESB Config Project and save the endpoint there.
- In the Advanced Configuration section, select the endpoints you want to import.
- Click Finish. The endpoints you selected are created in the endpoints folder under the ESB Config project you specified, and the first endpoint is open in the editor.
Local Entries
A local entry is used to store static content as a key-value pair, where the value could be a static entry such as a text string, XML code, or a URL. This is useful for the type of static content often found in XSLT files, WSDL files, URLs, etc. Local entries can be referenced from mediators in ESB mediation flows and resolved at runtime.
You can create a new local entry or import an existing local entry from an XML file, such as a Synapse Configuration file.
Creating a New Local Entry
Follow these steps to create a new local entry. Alternatively, you can import an existing local entry.
- Open the Developer Studio Dashboard (choose Developer Studio -> Open Dashboard) and click Local Entry in the ESB Enterprise Service Bus area.
- Select Create a New Local Entry and click Next.
- Type a unique name for the local entry, specify one of the following types of local entries, and then fill in the advanced configuration as described below:
- In-Line Text Entry: Type the text you want to store
- In-Line XML Entry: Type the XML code you want to store
- Source URL Entry: Type or browse to the URL you want to store
- Do one of the following:
- To save the local entry in an existing ESB Config project in your workspace, click Browse and select that project.
- To save the local entry in a new ESB Config project, click Create new Project and create the new project.
- Click Finish. The local entry is created in the local-entries folder under the ESB Config Project you specified, and the local entry appears in the editor. Click its icon in the editor to view its properties.
Importing a Local Entry
Follow these steps to import an existing local entry from an XML file (such as a Synapse configuration file) into an ESB Config project. Alternatively, you can create a new local entry.
- Open the Developer Studio Dashboard (choose Developer Studio -> Open Dashboard) and click Local Entry in the ESB Enterprise Service Bus area.
- Select Import Local Entry and click Next.
- Specify the local entry file by typing its full pathname or clicking Browse and navigating to the file.
- In the Save Local Entry In field, specify an existing ESB Config Project in your workspace where you want to save the local entry, or click Create new Project to create a new ESB Config Project and save the local entry there.
- In the Advanced Configuration section, select the local entries you want to import.
- Click Finish. The local entries you selected are created in the local-entries folder under the ESB Config project you specified, and the first local entry appears in the editor.
Using a Local Entry
After you create a local entry, you can reference it from a mediator in your mediation workflow. For example, if you created a local entry with XSLT code, you could add an XSLT mediator to the workflow and then reference the local entry as follows:
- Click the XSLT mediator to display its properties, click the XSLT Static Schema Key property, and then click the browse [...] button on the far right of the property's value.
- Click the Workspace link, and then navigate to and select the local entry that contains the XSLT code.
- Click OK.
Proxy Services
A proxy service is a virtual service that receives messages and optionally processes them before forwarding them to a service at a given endpoint. It acts as a front end to the service, allowing you to define a mediation workflow that performs whatever logic is needed on the message before sending it to the actual service.
You can create a new proxy service or import an existing proxy service from an XML file, such as a Synapse Configuration file.
Creating a New Proxy Service
Follow these steps to create a proxy service. Alternatively, you can import an existing proxy service .
- Open the Developer Studio Dashboard (choose Developer Studio -> Open Dashboard) and click Proxy Service in the ESB Enterprise Service Bus area.
- Select Create a New Proxy Service and click Next.
- Type a unique name for the proxy service and specify the proxy type (see below).
- Do one of the following:
- To save the proxy service in an existing ESB Config project in your workspace, click Browse and select that project.
- To save the proxy service in a new ESB Config project, click Create new ESB Project and create the new project.
- If you specified a proxy type that requires that you enter the target endpoint (the endpoint that represents the actual service), do one of the following:
- If you know the URL of the endpoint, select Enter URL and type it in the text box.
- If you want to use an endpoint you've already defined in this workspace, select Predefined Endpoint and select it from the list.
- If you want to use an endpoint in the registry, select Pick from Registry, and then either type the endpoint's registry key or click Browse, click Registry, and navigate to the endpoint in the registry.
- Fill in the advanced configuration based on the proxy service type you specified:
- Transformer Proxy: Transforms all the incoming requests using XSLT and then forwards them to a given target endpoint. Specify the target endpoint as described in the previous step, and then specify the location of the XSLT you want to use to transform requests, either by typing the path or by clicking Browse and navigating to the XSLT, which can be a file in the workspace or registry or can be a local entry. If you also want to transform the responses from the backend service, click Transform Responses.
- Log Forward Proxy: Logs all the incoming requests and forwards them to a given endpoint. It can also log responses from the backend service before routing them to the client. Specify the log level for requests and responses, where Simple logs
To, From, WSAction, SOAPAction, ReplyTo, MessageID
, and any properties, and Full logs all attributes of the message plus the SOAP envelope information. - Pass Through Proxy: Forwards messages to the endpoint without performing any processing on them. This proxy service is useful as a catch-all, so that messages that do not meet the criteria to be handled by other proxy services are simply forwarded to the endpoint. When you select this proxy service type, you just specify the target endpoint as described in the previous step.
- WSDL Based Proxy: A proxy service that is created from the remotely hosted WSDL of an existing web service. The endpoint information is extracted from the WSDL. In the URI field, enter the URL and URN of the WSDL. The URL defines the host address of the network resource (can be omitted if resources are not network homed), and the URN defines the resource name in local namespaces. For example, if the URL is
ftp://ftp.dlink.ru
and the URN is/pub/ADSL/
, you would enterftp://ftp.dlink.ru/pub/ADSL/
for the URI. To ensure that the URI is valid, click Test URI. You then enter the service name and port of the WSDL. Lastly, if you want to publish this WSDL, click Publish Same Service Contract. - Secure Proxy: Uses WS-Security to process incoming requests and forward them to an unsecured backend service. Specify the target endpoint as described in the previous step, and then specify the key of the security policy or click Browse and select it from the registry.
- Custom Proxy: A custom proxy service in which you customize all the sequences, endpoints, transports, and other QoS settings by adding them to the mediation workflow after the proxy service is created.
- Click Finish. The proxy service is created in the src/main/synapse-config/proxy-service folder under the ESB Config Project you specified, and the proxy service appears in the editor. Click its icon in the editor to view its properties.
Importing a Proxy Service
Follow these steps to import an existing proxy service from an XML file (such as a Synapse configuration file) into an ESB Config project. Alternatively, you can create a new proxy service.
- Open the Developer Studio Dashboard (choose Developer Studio -> Open Dashboard) and click Proxy Service in the ESB Enterprise Service Bus area.
- Select Import Proxy Service and click Next.
- Specify the proxy service file by typing its full pathname or clicking Browse and navigating to the file.
- In the Save Proxy Service In field, specify an existing ESB Config Project in your workspace where you want to save the proxy service, or click Create new ESB Project to create a new ESB Config Project and save the proxy service there.
- If there are multiple proxy services in the file, in the Advanced Configuration section select the proxy services you want to import.
- Click Finish. The proxy services you selected are created in the src/main/synapse-config/proxy-service folder under the ESB Config project you specified, and the first proxy service appears in the editor.
Synapse Configurations
A Synapse configuration file contains one or more ESB artifacts, such as endpoints and sequences. You can create a new Synapse configuration, or you can import an existing Synapse configuration to import all its ESB artifacts in one step.
Creating a Synapse Configuration
Follow these steps to create a Synapse Configuration. Alternatively, you can import an existing Synapse Configuration .
- Open the Developer Studio Dashboard (choose Developer Studio -> Open Dashboard) and click Synapse in the ESB Enterprise Service Bus area.
- Do one of the following, and then click Next:
- To create a simple Synapse configuration file, select Create New Synapse Configuration.
- To create a Synapse configuration file with the main and fault sequence templates included, select Create New Synapse Configuration with Template.
- Type a unique name for the Synapse configuration.
- Do one of the following:
- To save the Synapse configuration in an existing ESB Config project in your workspace, click Browse and select that project.
- To save the Synapse configuration in a new ESB Config project, click Create new ESB Project and create the new project.
- Click Finish. The Synapse configuration is created in the src/main/synapse-config folder under the ESB Config Project you specified. When prompted, you can open the file in the editor. Click its icon in the editor to view its properties.
Importing a Synapse Configuration
Follow these steps to import an existing Synapse configuration into an ESB Config project. Alternatively, you can create a new Synapse configuration.
- Open the Developer Studio Dashboard (choose Developer Studio -> Open Dashboard) and click Synapse in the ESB Enterprise Service Bus area.
- Select Import Synapse Configuration from File System and click Next.
- Specify the Synapse configuration file by typing its full pathname or clicking Browse and navigating to the file.
- In the Save Synapse Configuration In field, specify an existing ESB Config Project in your workspace where you want to save the configuration, or click Create new ESB Project to create a new ESB Config Project and save the Synapse configuration there.
- If there are multiple artifacts in the file, click Create ESB Artifacts, and then select the artifacts you want to import.
- Click Finish. The artifacts you selected are created in the subfolders of src/main/synapse-config folder under the ESB Config project you specified, and the first artifact appears in the editor.
Creating a REST API
A REST API allows you to configure REST endpoints in the ESB by directly specifying HTTP verbs (such as POST and GET), URI templates, and URL mappings through an API. You can create a new REST API, or you can import an existing REST API from the file system.
Creating a REST API
Follow these steps to create a REST API. Alternatively, you can import an existing REST API .
- Open the Developer Studio Dashboard (choose Developer Studio -> Open Dashboard) and click REST API in the ESB Enterprise Service Bus area.
- Leave the first option selected and click Next.
- Type a unique name for the REST API and specify the context, hostname, and port. For more information, see "Getting Started with REST APIs" in the ESB documentation.
- Do one of the following:
- To save the API in an existing ESB Config project in your workspace, click Browse and select that project.
- To save the API in a new ESB Config project, click Create new ESB Project and create the new project.
- Click Finish. The REST API is created in the src/main/synapse-config/api folder under the ESB Config Project you specified. When prompted, you can open the file in the editor, or you can right-click the API in the project explorer and choose Open With -> ESB Editor. Click its icon in the editor to view its properties.
Importing a REST API
Follow these steps to import an existing REST API into an ESB Config project. Alternatively, you can create a new REST API.
- Open the Developer Studio Dashboard (choose Developer Studio -> Open Dashboard) and click REST API in the ESB Enterprise Service Bus area.
- Select Import API Artifact and click Next.
- Specify the XML file that defines the API by typing its full pathname or clicking Browse and navigating to the file.
- In the Save API In field, specify an existing ESB Config Project in your workspace where you want to save the API, or click Create new ESB Project to create a new ESB Config Project and save the API configuration there.
- If there are multiple API definitions in the file, click Create ESB Artifacts, and then select the artifacts you want to import.
- Click Finish. The APIs you selected are created in the subfolders of the src/main/synapse-config/api folder under the ESB Config project you specified, and the first API appears in the editor.
Creating a Scheduled Task
A scheduled task allows you to run a piece of code triggered by a timer. You can create a new task, or you can import an existing task from the file system.
Creating a Task
Follow these steps to create a new scheduled task. Alternatively, you can import an existing task .
- Open the Developer Studio Dashboard (choose Developer Studio -> Open Dashboard) and click Scheduled Task in the ESB Enterprise Service Bus area.
- Leave the first option selected and click Next.
- Type a unique name for this scheduled task and specify the group, implementation class, and other options. For more information, see "Adding and Scheduling Tasks" in the ESB documentation.
- Do one of the following:
- To save the task in an existing ESB Config project in your workspace, click Browse and select that project.
- To save the task in a new ESB Config project, click Create new ESB Project and create the new project.
- Click Finish. The scheduled task is created in the src/main/synapse-config/tasks folder under the ESB Config Project you specified. When prompted, you can open the file in the editor, or you can right-click the task in the project explorer and choose Open With -> ESB Editor. Click its icon in the editor to view its properties.
Importing a Task
Follow these steps to import an existing scheduled task into an ESB Config project. Alternatively, you can create a new task.
- Open the Developer Studio Dashboard (choose Developer Studio -> Open Dashboard) and click Scheduled Task in the ESB Enterprise Service Bus area.
- Select Import Scheduled Task Artifact and click Next.
- Specify the XML file that defines the scheduled task by typing its full pathname or clicking Browse and navigating to the file.
- In the Save Task In field, specify an existing ESB Config Project in your workspace where you want to save the task, or click Create new ESB Project to create a new ESB Config Project and save the task configuration there.
- If there are multiple tasks definitions in the file, click Create ESB Artifacts, and then select the tasks you want to import.
- Click Finish. The tasks you selected are created in the subfolders of the src/main/synapse-config/tasks folder under the ESB Config project you specified, and the first task appears in the editor.
Creating a Message Store
A message store is used to temporarily hold messages before they are delivered to their destination by a message processor, allowing you to control the flow of messages and implement different messaging and integration patterns. You can create a new message store, or you can import an existing message store from the file system.
Creating a Message Store
Follow these steps to create a new message store. Alternatively, you can import an existing message store .
- Open the Developer Studio Dashboard (choose Developer Studio -> Open Dashboard) and click Message Store in the ESB Enterprise Service Bus area.
- Leave the first option selected and click Next.
- Type a unique name for this message store, specify the type of store you're creating, and then fill in the options for that store type. For details on creating message stores, see the ESB documentation.
- Do one of the following:
- To save the message store in an existing ESB Config project in your workspace, click Browse and select that project.
- To save the message store in a new ESB Config project, click Create a new ESB Project and create the new project.
- Click Finish. The message store is created in the src/main/synapse-config/message-stores folder under the ESB Config Project you specified and appears in the editor. You can click its icon in the editor to view its properties.
Importing a Message Store
Follow these steps to import an existing message store into an ESB Config project. Alternatively, you can create a new message store.
- Open the Developer Studio Dashboard (choose Developer Studio -> Open Dashboard) and click Message Store in the ESB Enterprise Service Bus area.
- Select Import a Message Store and click Next.
- Specify the XML file that defines the message store by typing its full pathname or clicking Browse and navigating to the file.
- In the Save In field, specify an existing ESB Config Project in your workspace where you want to save the message store, or click Create new Project to create a new ESB Config Project and save the message store configuration there.
- Click Finish. The message store is created in the src/main/synapse-config/message-stores folder under the ESB Config Project you specified and appears in the editor.
Creating a Message Processor
A message processor is used to deliver messages that have been held in a message store. You can create a new message processor, or you can import an existing message processor from the file system.
Be sure to create the message store before creating the message processor, as you will need to specify the message store that this processor applies to.
Creating a Message Processor
Follow these steps to create a new message processor. Alternatively, you can import an existing message processor .
- Open the Developer Studio Dashboard (choose Developer Studio -> Open Dashboard) and click Message Processor in the ESB Enterprise Service Bus area.
- Leave the first option selected and click Next.
- Type a unique name for this message processor, specify the type of processor you're creating, specify the message store this processor applies to, and then fill in the options for the processor type you selected. For details on creating message processors, see the ESB documentation.
- Do one of the following:
- To save the message processor in an existing ESB Config project in your workspace, click Browse and select that project.
- To save the message processor in a new ESB Config project, click Create a new ESB Project and create the new project.
- Click Finish. The message processor is created in the src/main/synapse-config/message-processors folder under the ESB Config Project you specified and appears in the editor. You can click its icon in the editor to view its properties.
Importing a Message Processor
Follow these steps to import an existing message processor into an ESB Config project. Alternatively, you can create a new message processor.
- Open the Developer Studio Dashboard (choose Developer Studio -> Open Dashboard) and click Message Processor in the ESB Enterprise Service Bus area.
- Select Import a Message Processor and click Next.
- Specify the XML file that defines the message processor by typing its full pathname or clicking Browse and navigating to the file.
- In the Save In field, specify an existing ESB Config Project in your workspace where you want to save the message processor, or click Create new Project to create a new ESB Config Project and save the message processor configuration there.
- Click Finish. The message processor is created in the src/main/synapse-config/message-processors folder under the ESB Config Project you specified and appears in the editor.
Creating a Template
A template is a reusable, parameterized configuration that you can reuse when creating endpoints and sequences. You can create a new template, or you can import an existing template from the file system.
Creating a Template
Follow these steps to create a new scheduled task. Alternatively, you can import an existing template .
- Open the Developer Studio Dashboard (choose Developer Studio -> Open Dashboard) and click Template in the ESB Enterprise Service Bus area.
- Leave the first option selected and click Next.
- Type a unique name for this template and specify the type of template you're creating.
- Do one of the following:
- To save the template in an existing ESB Config project in your workspace, click Browse and select that project.
- To save the template in a new ESB Config project, click Create new Project and create the new project.
- If you specified an address or WSDL endpoint as the template type, enter the URL for the address or the WSDL URI and connection information in the Advanced Configuration fields.
- Click Finish. The template is created in the src/main/synapse-config/templates folder under the ESB Config Project you specified. When prompted, you can open the file in the editor, or you can right-click the template in the project explorer and choose Open With -> ESB Editor. Click its icon in the editor to view its properties.
Importing a Template
Follow these steps to import an existing template into an ESB Config project. Alternatively, you can create a new template.
- Open the Developer Studio Dashboard (choose Developer Studio -> Open Dashboard) and click Template in the ESB Enterprise Service Bus area.
- Select Import a Template and click Next.
- Specify the XML file that defines the template by typing its full pathname or clicking Browse and navigating to the file.
- In the Save Template In field, specify an existing ESB Config Project in your workspace where you want to save the template, or click Create new Project to create a new ESB Config Project and save the template configuration there.
- If there are multiple template definitions in the file, click Create ESB Artifacts, and then select the templates you want to import.
- Click Finish. The templates you selected are created in the subfolders of the src/main/synapse-config/templates folder under the ESB Config project you specified, and the first template appears in the editor.
Creating a mediator
A mediator project allows you to create a custom mediator that performs some logic on a message. You can create a new mediator project, or you can import an existing mediator project from the workspace.
Once the mediator project is finalised, you can export it as a deployable artifact by right-clicking on the project and selecting Export Project as Deployable Archive. This creates a JAR file that you can deploy to a WSO2 ESB. Alternatively, you can group the mediator project as a Composite Application Project, create a Composite Application Archive (CAR), and deploy it to the ESB.
From ESB 4.8.1 onwards, a URL classloader is used to load classes in the mediator (class mediators are not deployed as OSGi bundles). Therefore, it is only possible to refer to the class mediator from artifacts packed in the same CAR file in which the class mediator is packed. Accessing the class mediator from an artifact packed in another CAR file is not possible. However, it is possible to refer to the class mediator from a sequence packed in the same CAR file and call that sequence from any other artifact packed in other CAR files.
Creating a mediator project
Follow these steps to create a new mediator. Alternatively, you can import a mediator project.
- Open the Developer Studio Dashboard (click Developer Studio > Open Dashboard) and click Mediator Project in the Enterprise Service Bus area.
- Leave the first option selected and click Next. The New Mediator Creation Wizard appears.
- Do the following:
- Type a unique name for the project.
- Specify the package and class names you are creating.
- Optionally specify the location where you want to save the project (or leave the default location specified).
- Optionally specify the working set, if any, that you want to include in this project.
- A Maven POM file will be generated automatically for this project. If you want to include parent POM information in the file from another project in this workspace, click Next, click the Specify Parent from Workspace check box, and then select the parent project.
- Click Finish.
The mediator project is created in the workspace location you specified with a new mediator class that extends org.apache.synapse.mediators.AbstractMediator
.
Importing a Java Mediator Project
Follow the steps below to import a Java mediator project (that includes a Java class, which extends the org.apache.synapse.mediators.AbstractMediator
class) to WSO2 Developer Studio.
- Open the Developer Studio Dashboard (click Developer Studio > Open Dashboard) and click Mediator Project in the Enterprise Service Bus area.
- Select Import From Workspace and click Next.
- Specify the mediator project in this workspace that you want to import. Only projects with source files that extend
org.apache.synapse.mediators.AbstractMediator
are listed. Optionally, you can change the location where the mediator project will be created and add it to working sets. - Click Finish.
The mediator project you selected is created in the location you specified.
The mediator projects you create using WOS2 Developer Studio are of the org.wso2.developerstudio.eclipse.artifact.mediator.project.nature
nature by default. Follow the steps below to view this nature added to the <PROJECT_NAME>/target/.project
file of the Java mediator project you imported.
- Click the View Menu icon, and click Customize View.
- Deselect .*resources, and click OK.
For information on importing a mediator project, which you created using WSO2 Developer Studio, see Importing Existing Projects.
You can export this mediator project as a deployable artifact by right-clicking on the project and selecting Export Project as Deployable Archive. This creates a JAR file that you can deploy to a WSO2 ESB. Alternatively, you can group the mediator project with a Carbon Application Project, create a Carbon Application Archive (CAR), and deploy it to the ESB.
Creating a Smooks Configuration Artifact
In order to create a Smooks Configuration Artifact, first you need to create a Registry Resource. Go through how to create a Registry Resource document. When creating the Registry Resource, select From Existing Template option and select the template as Smooks Configuration.
Now you will see smooks-configuration file has been created and it will be open in the embedded JBoss Smooks editor.
You can find more information regarding how to map data using smooks configuration from here.
Create the smooks configuration and save the file.
To run the created smooks-configuration, you will need to add libraries from smooks framework. To add these libraries select the Registry Resources project and go to Project -> Properties.
Select Java Build Path and go to Libraries tab.
Click on Add Library button and you will see Add Library page which has WSO2 Classpath Libraries entry at the bottom.
Select WSO2 Classpath Libraries and click Next. Now you will see a multi-tab page which includes most of the third party libraries that will be needed for your SOA development. To add smooks related libraries, go to Smooks tab.
Select all the libraries by clicking Select All button and click Finish.
Now you will see, all the smooks related libraries are added to project classpath.
Now you can run smooks configuration file by right click on the file and select Run As -> Smooks Run Configuration after doing the mapping you need.
If your Smooks Configuration is correct, it will show the results according to the Input Model and the Output Model that you have specified in the console.
You can add this newly created smooks configuration artifact in to ESB Tools via a Proxy Service or a Sequence. To do so, let's create a Proxy Service as mentioned Proxy Service section. Then you can see there is a selection called Anonymous under InSequence drop down.If it is not there click on InSequence and set Anonymous from its properties.
Next right click on Anonymous and then select New Child -> Advanced -> Smooks from the menu.
Once you double click on the Smooks mediator, you will see that the Properties view get focused. From the Properties view, click on the button at the right hand corner of Configuration Key field.
Once you click on the button, it will open the Resource Key Editor dialog which you can specify from where you should select the resource file.
Select Workspace option since we have the created Smooks Configuration in our workspace. Browse for the Smooks Configuration file that we have created and click OK.
Now you have successfully refer the created Smooks Configuration within your proxy service.
Deploying the ESB Config Project
Once you create all the ESB components such as sequences, proxy services, endpoints, local-entries, you can create a Carbon Application Project to group them and create a Carbon Application Archive.
You can select individual components as well.