DZone
Integration Zone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
  • Refcardz
  • Trend Reports
  • Webinars
  • Zones
  • |
    • Agile
    • AI
    • Big Data
    • Cloud
    • Database
    • DevOps
    • Integration
    • IoT
    • Java
    • Microservices
    • Open Source
    • Performance
    • Security
    • Web Dev
DZone > Integration Zone > Extending the Prototyping Capabilities of WSO2 API Manager

Extending the Prototyping Capabilities of WSO2 API Manager

Check out how to create API prototypes with mediation policies, and showing the power of WSO2 API manager.

Dumidu Handakumbura user avatar by
Dumidu Handakumbura
·
Mar. 09, 16 · Integration Zone · Analysis
Like (2)
Save
Tweet
4.89K Views

Join the DZone community and get the full member experience.

Join For Free

What's covered: creating API prototypes using mediation policies for APIM 1.10.0
WSO2 API Manager comes with API prototyping capability OOTB. However if you are in need of advanced prototyping capabilities or feel restricted by the available implementation for the time being you could tap into the underlying mediation engine (WSO2 ESB) to meet your prototyping need.

1) Create a Mediation Policy With the Prototype Logic

The mediation policy should be such that it responds back to the client with the configured response rather than passing the message back to the backend. We can achieve this requirement using Respond [1] and Payload Factory mediators [2].

 <sequence xmlns="http://ws.apache.org/ns/synapse" name="prototypesequence">
   <header name="To" action="remove"></header>
   <header name="CustomHeader" scope="transport" value="test123"></header>
   <property name="RESPONSE" value="true"></property>
   <property name="NO_ENTITY_BODY" action="remove" scope="axis2"></property>
   <payloadFactory media-type="json">
      <format>               {"id":"101","name": "dumiduh","desc": "hard coded json"}            </format>
   </payloadFactory>
   <class name="org.wso2.carbon.apimgt.usage.publisher.APIMgtResponseHandler"/>
   <respond></respond>
</sequence>

The example above is using a hardcoded response body and headers, you could also populate the response with variables as required [3]. Find the example mediation policy here [4].

2) Attach Mediation Policy to API in Flow

Start creating an API with required HTTP methods etc, select Manage API from implementation and from Message Mediation Policies section upload the prototype mediation policy. Publish the API.

Image title

3) Invoke

Invoke the API as you would any other managed API [5].

[1] - https://docs.wso2.com/display/ESB490/Respond+Mediator
[2] - https://docs.wso2.com/display/ESB490/PayloadFactory+Mediator
[3] -https://docs.wso2.com/display/ESB490/PayloadFactory+Mediator#PayloadFactoryMediator-Example3:Addingarguments
[4] -  https://drive.google.com/file/d/0B9oVIeyHJKBXb0xkTGUwSmlJc0E/view?usp=sharing
[5] - https://docs.wso2.com/display/AM1100/Quick+Start+Guide

API

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Autowiring in Spring
  • How to Generate Fake Test Data
  • 5 Steps to Strengthen API Security
  • ETL, ELT, and Reverse ETL

Comments

Integration Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • MVB Program
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends:

DZone.com is powered by 

AnswerHub logo