Read system property using proxy service deployed in WSO2 ESB

Here i have added sample synapse configuration to get carbon server home property and return it as response. Add this configuration and invoke proxy service. You will get carbon.home as response.




<proxy name="EchoProxyTest"
          transports="https http"
          startOnLoad="true"
          trace="disable">
      <description/>
      <target>
         <inSequence>
            <sequence key="responseTest1"/>
         </inSequence>
         <outSequence>
            <send/>
         </outSequence>
      </target>
   </proxy>
 <sequence name="responseTest1">
      <script language="js">var carbonHome = java.lang.System.getProperty("carbon.home");
      mc.setPayloadXML(&lt;serverHome&gt;{carbonHome}&lt;/serverHome&gt;);</script>
      <header name="To" action="remove"/>
      <property name="NO_ENTITY_BODY" scope="axis2" action="remove"/>
      <property name="RESPONSE" value="true"/>
      <send/>
      <log level="full"/>
   </sequence>

How to write sample class mediator to get system property and inject to synapse properties / How to generate response with synapse property using script mediator

Here i have added class mediator code and sample synapse configuration to get carbon server home property. To test this create java project and add following class mediator code file to /repository/components/lib directory and add following synapse configuration to source view.  Then you can invoke created proxy service.

Class mediator code.

package main.java.org.wso2.carbon.custommediator;
import org.apache.synapse.MessageContext;
import org.apache.synapse.core.axis2.Axis2MessageContext;
import org.apache.synapse.mediators.AbstractMediator;
public class SampleCustomMediator extends AbstractMediator {

public boolean mediate(MessageContext synapseMsgContext) {
    String carbonHome = System.getProperty("carbon.home");
    log.info("Carbon Home is : "+carbonHome);
    synapseMsgContext.setProperty("CARBON_HOME", carbonHome);
    return true;
 }
 


Synapse configuration.

 
<proxy name="EchoProxyTest"
          transports="https http"
          startOnLoad="true"
          trace="disable">
  <target>
   <inSequence>
     <class name="main.java.org.wso2.carbon.custommediator.SampleCustomMediator"/>
     <sequence key="responseTest"/>
   </inSequence>
   <outSequence>
      <send/>
   </outSequence>
 </target>
</proxy>
<sequence name="responseTest">
      <script language="js">var carbonHome = mc.getProperty("CARBON_HOME");
      var carbonHomeTest = "sanjeewa";
      mc.setPayloadXML(&lt;serverHome&gt;{carbonHome}&lt;/serverHome&gt;);</script>
      <header name="To" action="remove"/>
      <property name="NO_ENTITY_BODY" scope="axis2" action="remove"/>
      <property name="RESPONSE" value="true"/>
      <send/>
      <log level="full"/>
</sequence>



You can invoke create proxy service by calling following URL
https://130.76.202.98:9443/services/EchoProxyTest

Then you will get following response.
 
<serverHome>/home/sanjeewa/work/packs/wso2esb-4.8.0</serverHome>

WSO2 API Manager - Basic user operations curl command( How to do basic operations using curl commands)

Here in this post i will list out curl commands that required to cover complete API Manager (basic) use case. Here we will do fallowing operations. Here we need to login API Manager publisher and store multiple times. Here user will be tenant user(ttt@ttt.ttt). if need change any parameter.

1) Create APIs
2) Publish APIs
3) Create application
4) Subscribe to APIs for that application
5) Remove subscriptions
6) Remove application
7) Remove APIs

API Publisher
=============
curl -X POST -c cookies http://localhost:9763/publisher/site/blocks/user/login/ajax/login.jag -d 'action=login&username=ttt@ttt.ttt&password=tttttt'

1) Create APIs
curl -X POST -b cookies http://localhost:9763/publisher/site/blocks/item-add/ajax/add.jag -d "action=addAPI&name=sanjeewa-api&context=/sanjeewa-api&version=1.0.0&tier=Bronze&tier=Gold&transports=http&http_checked=http&transports=https&https_checked=https&description=sanjeewa-api&visibility=public API&tags=sanjeewa-api,api&resourceCount=0&resourceMethod-0=GET,PUT,POST,DELETE,OPTIONS&resourceMethodAuthType-0=Application & Application User,Application & Application User,Application & Application User,Application & Application User,None&uriTemplate-0=/*&resourceMethodThrottlingTier-0=Unlimited, Unlimited, Unlimited, Unlimited, Unlimited&tiersCollection=Bronze,Gold,Silver,Unlimited" -d 'endpoint_config={"production_endpoints":{"url":"http://search.twitter.com","config":null},"endpoint_type":"http"}'

2) Publish APIs
curl -X POST -b cookies 'http://localhost:9763/publisher/site/blocks/life-cycles/ajax/life-cycles.jag' -d 'action=updateStatus&name=sanjeewa-api&version=1.0.0&provider=ttt@ttt.ttt&status=PUBLISHED&publishToGateway=true&requireResubscription=true'

API Store
=========
curl -X POST -c cookies http://localhost:9763/store/site/blocks/user/login/ajax/login.jag -d 'action=login&username=ttt@ttt.ttt&password=tttttt'

3) Create application
curl -X POST -b cookies http://localhost:9763/store/site/blocks/application/application-add/ajax/application-add.jag -d 'action=addApplication&application=sanjeewa-application&tier=unlimited&description=&callbackUrl='

4) Subscribe to APIs for that application
curl -b cookies http://localhost:9763/store/site/blocks/application/application-list/ajax/application-list.jag?action=getApplications
Got app id for sanjeewa-application each time and used it for further calls.

curl -X POST -b cookies http://localhost:9763/store/site/blocks/subscription/subscription-add/ajax/subscription-add.jag -d 'action=addSubscription&name=sanjeewa-api&version=1.0.0&provider=ttt@ttt.ttt&tier=Unlimited&applicationId=7'

5) Remove subscriptions
curl -X POST -b cookies http://localhost:9763/store/site/blocks/subscription/subscription-remove/ajax/subscription-remove.jag -d 'action=removeSubscription&name=sanjeewa-api&version=1.0.0&provider=ttt@ttt.ttt&applicationId=7'

6) Remove application
curl -X POST -b cookies http://localhost:9763/store/site/blocks/application/application-remove/ajax/application-remove.jag -d "action=removeApplication&application=sanjeewa-application"

API Publisher
=============
curl -X POST -c cookies http://localhost:9763/publisher/site/blocks/user/login/ajax/login.jag -d 'action=login&username=ttt@ttt.ttt&password=tttttt'
7) Remove APIs
curl -X POST -b cookies http://localhost:9763/publisher/site/blocks/item-add/ajax/remove.jag -d "action=removeAPI&name=sanjeewa-api&version=1.0.0&provider=ttt@ttt.ttt"

Empowering the Future of API Management: Unveiling the Journey of WSO2 API Platform for Kubernetes (APK) Project and the Anticipated Alpha Release

  Introduction In the ever-evolving realm of API management, our journey embarked on the APK project eight months ago, and now, with great a...