Sunday, January 28, 2018

WSO2 ESB - Sample Class Mediator

In WSO2 ESB / EI when we want to write our own logic of mediation, class mediators are very helpful.

A class mediator can be written by extending AbstractMediator

Following is a sample class mediator which simply logs a sting message (Doesn't actually do any mediation)

This source can be used as a template to start a class mediator quickly

public class SampleClassMediator extends AbstractMediator {

    private static final Log log = LogFactory.getLog(SampleClassMediator.class);

    public boolean mediate(MessageContext messageContext) {
        log.info("This is a sample class mediator");
        return true;
    }
}

Full project can be found in  https://github.com/bsenduran/sample-class-mediator/tree/v1.0



Monday, January 8, 2018

Invoking a SOAP back-end with apache ab

Following is a sample request to invoke a soap backend using apache ab


ab -n 10 -c 5 -p req.xml -T "text/xml" -H "soapAction:getSimpleQuote" http://localhost:9000/services/SimpleStockQuoteService

Here
-n : number of requests
-c : number of concurrent requests
-p : post request payload file
-T : content type
-H: custom header

req.xml

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
   <soapenv:Header/>
   <soapenv:Body>
      <ser:getSimpleQuote xmlns:ser="http://services.samples">
         <ser:symbol>ABC</ser:symbol>
      </ser:getSimpleQuote>
   </soapenv:Body>
</soapenv:Envelope>