Script mediator is helpful in many ways and it can be written in different scripting languages such as JavaScript, Groovy and Ruby.
I'm going to use JavaScript for this example. I'm trying to show you the way that you can use to log some values when you are writing a mediator. This will be helpful when you need to log values when you are writing a complex script mediators.
This is a sample script
This is a sample proxy service
I'm going to use JavaScript for this example. I'm trying to show you the way that you can use to log some values when you are writing a mediator. This will be helpful when you need to log values when you are writing a complex script mediators.
This is a sample script
<script language="js">
var log = mc.getServiceLog();
log.info("started"); var temp_auth = mc.getProperty('authheader'); log.info("temp_auth : " + temp_auth); log.info("out");</script>
When you define a "var log = mc.getServiceLog();" variable, you can use log object to display values as below.
log.info("started");
log.info("temp_auth : " + temp_auth);
This is a sample proxy service
<?xml version="1.0" encoding="UTF-8"?> <proxy xmlns="http://ws.apache.org/ns/synapse" name="sampleScriptMediator3" transports="https,http" statistics="disable" trace="disable" startOnLoad="true"> <target> <inSequence> <property name="authheader" expression="get-property('transport','Authorization')"/> <log level="full"/> <script language="js">var log = mc.getServiceLog();log.info("started"); var temp_auth = mc.getProperty('authheader'); log.info("temp_auth : " + temp_auth); log.info("out");</script> </inSequence> </target> <description/> </proxy>
You can send a request to proxy service using Fire fox RESTClient. you can install RESTClient using this link[1]
Before you send the request, you have to add an Authorization header by clicking a headers clink as below
Then you can access Authorization headers inside the proxy service.
[1] https://addons.mozilla.org/en-US/firefox/addon/restclient/
Comments
Post a Comment