Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  1. Right-click the project in the navigator and go to New → REST API to open the API Artifact Creation Options dialog box.

    Image Added

    Tip
    titleImporting a REST API?

    If you already have a REST API created, you have the option of importing the XML configuration. Select Import API Artifact and follow the instructions on the UI. To create a new API from scratch, continue with the following steps.

    Image Removed

  2. Leave the first option selected and click Next.
  3. Specify the API name, context, hostname, and port. For more information, see Configuring Endpoints using REST APIs.

    NameEnter a unique name for the new API.
    Context URL

    An API in WSO2 EI is analogous to a web application deployed in the in the ESB profile. Each API is anchored at a user-defined URL context, much like how a web application deployed in a servlet container is anchored at a fixed URL context. An API will only process processes requests that fall under its URL context. For example, if a particular API is anchored at the context /test”test, the API will only handle handles HTTP requests with a URL path that starts with /test”test.

    Info

    If your ESB profile is deployed in multitenant mode, the tenant domain should be added to the API context. For example, the API is defined for tenant abc.com, and the context for the API is " /order", the context should be "/t/abc.com/order". When you define the API in Design View, the tenant domain will be is appended to the context by the system. Therefore, you do not need to manually add the tenant domain.

    HostnameThe Host at which the API is anchored. If you don't do not enter a value, 'localhost' will be is considered the default hostname. If required, you can bind a given API to a user-defined hostname.
    PortThe Port of the REST API. If you don't enter do notenter a value, '8280' will be is considered the default hostname. If required, you can bind a given API to a user-defined port number.
    VersionThe ESB identifies each API by its unique context name. If you introduce a version in the API context (e.g., /Service 1.0.0), you can update it when you upgrade the same API (e.g., /Service 1.0.1). Version your APIs as early as possible in the development cycle.
  4. Click Finish. The REST API is created inside the src/main/synapse-config/api folder under the ESB Config project you specified.
  5. When you created the API, an API resource is created by default. If you want to add a new resource, click API Resource in the Tool pallet of the API section and simply drag and drop the resource to the REST API.

    Info
    titleAbout the default API Resource

    Each API can have at most one default resource. Any request received by the API but does not match any of the enclosed resource definitions will be dispatched to the default resource of the API. In case of API_3, a DELETE request on the URL “/payments” will be dispatched to the default resource as none of the other resources in API_3 are configured to handle DELETE requests. If you go to the Source view, the default resource will be as follows:

    Code Block
    <api context="/healthcare" name="HealthcareAPI" xmlns="http://ws.apache.org/ns/synapse">
        <resource methods="GET">
            <inSequence/>
            <outSequence/>
            <faultSequence/>
        </resource>
    </api>

...