View TcpConnectionAsAPI.xml
<api xmlns="http://ws.apache.org/ns/synapse" name="TcpConnectionAsAPI" context="/tcp">
<resource methods="POST GET" url-mapping="/connection">
<inSequence>
<script language="groovy">def myValue='value';def socket = new Socket('localhost', 4444); myValue = socket.withStreams { input, output -&gt; buffer = input.newReader().readLine(); return buffer;}; mc.setProperty('ValueInGroovyScript',myValue);</script>
<log>
<property name="Value from TCP Server" expression="$ctx:ValueInGroovyScript" />
</log>
<script language="js">var resp = String(mc.getProperty("ValueInGroovyScript")).split(','); var payloadXML = new XML(&lt;response/&gt;); var resp = String(mc.getProperty("ValueInGroovyScript")).split(','); payloadXML.appendChild(new XML(&lt;resp&gt;{resp[0]}&lt;/resp&gt;)); payloadXML.appendChild(new XML(&lt;company&gt;{resp[1]}&lt;/company&gt;)); payloadXML.appendChild(new XML(&lt;itemnbr&gt;{resp[2]}&lt;/i
View MockServer.py
# Copyright 2017 Vanji
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
View _auth_failure_handler_.xml
<sequence name="_auth_failure_handler_" xmlns="http://ws.apache.org/ns/synapse">
<switch source="$trp:Accept">
<case regex="application/json">
<property name="error_message_type" value="application/json"/>
</case>
<default>
<property name="error_message_type" value="application/xml"/>
</default>
</switch>
<sequence key="_build_"/>
View blockchainID.txt
Verifying that +vanjikumaran is my blockchain ID. https://onename.com/vanjikumaran
View NxNPattern.java
import java.lang.Math;
public class NxNPattern
{
public static void main(String[] args)
{
for (int i = 0, j = 0; i < 49; i++) {
if (i % 7 == 0) {
if (j > 0) System.out.println();
j++;
View RecursiveValueFetch
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="RecursiveValueFetch"
transports="https,http"
statistics="disable"
trace="disable"
startOnLoad="true">
<target>
<inSequence>
<property name="Key" value="Location" scope="default" type="STRING"/>
View SynapseConfigSimpleServiceChaining
<api xmlns="http://ws.apache.org/ns/synapse" name="TestApi" context="/TestContext">
<resource methods="POST GET">
<inSequence>
<log level="custom">
<property name="Message Flow" value="Roovershof Plant Search API - IN"></property>
<property name="HTTP_METHOD IS###########" expression="$axis2:HTTP_METHOD"></property>
<property name="ip address" expression="get-property('axis2','REMOTE_ADDR')"></property>
<property name="Authorization" expression="get-property('transport','Authorization')"></property>
</log>
<property name="TIME_IN" expression="get-property('SYSTEM_TIME')" scope="default" type="LONG"></property>
View gist:c7574441327e4927ed5a
<api xmlns="http://ws.apache.org/ns/synapse" name="strip" context="/strip">
<resource methods="POST GET">
<inSequence>
<header name="Authorization" scope="transport" value="Bearer XXXXXXXXXXXXXXXXXXXXX"></header>
<property name="uri.var.chargeId" expression="json-eval($.chargeId)" scope="default" type="STRING"></property>
<payloadFactory media-type="json">
<format></format>
<args></args>
</payloadFactory>
<property name="ContentType" value="application/x-www-form-urlencoded" scope="axis2"></property>
View deleteObjects
<script>
var text = '{"invideoPromotion":{"items":[{"id":{"type":"video","videoId":"11","websiteUrl":""},"timing":{"type":"ms","offsetMs":"2222"},"customMessage":"aa","promotedByContentOwner":"vanji"}]}}'
var obj = JSON.parse(text);
document.writeln(JSON.stringify(obj));
for (var i = 0; i < obj.invideoPromotion.items.length; i++) {
if (obj.invideoPromotion.items[i].id.type == 'video') {
if (obj.invideoPromotion.items[i].id.websiteUrl == '') {
delete obj.invideoPromotion.items[i].id.websiteUrl;
}
View GetHeaderDetail
<sequence xmlns="http://ws.apache.org/ns/synapse" name="main">
<in>
<filter xmlns:ns="http://org.apache.synapse/xsd" source="get-property('To')" regex=".*/StockQuote.*">
<then>
<send>
<endpoint>
<address uri="http://localhost:9000/services/SimpleStockQuoteService"></address>
</endpoint>
</send>
</then>