Posts

Dynamic Endpoints in WSO2 API Manager

Image
From WSO2 APIM 1.10.0, we have introduced new feature to define dynamic endpoints through synapse default endpoints support. In this blog article, I am going to show how we can create an API with dynamic endpoints in APIM. Assume that you have a scenario where depending on the request payload, the backend URL of the API differs. For instance, if the value of "operation" element in the payload is "menu", you have to route the request to endpoint1 and else you need to route the request to endpoint2. { "srvNum": "XXXX", "operation": "menu" } In APIM, dynamic endpoints are achieved through mediation extension sequences. For more information about mediation extensions refer this documentation. For dynamic endpoints we have to set the "To" header with the endpoint address through a mediation In-flow sequence. So let's first create the sequence which sets the "To" header based on the payload. Cr...

How to invoke APIs in SOAP style in Swagger

Image
WSO2 API Manager has integrated Swagger to allow API consumers to explore APIs through a interactive console which is known as 'API Console' This swagger based API Console supports invoking APIs i REST style out of the box. So this post going to show how we can invoke APIs in SOAP style in API console of WSO2 API Manager 1.7.0. For that we need to do few extra configurations. 1. Send SOAPAction and Content-Type header in the request 2. Enable sending SOAPAction header in the CORS configuration First create an API for a SOAP Service. In this example I am using HelloService sample SOAP service of WSO2 Application Server. This HelloService has a operation named greet which accepts a payload as below. <soapenv:envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:typ="http://www.wso2.org/types"> <soapenv:header> <soapenv:body> <typ:greet> <!--Optional:--> <name>lakma...

Troubleshooting Swagger issues in WSO2 API Manager

Image
WSO2 API Manager provides this functionality through the integration of Swagger ( https://developers.helloreverb.com/swagger ). Swagger-based interactive documentation allows you to try out APIs from the documentation itself which is available as the "API Console" in API Store.  There are certain requirements that need to be satisfied in order to swagger Try-it functionality to work. First requirement is to enable CORS in API Mananger Store. This documentation describes how that should be done.  But most of them face many issues in getting the swagger Try-it into work. So this blog post describes common issues faced by users with Swagger and how to troubleshoot them.   Issue-1 API Console keeps on loading the response for ever as below. Cause -1 API resource not supporting OPTIONS HTTP verb.  Solution Add OPTIONS HTTP verb for API resources as below. Then Save the API and Try again.  Cause -2  Backend ...

Customizing workflows in WSO2 API Manager

Image
In WSO2 API Manager, Workflow extensions allow you to attach a custom workflow to various operations in the API Manager for User Signup Application Creation Application Registration Subscription By default, the API Manager workflows have Simple Workflow Executor engaged in them. The Simple Workflow Executor carries out an operation without any intervention by a workflow admin. For example, when the user creates an application, the Simple Workflow Executor allows the application to be created without the need for an admin to approve the creation process. In order to enforce intervention by a workflow admin, you can engage the WS Workflow Executor . It invokes an external Web service when executing a workflow and the process completes based on the output of the Web service. For example, when the user creates an application, the request goes into an intermediary state where it remains until authorized by a workflow admin. You can try out the default wor...

Migrating WSO2 API Manager 1.5.0 to 1.6.0

WSO2 API Manager latest version 1.6.0 got released recently. This post provides instructions on how to migrate your data from API Manager 1.5.0 to 1.6.0. If you had already used API Manager 1.5.0 and need to migrate your data to the latest version you can follow this. You can download WSO2 API Manager 1.6.0 from here . You can download the latest migration scripts from https://svn.wso2.org/repos/wso2/carbon/platform/branches/turing/products/apimgt/1.6.0/modules/distribution/resources/migration-1.5.0_to_1.6.0 Checkout the migration kit by executing below command. %> svn co https://svn.wso2.org/repos/wso2/carbon/platform/branches/turing/products/apimgt/1.6.0/modules/distribution/resources/migration-1.5.0_to_1.6.0 Shutdown AM 1.5.0 if it is running.  Backup your API Manager Databases of your AM 1.5.0 instance. Execute relevant sql script in migration-1.5.0_to_1.6.0 against your API Manager Database. (ex:If your database is mysql run mysql.sql against yo...

Migrating WSO2 API Manager 1.4.0 to 1.5.0

Migrating WSO2 API Manager 1.4.0 to 1.5.0 WSO2 API Manager latest version 1.5.0 got released recently. This post provides instructions on how to migrate your data from API Manager 1.4.0 to 1.5.0. If you had already used API Manager 1.4.0 and need to migrate your data to the latest version you can follow this. You can download WSO2 API Manager 1.5.0 from here . You can download the latest migration scripts from  https://svn.wso2.org/repos/wso2/carbon/platform/branches/turing/products/apimgt/1.6.0/modules/distribution/resources/migration-1.4.0_to_1.5.0/ Checkout the migration kit by executing below command. %> svn co  https://svn.wso2.org/repos/wso2/carbon/platform/branches/turing/products/apimgt/1.6.0/modules/distribution/resources/migration-1.4.0_to_1.5.0/ 1. Shutdown APIM 1.4.0 if it is running. 2. Backup your WSO2 Carbon Database(User Store and Registry) and API Manager Databases of your APIM 1.4.0 instance. 3. Execute relevant sql script in ' migratio...

How to add additional headers to WSO2 API Manager Swagger Console

Image
WSO2 API Manager has integrated Swagger to allow API consumers to explore APIs through a interactive console. When integrating Swagger with WSO2 API Manager we had to support CORS between API Store and the API Gateway. So in order to send any headers from Swagger, we need to add those required headers to the response coming from the API Gateway as 'Access-Control-Allow-Headers' . By default below set of headers are allowed to be send from swagger. authorization,Access-Control-Allow-Origin,Content-Type So if you need to add any additional headers to Swagger UI, then we should add that header to list of 'Access-Control-Allow-Headers'. There are 2 options to modify 'Access-Control-Allow-Headers'. 1. Modify the Synapse configuration of APIs and add modified set of headers to OutSequence. If you choose this method, you have to modify API configuration of each API and add the 'Access-Control-Allow-Headers'. For that go to Management Console of API...