You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by sm...@apache.org on 2015/03/18 19:07:34 UTC

[3/4] airavata-sandbox git commit: adding PHP client for multiplexing AIRAVATA-1632

http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/165a5113/airavata-mock-multiplexed-api/mock-airavata-api-php-stubs/src/main/resources/lib/Thrift/Factory/TBinaryProtocolFactory.php
----------------------------------------------------------------------
diff --git a/airavata-mock-multiplexed-api/mock-airavata-api-php-stubs/src/main/resources/lib/Thrift/Factory/TBinaryProtocolFactory.php b/airavata-mock-multiplexed-api/mock-airavata-api-php-stubs/src/main/resources/lib/Thrift/Factory/TBinaryProtocolFactory.php
new file mode 100755
index 0000000..0c1c4a7
--- /dev/null
+++ b/airavata-mock-multiplexed-api/mock-airavata-api-php-stubs/src/main/resources/lib/Thrift/Factory/TBinaryProtocolFactory.php
@@ -0,0 +1,45 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ * @package thrift.protocol
+ */
+
+namespace Thrift\Factory;
+
+use Thrift\Protocol\TBinaryProtocol;
+
+/**
+ * Binary Protocol Factory
+ */
+class TBinaryProtocolFactory implements TProtocolFactory
+{
+  private $strictRead_ = false;
+  private $strictWrite_ = false;
+
+  public function __construct($strictRead=false, $strictWrite=false)
+  {
+    $this->strictRead_ = $strictRead;
+    $this->strictWrite_ = $strictWrite;
+  }
+
+  public function getProtocol($trans)
+  {
+    return new TBinaryProtocol($trans, $this->strictRead_, $this->strictWrite_);
+  }
+}

http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/165a5113/airavata-mock-multiplexed-api/mock-airavata-api-php-stubs/src/main/resources/lib/Thrift/Factory/TCompactProtocolFactory.php
----------------------------------------------------------------------
diff --git a/airavata-mock-multiplexed-api/mock-airavata-api-php-stubs/src/main/resources/lib/Thrift/Factory/TCompactProtocolFactory.php b/airavata-mock-multiplexed-api/mock-airavata-api-php-stubs/src/main/resources/lib/Thrift/Factory/TCompactProtocolFactory.php
new file mode 100755
index 0000000..f4b4fe3
--- /dev/null
+++ b/airavata-mock-multiplexed-api/mock-airavata-api-php-stubs/src/main/resources/lib/Thrift/Factory/TCompactProtocolFactory.php
@@ -0,0 +1,40 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ * @package thrift.protocol
+ */
+
+namespace Thrift\Factory;
+
+use Thrift\Protocol\TCompactProtocol;
+
+/**
+ * Compact Protocol Factory
+ */
+class TCompactProtocolFactory implements TProtocolFactory
+{
+  public function __construct()
+  {
+  }
+
+  public function getProtocol($trans)
+  {
+    return new TCompactProtocol($trans);
+  }
+}

http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/165a5113/airavata-mock-multiplexed-api/mock-airavata-api-php-stubs/src/main/resources/lib/Thrift/Factory/TJSONProtocolFactory.php
----------------------------------------------------------------------
diff --git a/airavata-mock-multiplexed-api/mock-airavata-api-php-stubs/src/main/resources/lib/Thrift/Factory/TJSONProtocolFactory.php b/airavata-mock-multiplexed-api/mock-airavata-api-php-stubs/src/main/resources/lib/Thrift/Factory/TJSONProtocolFactory.php
new file mode 100755
index 0000000..fbfb1d7
--- /dev/null
+++ b/airavata-mock-multiplexed-api/mock-airavata-api-php-stubs/src/main/resources/lib/Thrift/Factory/TJSONProtocolFactory.php
@@ -0,0 +1,40 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ * @package thrift.protocol
+ */
+
+namespace Thrift\Factory;
+
+use Thrift\Protocol\TJSONProtocol;
+
+/**
+ * JSON Protocol Factory
+ */
+class TJSONProtocolFactory implements TProtocolFactory
+{
+    public function __construct()
+    {
+    }
+
+    public function getProtocol($trans)
+    {
+        return new TJSONProtocol($trans);
+    }
+}

http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/165a5113/airavata-mock-multiplexed-api/mock-airavata-api-php-stubs/src/main/resources/lib/Thrift/Factory/TProtocolFactory.php
----------------------------------------------------------------------
diff --git a/airavata-mock-multiplexed-api/mock-airavata-api-php-stubs/src/main/resources/lib/Thrift/Factory/TProtocolFactory.php b/airavata-mock-multiplexed-api/mock-airavata-api-php-stubs/src/main/resources/lib/Thrift/Factory/TProtocolFactory.php
new file mode 100755
index 0000000..4c9562d
--- /dev/null
+++ b/airavata-mock-multiplexed-api/mock-airavata-api-php-stubs/src/main/resources/lib/Thrift/Factory/TProtocolFactory.php
@@ -0,0 +1,36 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ * @package thrift.protocol
+ */
+
+namespace Thrift\Factory;
+
+/**
+ * Protocol factory creates protocol objects from transports
+ */
+interface TProtocolFactory
+{
+  /**
+   * Build a protocol from the base transport
+   *
+   * @return Thrift\Protocol\TProtocol protocol
+   */
+  public function getProtocol($trans);
+}

http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/165a5113/airavata-mock-multiplexed-api/mock-airavata-api-php-stubs/src/main/resources/lib/Thrift/Factory/TStringFuncFactory.php
----------------------------------------------------------------------
diff --git a/airavata-mock-multiplexed-api/mock-airavata-api-php-stubs/src/main/resources/lib/Thrift/Factory/TStringFuncFactory.php b/airavata-mock-multiplexed-api/mock-airavata-api-php-stubs/src/main/resources/lib/Thrift/Factory/TStringFuncFactory.php
new file mode 100755
index 0000000..6ad6839
--- /dev/null
+++ b/airavata-mock-multiplexed-api/mock-airavata-api-php-stubs/src/main/resources/lib/Thrift/Factory/TStringFuncFactory.php
@@ -0,0 +1,66 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+namespace Thrift\Factory;
+
+use Thrift\StringFunc\Mbstring;
+use Thrift\StringFunc\Core;
+
+class TStringFuncFactory
+{
+    private static $_instance;
+
+    /**
+     * Get the Singleton instance of TStringFunc implementation that is
+     * compatible with the current system's mbstring.func_overload settings.
+     *
+     * @return TStringFunc
+     */
+    public static function create()
+    {
+        if (!self::$_instance) {
+            self::_setInstance();
+        }
+
+        return self::$_instance;
+    }
+
+    private static function _setInstance()
+    {
+        /**
+         * Cannot use str* functions for byte counting because multibyte
+         * characters will be read a single bytes.
+         *
+         * See: http://us.php.net/manual/en/mbstring.overload.php
+         */
+        if (ini_get('mbstring.func_overload') & 2) {
+            self::$_instance = new Mbstring();
+        }
+        /**
+         * mbstring is not installed or does not have function overloading
+         * of the str* functions enabled so use PHP core str* functions for
+         * byte counting.
+         */
+        else {
+            self::$_instance = new Core();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/165a5113/airavata-mock-multiplexed-api/mock-airavata-api-php-stubs/src/main/resources/lib/Thrift/Factory/TTransportFactory.php
----------------------------------------------------------------------
diff --git a/airavata-mock-multiplexed-api/mock-airavata-api-php-stubs/src/main/resources/lib/Thrift/Factory/TTransportFactory.php b/airavata-mock-multiplexed-api/mock-airavata-api-php-stubs/src/main/resources/lib/Thrift/Factory/TTransportFactory.php
new file mode 100755
index 0000000..b32b5f4
--- /dev/null
+++ b/airavata-mock-multiplexed-api/mock-airavata-api-php-stubs/src/main/resources/lib/Thrift/Factory/TTransportFactory.php
@@ -0,0 +1,18 @@
+<?php
+
+namespace Thrift\Factory;
+
+use Thrift\Transport\TTransport;
+
+class TTransportFactory
+{
+  /**
+   * @static
+   * @param TTransport $transport
+   * @return TTransport
+   */
+  public static function getTransport(TTransport $transport)
+  {
+    return $transport;
+  }
+}

http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/165a5113/airavata-mock-multiplexed-api/mock-airavata-api-php-stubs/src/main/resources/lib/Thrift/Protocol/JSON/BaseContext.php
----------------------------------------------------------------------
diff --git a/airavata-mock-multiplexed-api/mock-airavata-api-php-stubs/src/main/resources/lib/Thrift/Protocol/JSON/BaseContext.php b/airavata-mock-multiplexed-api/mock-airavata-api-php-stubs/src/main/resources/lib/Thrift/Protocol/JSON/BaseContext.php
new file mode 100755
index 0000000..31bcb48
--- /dev/null
+++ b/airavata-mock-multiplexed-api/mock-airavata-api-php-stubs/src/main/resources/lib/Thrift/Protocol/JSON/BaseContext.php
@@ -0,0 +1,39 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ * @package thrift.protocol
+ */
+
+namespace Thrift\Protocol\JSON;
+
+class BaseContext
+{
+    public function escapeNum()
+    {
+        return false;
+    }
+
+    public function write()
+    {
+    }
+
+    public function read()
+    {
+    }
+}

http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/165a5113/airavata-mock-multiplexed-api/mock-airavata-api-php-stubs/src/main/resources/lib/Thrift/Protocol/JSON/ListContext.php
----------------------------------------------------------------------
diff --git a/airavata-mock-multiplexed-api/mock-airavata-api-php-stubs/src/main/resources/lib/Thrift/Protocol/JSON/ListContext.php b/airavata-mock-multiplexed-api/mock-airavata-api-php-stubs/src/main/resources/lib/Thrift/Protocol/JSON/ListContext.php
new file mode 100755
index 0000000..eef6594
--- /dev/null
+++ b/airavata-mock-multiplexed-api/mock-airavata-api-php-stubs/src/main/resources/lib/Thrift/Protocol/JSON/ListContext.php
@@ -0,0 +1,54 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ * @package thrift.protocol
+ */
+
+namespace Thrift\Protocol\JSON;
+
+use Thrift\Protocol\TJSONProtocol;
+
+class ListContext extends BaseContext
+{
+    private $first_ = true;
+    private $p_;
+
+    public function __construct($p)
+    {
+        $this->p_ = $p;
+    }
+
+    public function write()
+    {
+        if ($this->first_) {
+            $this->first_ = false;
+        } else {
+            $this->p_->getTransport()->write(TJSONProtocol::COMMA);
+        }
+    }
+
+    public function read()
+    {
+        if ($this->first_) {
+            $this->first_ = false;
+        } else {
+            $this->p_->readJSONSyntaxChar(TJSONProtocol::COMMA);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/165a5113/airavata-mock-multiplexed-api/mock-airavata-api-php-stubs/src/main/resources/lib/Thrift/Protocol/JSON/LookaheadReader.php
----------------------------------------------------------------------
diff --git a/airavata-mock-multiplexed-api/mock-airavata-api-php-stubs/src/main/resources/lib/Thrift/Protocol/JSON/LookaheadReader.php b/airavata-mock-multiplexed-api/mock-airavata-api-php-stubs/src/main/resources/lib/Thrift/Protocol/JSON/LookaheadReader.php
new file mode 100755
index 0000000..0b18c40
--- /dev/null
+++ b/airavata-mock-multiplexed-api/mock-airavata-api-php-stubs/src/main/resources/lib/Thrift/Protocol/JSON/LookaheadReader.php
@@ -0,0 +1,57 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ * @package thrift.protocol
+ */
+
+namespace Thrift\Protocol\JSON;
+
+class LookaheadReader
+{
+    private $hasData_ = false;
+    private $data_ = array();
+    private $p_;
+
+    public function __construct($p)
+    {
+        $this->p_ = $p;
+    }
+
+    public function read()
+    {
+        if ($this->hasData_) {
+            $this->hasData_ = false;
+        } else {
+            $this->data_ = $this->p_->getTransport()->readAll(1);
+        }
+
+        return substr($this->data_, 0, 1);
+    }
+
+    public function peek()
+    {
+        if (!$this->hasData_) {
+            $this->data_ = $this->p_->getTransport()->readAll(1);
+        }
+
+        $this->hasData_ = true;
+
+        return substr($this->data_, 0, 1);
+    }
+}

http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/165a5113/airavata-mock-multiplexed-api/mock-airavata-api-php-stubs/src/main/resources/lib/Thrift/Protocol/JSON/PairContext.php
----------------------------------------------------------------------
diff --git a/airavata-mock-multiplexed-api/mock-airavata-api-php-stubs/src/main/resources/lib/Thrift/Protocol/JSON/PairContext.php b/airavata-mock-multiplexed-api/mock-airavata-api-php-stubs/src/main/resources/lib/Thrift/Protocol/JSON/PairContext.php
new file mode 100755
index 0000000..7b353c4
--- /dev/null
+++ b/airavata-mock-multiplexed-api/mock-airavata-api-php-stubs/src/main/resources/lib/Thrift/Protocol/JSON/PairContext.php
@@ -0,0 +1,64 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ * @package thrift.protocol
+ */
+
+namespace Thrift\Protocol\JSON;
+
+use Thrift\Protocol\TJSONProtocol;
+
+class PairContext extends BaseContext
+{
+    private $first_ = true;
+    private $colon_ = true;
+    private $p_ = null;
+
+    public function __construct($p)
+    {
+        $this->p_ = $p;
+    }
+
+    public function write()
+    {
+        if ($this->first_) {
+            $this->first_ = false;
+            $this->colon_ = true;
+        } else {
+            $this->p_->getTransport()->write($this->colon_ ? TJSONProtocol::COLON : TJSONProtocol::COMMA);
+            $this->colon_ = !$this->colon_;
+        }
+    }
+
+    public function read()
+    {
+        if ($this->first_) {
+            $this->first_ = false;
+            $this->colon_ = true;
+        } else {
+            $this->p_->readJSONSyntaxChar($this->colon_ ? TJSONProtocol::COLON : TJSONProtocol::COMMA);
+            $this->colon_ = !$this->colon_;
+        }
+    }
+
+    public function escapeNum()
+    {
+        return $this->colon_;
+    }
+}

http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/165a5113/airavata-mock-multiplexed-api/mock-airavata-api-php-stubs/src/main/resources/lib/Thrift/Protocol/TBinaryProtocol.php
----------------------------------------------------------------------
diff --git a/airavata-mock-multiplexed-api/mock-airavata-api-php-stubs/src/main/resources/lib/Thrift/Protocol/TBinaryProtocol.php b/airavata-mock-multiplexed-api/mock-airavata-api-php-stubs/src/main/resources/lib/Thrift/Protocol/TBinaryProtocol.php
new file mode 100755
index 0000000..fe6a103
--- /dev/null
+++ b/airavata-mock-multiplexed-api/mock-airavata-api-php-stubs/src/main/resources/lib/Thrift/Protocol/TBinaryProtocol.php
@@ -0,0 +1,453 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ * @package thrift.protocol
+ */
+
+namespace Thrift\Protocol;
+
+use Thrift\Type\TType;
+use Thrift\Exception\TProtocolException;
+use Thrift\Factory\TStringFuncFactory;
+
+/**
+ * Binary implementation of the Thrift protocol.
+ *
+ */
+class TBinaryProtocol extends TProtocol
+{
+  const VERSION_MASK = 0xffff0000;
+  const VERSION_1 = 0x80010000;
+
+  protected $strictRead_ = false;
+  protected $strictWrite_ = true;
+
+  public function __construct($trans, $strictRead=false, $strictWrite=true)
+  {
+    parent::__construct($trans);
+    $this->strictRead_ = $strictRead;
+    $this->strictWrite_ = $strictWrite;
+  }
+
+  public function writeMessageBegin($name, $type, $seqid)
+  {
+    if ($this->strictWrite_) {
+      $version = self::VERSION_1 | $type;
+
+      return
+        $this->writeI32($version) +
+        $this->writeString($name) +
+        $this->writeI32($seqid);
+    } else {
+      return
+        $this->writeString($name) +
+        $this->writeByte($type) +
+        $this->writeI32($seqid);
+    }
+  }
+
+  public function writeMessageEnd()
+  {
+    return 0;
+  }
+
+  public function writeStructBegin($name)
+  {
+    return 0;
+  }
+
+  public function writeStructEnd()
+  {
+    return 0;
+  }
+
+  public function writeFieldBegin($fieldName, $fieldType, $fieldId)
+  {
+    return
+      $this->writeByte($fieldType) +
+      $this->writeI16($fieldId);
+  }
+
+  public function writeFieldEnd()
+  {
+    return 0;
+  }
+
+  public function writeFieldStop()
+  {
+    return
+      $this->writeByte(TType::STOP);
+  }
+
+  public function writeMapBegin($keyType, $valType, $size)
+  {
+    return
+      $this->writeByte($keyType) +
+      $this->writeByte($valType) +
+      $this->writeI32($size);
+  }
+
+  public function writeMapEnd()
+  {
+    return 0;
+  }
+
+  public function writeListBegin($elemType, $size)
+  {
+    return
+      $this->writeByte($elemType) +
+      $this->writeI32($size);
+  }
+
+  public function writeListEnd()
+  {
+    return 0;
+  }
+
+  public function writeSetBegin($elemType, $size)
+  {
+    return
+      $this->writeByte($elemType) +
+      $this->writeI32($size);
+  }
+
+  public function writeSetEnd()
+  {
+    return 0;
+  }
+
+  public function writeBool($value)
+  {
+    $data = pack('c', $value ? 1 : 0);
+    $this->trans_->write($data, 1);
+
+    return 1;
+  }
+
+  public function writeByte($value)
+  {
+    $data = pack('c', $value);
+    $this->trans_->write($data, 1);
+
+    return 1;
+  }
+
+  public function writeI16($value)
+  {
+    $data = pack('n', $value);
+    $this->trans_->write($data, 2);
+
+    return 2;
+  }
+
+  public function writeI32($value)
+  {
+    $data = pack('N', $value);
+    $this->trans_->write($data, 4);
+
+    return 4;
+  }
+
+  public function writeI64($value)
+  {
+    // If we are on a 32bit architecture we have to explicitly deal with
+    // 64-bit twos-complement arithmetic since PHP wants to treat all ints
+    // as signed and any int over 2^31 - 1 as a float
+    if (PHP_INT_SIZE == 4) {
+      $neg = $value < 0;
+
+      if ($neg) {
+        $value *= -1;
+      }
+
+      $hi = (int) ($value / 4294967296);
+      $lo = (int) $value;
+
+      if ($neg) {
+        $hi = ~$hi;
+        $lo = ~$lo;
+        if (($lo & (int) 0xffffffff) == (int) 0xffffffff) {
+          $lo = 0;
+          $hi++;
+        } else {
+          $lo++;
+        }
+      }
+      $data = pack('N2', $hi, $lo);
+
+    } else {
+      $hi = $value >> 32;
+      $lo = $value & 0xFFFFFFFF;
+      $data = pack('N2', $hi, $lo);
+    }
+
+    $this->trans_->write($data, 8);
+
+    return 8;
+  }
+
+  public function writeDouble($value)
+  {
+    $data = pack('d', $value);
+    $this->trans_->write(strrev($data), 8);
+
+    return 8;
+  }
+
+  public function writeString($value)
+  {
+    $len = TStringFuncFactory::create()->strlen($value);
+    $result = $this->writeI32($len);
+    if ($len) {
+      $this->trans_->write($value, $len);
+    }
+
+    return $result + $len;
+  }
+
+  public function readMessageBegin(&$name, &$type, &$seqid)
+  {
+    $result = $this->readI32($sz);
+    if ($sz < 0) {
+      $version = (int) ($sz & self::VERSION_MASK);
+      if ($version != (int) self::VERSION_1) {
+        throw new TProtocolException('Bad version identifier: '.$sz, TProtocolException::BAD_VERSION);
+      }
+      $type = $sz & 0x000000ff;
+      $result +=
+        $this->readString($name) +
+        $this->readI32($seqid);
+    } else {
+      if ($this->strictRead_) {
+        throw new TProtocolException('No version identifier, old protocol client?', TProtocolException::BAD_VERSION);
+      } else {
+        // Handle pre-versioned input
+        $name = $this->trans_->readAll($sz);
+        $result +=
+          $sz +
+          $this->readByte($type) +
+          $this->readI32($seqid);
+      }
+    }
+
+    return $result;
+  }
+
+  public function readMessageEnd()
+  {
+    return 0;
+  }
+
+  public function readStructBegin(&$name)
+  {
+    $name = '';
+
+    return 0;
+  }
+
+  public function readStructEnd()
+  {
+    return 0;
+  }
+
+  public function readFieldBegin(&$name, &$fieldType, &$fieldId)
+  {
+    $result = $this->readByte($fieldType);
+    if ($fieldType == TType::STOP) {
+      $fieldId = 0;
+
+      return $result;
+    }
+    $result += $this->readI16($fieldId);
+
+    return $result;
+  }
+
+  public function readFieldEnd()
+  {
+    return 0;
+  }
+
+  public function readMapBegin(&$keyType, &$valType, &$size)
+  {
+    return
+      $this->readByte($keyType) +
+      $this->readByte($valType) +
+      $this->readI32($size);
+  }
+
+  public function readMapEnd()
+  {
+    return 0;
+  }
+
+  public function readListBegin(&$elemType, &$size)
+  {
+    return
+      $this->readByte($elemType) +
+      $this->readI32($size);
+  }
+
+  public function readListEnd()
+  {
+    return 0;
+  }
+
+  public function readSetBegin(&$elemType, &$size)
+  {
+    return
+      $this->readByte($elemType) +
+      $this->readI32($size);
+  }
+
+  public function readSetEnd()
+  {
+    return 0;
+  }
+
+  public function readBool(&$value)
+  {
+    $data = $this->trans_->readAll(1);
+    $arr = unpack('c', $data);
+    $value = $arr[1] == 1;
+
+    return 1;
+  }
+
+  public function readByte(&$value)
+  {
+    $data = $this->trans_->readAll(1);
+    $arr = unpack('c', $data);
+    $value = $arr[1];
+
+    return 1;
+  }
+
+  public function readI16(&$value)
+  {
+    $data = $this->trans_->readAll(2);
+    $arr = unpack('n', $data);
+    $value = $arr[1];
+    if ($value > 0x7fff) {
+      $value = 0 - (($value - 1) ^ 0xffff);
+    }
+
+    return 2;
+  }
+
+  public function readI32(&$value)
+  {
+    $data = $this->trans_->readAll(4);
+    $arr = unpack('N', $data);
+    $value = $arr[1];
+    if ($value > 0x7fffffff) {
+      $value = 0 - (($value - 1) ^ 0xffffffff);
+    }
+
+    return 4;
+  }
+
+  public function readI64(&$value)
+  {
+    $data = $this->trans_->readAll(8);
+
+    $arr = unpack('N2', $data);
+
+    // If we are on a 32bit architecture we have to explicitly deal with
+    // 64-bit twos-complement arithmetic since PHP wants to treat all ints
+    // as signed and any int over 2^31 - 1 as a float
+    if (PHP_INT_SIZE == 4) {
+
+      $hi = $arr[1];
+      $lo = $arr[2];
+      $isNeg = $hi  < 0;
+
+      // Check for a negative
+      if ($isNeg) {
+        $hi = ~$hi & (int) 0xffffffff;
+        $lo = ~$lo & (int) 0xffffffff;
+
+        if ($lo == (int) 0xffffffff) {
+          $hi++;
+          $lo = 0;
+        } else {
+          $lo++;
+        }
+      }
+
+      // Force 32bit words in excess of 2G to pe positive - we deal wigh sign
+      // explicitly below
+
+      if ($hi & (int) 0x80000000) {
+        $hi &= (int) 0x7fffffff;
+        $hi += 0x80000000;
+      }
+
+      if ($lo & (int) 0x80000000) {
+        $lo &= (int) 0x7fffffff;
+        $lo += 0x80000000;
+      }
+
+      $value = $hi * 4294967296 + $lo;
+
+      if ($isNeg) {
+        $value = 0 - $value;
+      }
+    } else {
+
+      // Upcast negatives in LSB bit
+      if ($arr[2] & 0x80000000) {
+        $arr[2] = $arr[2] & 0xffffffff;
+      }
+
+      // Check for a negative
+      if ($arr[1] & 0x80000000) {
+        $arr[1] = $arr[1] & 0xffffffff;
+        $arr[1] = $arr[1] ^ 0xffffffff;
+        $arr[2] = $arr[2] ^ 0xffffffff;
+        $value = 0 - $arr[1]*4294967296 - $arr[2] - 1;
+      } else {
+        $value = $arr[1]*4294967296 + $arr[2];
+      }
+    }
+
+    return 8;
+  }
+
+  public function readDouble(&$value)
+  {
+    $data = strrev($this->trans_->readAll(8));
+    $arr = unpack('d', $data);
+    $value = $arr[1];
+
+    return 8;
+  }
+
+  public function readString(&$value)
+  {
+    $result = $this->readI32($len);
+    if ($len) {
+      $value = $this->trans_->readAll($len);
+    } else {
+      $value = '';
+    }
+
+    return $result + $len;
+  }
+}

http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/165a5113/airavata-mock-multiplexed-api/mock-airavata-api-php-stubs/src/main/resources/lib/Thrift/Protocol/TBinaryProtocolAccelerated.php
----------------------------------------------------------------------
diff --git a/airavata-mock-multiplexed-api/mock-airavata-api-php-stubs/src/main/resources/lib/Thrift/Protocol/TBinaryProtocolAccelerated.php b/airavata-mock-multiplexed-api/mock-airavata-api-php-stubs/src/main/resources/lib/Thrift/Protocol/TBinaryProtocolAccelerated.php
new file mode 100755
index 0000000..f0e0bb9
--- /dev/null
+++ b/airavata-mock-multiplexed-api/mock-airavata-api-php-stubs/src/main/resources/lib/Thrift/Protocol/TBinaryProtocolAccelerated.php
@@ -0,0 +1,65 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ * @package thrift.protocol
+ */
+
+namespace Thrift\Protocol;
+
+use Thrift\Transport\TBufferedTransport;
+
+/**
+ * Accelerated binary protocol: used in conjunction with the thrift_protocol
+ * extension for faster deserialization
+ */
+class TBinaryProtocolAccelerated extends TBinaryProtocol
+{
+  public function __construct($trans, $strictRead=false, $strictWrite=true)
+  {
+    // If the transport doesn't implement putBack, wrap it in a
+    // TBufferedTransport (which does)
+
+    // NOTE (t.heintz): This is very evil to do, because the TBufferedTransport may swallow bytes, which
+    // are then never written to the underlying transport. This happens precisely when a number of bytes
+    // less than the max buffer size (512 by default) is written to the transport and then flush() is NOT
+    // called. In that case the data stays in the writeBuffer of the transport, from where it can never be
+    // accessed again (for example through read()).
+    //
+    // Since the caller of this method does not know about the wrapping transport, this creates bugs which
+    // are very difficult to find. Hence the wrapping of a transport in a buffer should be left to the
+    // calling code. An interface could used to mandate the presence of the putBack() method in the transport.
+    //
+    // I am leaving this code in nonetheless, because there may be applications depending on this behavior.
+    //
+    // @see THRIFT-1579
+
+    if (!method_exists($trans, 'putBack')) {
+      $trans = new TBufferedTransport($trans);
+    }
+    parent::__construct($trans, $strictRead, $strictWrite);
+  }
+  public function isStrictRead()
+  {
+    return $this->strictRead_;
+  }
+  public function isStrictWrite()
+  {
+    return $this->strictWrite_;
+  }
+}

http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/165a5113/airavata-mock-multiplexed-api/mock-airavata-api-php-stubs/src/main/resources/lib/Thrift/Protocol/TCompactProtocol.php
----------------------------------------------------------------------
diff --git a/airavata-mock-multiplexed-api/mock-airavata-api-php-stubs/src/main/resources/lib/Thrift/Protocol/TCompactProtocol.php b/airavata-mock-multiplexed-api/mock-airavata-api-php-stubs/src/main/resources/lib/Thrift/Protocol/TCompactProtocol.php
new file mode 100755
index 0000000..2870351
--- /dev/null
+++ b/airavata-mock-multiplexed-api/mock-airavata-api-php-stubs/src/main/resources/lib/Thrift/Protocol/TCompactProtocol.php
@@ -0,0 +1,753 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ * @package thrift.protocol
+ */
+
+namespace Thrift\Protocol;
+
+use Thrift\Type\TType;
+use Thrift\Exception\TProtocolException;
+use Thrift\Factory\TStringFuncFactory;
+
+/**
+ * Compact implementation of the Thrift protocol.
+ *
+ */
+class TCompactProtocol extends TProtocol
+{
+  const COMPACT_STOP = 0x00;
+  const COMPACT_TRUE = 0x01;
+  const COMPACT_FALSE = 0x02;
+  const COMPACT_BYTE = 0x03;
+  const COMPACT_I16 = 0x04;
+  const COMPACT_I32 = 0x05;
+  const COMPACT_I64 = 0x06;
+  const COMPACT_DOUBLE = 0x07;
+  const COMPACT_BINARY = 0x08;
+  const COMPACT_LIST = 0x09;
+  const COMPACT_SET = 0x0A;
+  const COMPACT_MAP = 0x0B;
+  const COMPACT_STRUCT = 0x0C;
+
+  const STATE_CLEAR = 0;
+  const STATE_FIELD_WRITE = 1;
+  const STATE_VALUE_WRITE = 2;
+  const STATE_CONTAINER_WRITE = 3;
+  const STATE_BOOL_WRITE = 4;
+  const STATE_FIELD_READ = 5;
+  const STATE_CONTAINER_READ = 6;
+  const STATE_VALUE_READ = 7;
+  const STATE_BOOL_READ = 8;
+
+  const VERSION_MASK = 0x1f;
+  const VERSION = 1;
+  const PROTOCOL_ID = 0x82;
+  const TYPE_MASK = 0xe0;
+  const TYPE_BITS = 0x07;
+  const TYPE_SHIFT_AMOUNT = 5;
+
+  protected static $ctypes = array(
+    TType::STOP => TCompactProtocol::COMPACT_STOP,
+    TType::BOOL => TCompactProtocol::COMPACT_TRUE, // used for collection
+    TType::BYTE => TCompactProtocol::COMPACT_BYTE,
+    TType::I16 => TCompactProtocol::COMPACT_I16,
+    TType::I32 => TCompactProtocol::COMPACT_I32,
+    TType::I64 => TCompactProtocol::COMPACT_I64,
+    TType::DOUBLE => TCompactProtocol::COMPACT_DOUBLE,
+    TType::STRING => TCompactProtocol::COMPACT_BINARY,
+    TType::STRUCT => TCompactProtocol::COMPACT_STRUCT,
+    TType::LST => TCompactProtocol::COMPACT_LIST,
+    TType::SET => TCompactProtocol::COMPACT_SET,
+    TType::MAP => TCompactProtocol::COMPACT_MAP,
+  );
+
+  protected static $ttypes = array(
+    TCompactProtocol::COMPACT_STOP => TType::STOP ,
+    TCompactProtocol::COMPACT_TRUE => TType::BOOL, // used for collection
+    TCompactProtocol::COMPACT_FALSE => TType::BOOL,
+    TCompactProtocol::COMPACT_BYTE => TType::BYTE,
+    TCompactProtocol::COMPACT_I16 => TType::I16,
+    TCompactProtocol::COMPACT_I32 => TType::I32,
+    TCompactProtocol::COMPACT_I64 => TType::I64,
+    TCompactProtocol::COMPACT_DOUBLE => TType::DOUBLE,
+    TCompactProtocol::COMPACT_BINARY => TType::STRING,
+    TCompactProtocol::COMPACT_STRUCT => TType::STRUCT,
+    TCompactProtocol::COMPACT_LIST => TType::LST,
+    TCompactProtocol::COMPACT_SET => TType::SET,
+    TCompactProtocol::COMPACT_MAP => TType::MAP,
+  );
+
+  protected $state = TCompactProtocol::STATE_CLEAR;
+  protected $lastFid = 0;
+  protected $boolFid = null;
+  protected $boolValue = null;
+  protected $structs = array();
+  protected $containers = array();
+
+  // Some varint / zigzag helper methods
+  public function toZigZag($n, $bits)
+  {
+    return ($n << 1) ^ ($n >> ($bits - 1));
+  }
+
+  public function fromZigZag($n)
+  {
+    return ($n >> 1) ^ -($n & 1);
+  }
+
+  public function getVarint($data)
+  {
+    $out = "";
+    while (true) {
+      if (($data & ~0x7f) === 0) {
+        $out .= chr($data);
+        break;
+      } else {
+        $out .= chr(($data & 0xff) | 0x80);
+        $data = $data >> 7;
+      }
+    }
+
+    return $out;
+  }
+
+  public function writeVarint($data)
+  {
+    $out = $this->getVarint($data);
+    $result = TStringFuncFactory::create()->strlen($out);
+    $this->trans_->write($out, $result);
+
+    return $result;
+  }
+
+  public function readVarint(&$result)
+  {
+    $idx = 0;
+    $shift = 0;
+    $result = 0;
+    while (true) {
+      $x = $this->trans_->readAll(1);
+      $arr = unpack('C', $x);
+      $byte = $arr[1];
+      $idx += 1;
+      $result |= ($byte & 0x7f) << $shift;
+      if (($byte >> 7) === 0) {
+        return $idx;
+      }
+      $shift += 7;
+    }
+
+    return $idx;
+  }
+
+  public function __construct($trans)
+  {
+    parent::__construct($trans);
+  }
+
+  public function writeMessageBegin($name, $type, $seqid)
+  {
+    $written =
+      $this->writeUByte(TCompactProtocol::PROTOCOL_ID) +
+      $this->writeUByte(TCompactProtocol::VERSION |
+                        ($type << TCompactProtocol::TYPE_SHIFT_AMOUNT)) +
+      $this->writeVarint($seqid) +
+      $this->writeString($name);
+    $this->state = TCompactProtocol::STATE_VALUE_WRITE;
+
+    return $written;
+  }
+
+  public function writeMessageEnd()
+  {
+    $this->state = TCompactProtocol::STATE_CLEAR;
+
+    return 0;
+  }
+
+  public function writeStructBegin($name)
+  {
+    $this->structs[] = array($this->state, $this->lastFid);
+    $this->state = TCompactProtocol::STATE_FIELD_WRITE;
+    $this->lastFid = 0;
+
+    return 0;
+  }
+
+  public function writeStructEnd()
+  {
+    $old_values = array_pop($this->structs);
+    $this->state = $old_values[0];
+    $this->lastFid = $old_values[1];
+
+    return 0;
+  }
+
+  public function writeFieldStop()
+  {
+    return $this->writeByte(0);
+  }
+
+  public function writeFieldHeader($type, $fid)
+  {
+    $written = 0;
+    $delta = $fid - $this->lastFid;
+    if (0 < $delta && $delta <= 15) {
+      $written = $this->writeUByte(($delta << 4) | $type);
+    } else {
+      $written = $this->writeByte($type) +
+        $this->writeI16($fid);
+    }
+    $this->lastFid = $fid;
+
+    return $written;
+  }
+
+  public function writeFieldBegin($field_name, $field_type, $field_id)
+  {
+    if ($field_type == TTYPE::BOOL) {
+      $this->state = TCompactProtocol::STATE_BOOL_WRITE;
+      $this->boolFid = $field_id;
+
+      return 0;
+    } else {
+      $this->state = TCompactProtocol::STATE_VALUE_WRITE;
+
+      return $this->writeFieldHeader(self::$ctypes[$field_type], $field_id);
+    }
+  }
+
+  public function writeFieldEnd()
+  {
+    $this->state = TCompactProtocol::STATE_FIELD_WRITE;
+
+    return 0;
+  }
+
+  public function writeCollectionBegin($etype, $size)
+  {
+    $written = 0;
+    if ($size <= 14) {
+      $written = $this->writeUByte($size << 4 |
+                                    self::$ctypes[$etype]);
+    } else {
+      $written = $this->writeUByte(0xf0 |
+                                   self::$ctypes[$etype]) +
+        $this->writeVarint($size);
+    }
+    $this->containers[] = $this->state;
+    $this->state = TCompactProtocol::STATE_CONTAINER_WRITE;
+
+    return $written;
+  }
+
+  public function writeMapBegin($key_type, $val_type, $size)
+  {
+    $written = 0;
+    if ($size == 0) {
+      $written = $this->writeByte(0);
+    } else {
+      $written = $this->writeVarint($size) +
+        $this->writeUByte(self::$ctypes[$key_type] << 4 |
+                          self::$ctypes[$val_type]);
+    }
+    $this->containers[] = $this->state;
+
+    return $written;
+  }
+
+  public function writeCollectionEnd()
+  {
+    $this->state = array_pop($this->containers);
+
+    return 0;
+  }
+
+  public function writeMapEnd()
+  {
+    return $this->writeCollectionEnd();
+  }
+
+  public function writeListBegin($elem_type, $size)
+  {
+    return $this->writeCollectionBegin($elem_type, $size);
+  }
+
+  public function writeListEnd()
+  {
+    return $this->writeCollectionEnd();
+  }
+
+  public function writeSetBegin($elem_type, $size)
+  {
+    return $this->writeCollectionBegin($elem_type, $size);
+  }
+
+  public function writeSetEnd()
+  {
+    return $this->writeCollectionEnd();
+  }
+
+  public function writeBool($value)
+  {
+    if ($this->state == TCompactProtocol::STATE_BOOL_WRITE) {
+      $ctype = TCompactProtocol::COMPACT_FALSE;
+      if ($value) {
+        $ctype = TCompactProtocol::COMPACT_TRUE;
+      }
+
+      return $this->writeFieldHeader($ctype, $this->boolFid);
+    } elseif ($this->state == TCompactProtocol::STATE_CONTAINER_WRITE) {
+      return $this->writeByte($value ? 1 : 0);
+    } else {
+      throw new TProtocolException('Invalid state in compact protocol');
+    }
+  }
+
+  public function writeByte($value)
+  {
+    $data = pack('c', $value);
+    $this->trans_->write($data, 1);
+
+    return 1;
+  }
+
+  public function writeUByte($byte)
+  {
+    $this->trans_->write(pack('C', $byte), 1);
+
+    return 1;
+  }
+
+  public function writeI16($value)
+  {
+    $thing = $this->toZigZag($value, 16);
+
+    return $this->writeVarint($thing);
+  }
+
+  public function writeI32($value)
+  {
+    $thing = $this->toZigZag($value, 32);
+
+    return $this->writeVarint($thing);
+  }
+
+  public function writeDouble($value)
+  {
+    $data = pack('d', $value);
+    $this->trans_->write($data, 8);
+
+    return 8;
+  }
+
+  public function writeString($value)
+  {
+    $len = TStringFuncFactory::create()->strlen($value);
+    $result = $this->writeVarint($len);
+    if ($len) {
+      $this->trans_->write($value, $len);
+    }
+
+    return $result + $len;
+  }
+
+  public function readFieldBegin(&$name, &$field_type, &$field_id)
+  {
+    $result = $this->readUByte($field_type);
+
+    if (($field_type & 0x0f) == TType::STOP) {
+      $field_id = 0;
+
+      return $result;
+    }
+    $delta = $field_type >> 4;
+    if ($delta == 0) {
+      $result += $this->readI16($field_id);
+    } else {
+      $field_id = $this->lastFid + $delta;
+    }
+    $this->lastFid = $field_id;
+    $field_type = $this->getTType($field_type & 0x0f);
+    if ($field_type == TCompactProtocol::COMPACT_TRUE) {
+      $this->state = TCompactProtocol::STATE_BOOL_READ;
+      $this->boolValue = true;
+    } elseif ($field_type == TCompactProtocol::COMPACT_FALSE) {
+      $this->state = TCompactProtocol::STATE_BOOL_READ;
+      $this->boolValue = false;
+    } else {
+      $this->state = TCompactProtocol::STATE_VALUE_READ;
+    }
+
+    return $result;
+  }
+
+  public function readFieldEnd()
+  {
+    $this->state = TCompactProtocol::STATE_FIELD_READ;
+
+    return 0;
+  }
+
+  public function readUByte(&$value)
+  {
+    $data = $this->trans_->readAll(1);
+    $arr = unpack('C', $data);
+    $value = $arr[1];
+
+    return 1;
+  }
+
+  public function readByte(&$value)
+  {
+    $data = $this->trans_->readAll(1);
+    $arr = unpack('c', $data);
+    $value = $arr[1];
+
+    return 1;
+  }
+
+  public function readZigZag(&$value)
+  {
+    $result = $this->readVarint($value);
+    $value = $this->fromZigZag($value);
+
+    return $result;
+  }
+
+  public function readMessageBegin(&$name, &$type, &$seqid)
+  {
+    $protoId = 0;
+    $result = $this->readUByte($protoId);
+    if ($protoId != TCompactProtocol::PROTOCOL_ID) {
+      throw new TProtocolException('Bad protocol id in TCompact message');
+    }
+    $verType = 0;
+    $result += $this->readUByte($verType);
+    $type = ($verType >> TCompactProtocol::TYPE_SHIFT_AMOUNT) & TCompactProtocol::TYPE_BITS;
+    $version = $verType & TCompactProtocol::VERSION_MASK;
+    if ($version != TCompactProtocol::VERSION) {
+      throw new TProtocolException('Bad version in TCompact message');
+    }
+    $result += $this->readVarint($seqid);
+    $result += $this->readString($name);
+
+    return $result;
+  }
+
+  public function readMessageEnd()
+  {
+    return 0;
+  }
+
+  public function readStructBegin(&$name)
+  {
+    $name = ''; // unused
+    $this->structs[] = array($this->state, $this->lastFid);
+    $this->state = TCompactProtocol::STATE_FIELD_READ;
+    $this->lastFid = 0;
+
+    return 0;
+  }
+
+  public function readStructEnd()
+  {
+    $last = array_pop($this->structs);
+    $this->state = $last[0];
+    $this->lastFid = $last[1];
+
+    return 0;
+  }
+
+  public function readCollectionBegin(&$type, &$size)
+  {
+    $sizeType = 0;
+    $result = $this->readUByte($sizeType);
+    $size = $sizeType >> 4;
+    $type = $this->getTType($sizeType);
+    if ($size == 15) {
+      $result += $this->readVarint($size);
+    }
+    $this->containers[] = $this->state;
+    $this->state = TCompactProtocol::STATE_CONTAINER_READ;
+
+    return $result;
+  }
+
+  public function readMapBegin(&$key_type, &$val_type, &$size)
+  {
+    $result = $this->readVarint($size);
+    $types = 0;
+    if ($size > 0) {
+      $result += $this->readUByte($types);
+    }
+    $val_type = $this->getTType($types);
+    $key_type = $this->getTType($types >> 4);
+    $this->containers[] = $this->state;
+    $this->state = TCompactProtocol::STATE_CONTAINER_READ;
+
+    return $result;
+  }
+
+  public function readCollectionEnd()
+  {
+    $this->state = array_pop($this->containers);
+
+    return 0;
+  }
+
+  public function readMapEnd()
+  {
+    return $this->readCollectionEnd();
+  }
+
+  public function readListBegin(&$elem_type, &$size)
+  {
+    return $this->readCollectionBegin($elem_type, $size);
+  }
+
+  public function readListEnd()
+  {
+    return $this->readCollectionEnd();
+  }
+
+  public function readSetBegin(&$elem_type, &$size)
+  {
+    return $this->readCollectionBegin($elem_type, $size);
+  }
+
+  public function readSetEnd()
+  {
+    return $this->readCollectionEnd();
+  }
+
+  public function readBool(&$value)
+  {
+    if ($this->state == TCompactProtocol::STATE_BOOL_READ) {
+      $value = $this->boolValue;
+
+      return 0;
+    } elseif ($this->state == TCompactProtocol::STATE_CONTAINER_READ) {
+      return $this->readByte($value);
+    } else {
+      throw new TProtocolException('Invalid state in compact protocol');
+    }
+  }
+
+  public function readI16(&$value)
+  {
+    return $this->readZigZag($value);
+  }
+
+  public function readI32(&$value)
+  {
+    return $this->readZigZag($value);
+  }
+
+  public function readDouble(&$value)
+  {
+    $data = $this->trans_->readAll(8);
+    $arr = unpack('d', $data);
+    $value = $arr[1];
+
+    return 8;
+  }
+
+  public function readString(&$value)
+  {
+    $result = $this->readVarint($len);
+    if ($len) {
+      $value = $this->trans_->readAll($len);
+    } else {
+      $value = '';
+    }
+
+    return $result + $len;
+  }
+
+  public function getTType($byte)
+  {
+    return self::$ttypes[$byte & 0x0f];
+  }
+
+  // If we are on a 32bit architecture we have to explicitly deal with
+  // 64-bit twos-complement arithmetic since PHP wants to treat all ints
+  // as signed and any int over 2^31 - 1 as a float
+
+  // Read and write I64 as two 32 bit numbers $hi and $lo
+
+  public function readI64(&$value)
+  {
+    // Read varint from wire
+    $hi = 0;
+    $lo = 0;
+
+    $idx = 0;
+    $shift = 0;
+
+    while (true) {
+      $x = $this->trans_->readAll(1);
+      $arr = unpack('C', $x);
+      $byte = $arr[1];
+      $idx += 1;
+      if ($shift < 32) {
+        $lo |= (($byte & 0x7f) << $shift) &
+          0x00000000ffffffff;
+      }
+      // Shift hi and lo together.
+      if ($shift >= 32) {
+        $hi |= (($byte & 0x7f) << ($shift - 32));
+      } elseif ($shift > 25) {
+        $hi |= (($byte & 0x7f) >> ($shift - 25));
+      }
+      if (($byte >> 7) === 0) {
+        break;
+      }
+      $shift += 7;
+    }
+
+    // Now, unzig it.
+    $xorer = 0;
+    if ($lo & 1) {
+      $xorer = 0xffffffff;
+    }
+    $lo = ($lo >> 1) & 0x7fffffff;
+    $lo = $lo | (($hi & 1) << 31);
+    $hi = ($hi >> 1) ^ $xorer;
+    $lo = $lo ^ $xorer;
+
+    // Now put $hi and $lo back together
+    if (true) {
+      $isNeg = $hi  < 0;
+
+      // Check for a negative
+      if ($isNeg) {
+        $hi = ~$hi & (int) 0xffffffff;
+        $lo = ~$lo & (int) 0xffffffff;
+
+        if ($lo == (int) 0xffffffff) {
+          $hi++;
+          $lo = 0;
+        } else {
+          $lo++;
+        }
+      }
+
+      // Force 32bit words in excess of 2G to be positive - we deal with sign
+      // explicitly below
+
+      if ($hi & (int) 0x80000000) {
+        $hi &= (int) 0x7fffffff;
+        $hi += 0x80000000;
+      }
+
+      if ($lo & (int) 0x80000000) {
+        $lo &= (int) 0x7fffffff;
+        $lo += 0x80000000;
+      }
+
+      $value = $hi * 4294967296 + $lo;
+
+      if ($isNeg) {
+        $value = 0 - $value;
+      }
+    } else {
+
+      // Upcast negatives in LSB bit
+      if ($arr[2] & 0x80000000) {
+        $arr[2] = $arr[2] & 0xffffffff;
+      }
+
+      // Check for a negative
+      if ($arr[1] & 0x80000000) {
+        $arr[1] = $arr[1] & 0xffffffff;
+        $arr[1] = $arr[1] ^ 0xffffffff;
+        $arr[2] = $arr[2] ^ 0xffffffff;
+        $value = 0 - $arr[1] * 4294967296 - $arr[2] - 1;
+      } else {
+        $value = $arr[1] * 4294967296 + $arr[2];
+      }
+    }
+
+    return $idx;
+  }
+
+  public function writeI64($value)
+  {
+    // If we are in an I32 range, use the easy method below.
+    if (($value > 4294967296) || ($value < -4294967296)) {
+      // Convert $value to $hi and $lo
+      $neg = $value < 0;
+
+      if ($neg) {
+        $value *= -1;
+      }
+
+      $hi = (int) $value >> 32;
+      $lo = (int) $value & 0xffffffff;
+
+      if ($neg) {
+        $hi = ~$hi;
+        $lo = ~$lo;
+        if (($lo & (int) 0xffffffff) == (int) 0xffffffff) {
+          $lo = 0;
+          $hi++;
+        } else {
+          $lo++;
+        }
+      }
+
+      // Now do the zigging and zagging.
+      $xorer = 0;
+      if ($neg) {
+        $xorer = 0xffffffff;
+      }
+      $lowbit = ($lo >> 31) & 1;
+      $hi = ($hi << 1) | $lowbit;
+      $lo = ($lo << 1);
+      $lo = ($lo ^ $xorer) & 0xffffffff;
+      $hi = ($hi ^ $xorer) & 0xffffffff;
+
+      // now write out the varint, ensuring we shift both hi and lo
+      $out = "";
+      while (true) {
+        if (($lo & ~0x7f) === 0 &&
+           $hi === 0) {
+          $out .= chr($lo);
+          break;
+        } else {
+          $out .= chr(($lo & 0xff) | 0x80);
+          $lo = $lo >> 7;
+          $lo = $lo | ($hi << 25);
+          $hi = $hi >> 7;
+          // Right shift carries sign, but we don't want it to.
+          $hi = $hi & (127 << 25);
+        }
+      }
+
+      $ret = TStringFuncFactory::create()->strlen($out);
+      $this->trans_->write($out, $ret);
+
+      return $ret;
+    } else {
+      return $this->writeVarint($this->toZigZag($value, 64));
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/165a5113/airavata-mock-multiplexed-api/mock-airavata-api-php-stubs/src/main/resources/lib/Thrift/Protocol/TJSONProtocol.php
----------------------------------------------------------------------
diff --git a/airavata-mock-multiplexed-api/mock-airavata-api-php-stubs/src/main/resources/lib/Thrift/Protocol/TJSONProtocol.php b/airavata-mock-multiplexed-api/mock-airavata-api-php-stubs/src/main/resources/lib/Thrift/Protocol/TJSONProtocol.php
new file mode 100755
index 0000000..6c93b09
--- /dev/null
+++ b/airavata-mock-multiplexed-api/mock-airavata-api-php-stubs/src/main/resources/lib/Thrift/Protocol/TJSONProtocol.php
@@ -0,0 +1,769 @@
+<?php
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ * @package thrift.protocol
+ */
+
+namespace Thrift\Protocol;
+
+use Thrift\Type\TType;
+use Thrift\Exception\TProtocolException;
+use Thrift\Protocol\JSON\BaseContext;
+use Thrift\Protocol\JSON\LookaheadReader;
+use Thrift\Protocol\JSON\PairContext;
+use Thrift\Protocol\JSON\ListContext;
+
+/**
+ * JSON implementation of thrift protocol, ported from Java.
+ */
+class TJSONProtocol extends TProtocol
+{
+    const COMMA = ',';
+    const COLON = ':';
+    const LBRACE = '{';
+    const RBRACE = '}';
+    const LBRACKET = '[';
+    const RBRACKET = ']';
+    const QUOTE = '"';
+    const BACKSLASH = '\\';
+    const ZERO = '0';
+    const ESCSEQ = '\\';
+    const DOUBLEESC = '__DOUBLE_ESCAPE_SEQUENCE__';
+
+    const VERSION = 1;
+
+    public static $JSON_CHAR_TABLE = array(
+        /*  0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F */
+        0, 0, 0, 0, 0, 0, 0, 0, 'b', 't', 'n', 0, 'f', 'r', 0, 0, // 0
+        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 1
+        1, 1, '"', 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 2
+    );
+
+    public static $ESCAPE_CHARS = array('"', '\\', '/', "b", "f", "n", "r", "t");
+
+    public static $ESCAPE_CHAR_VALS = array(
+        '"', '\\', '/', "\x08", "\f", "\n", "\r", "\t",
+    );
+
+    const NAME_BOOL = "tf";
+    const NAME_BYTE = "i8";
+    const NAME_I16 = "i16";
+    const NAME_I32 = "i32";
+    const NAME_I64 = "i64";
+    const NAME_DOUBLE = "dbl";
+    const NAME_STRUCT = "rec";
+    const NAME_STRING = "str";
+    const NAME_MAP = "map";
+    const NAME_LIST = "lst";
+    const NAME_SET = "set";
+
+    private function getTypeNameForTypeID($typeID)
+    {
+        switch ($typeID) {
+            case TType::BOOL:
+                return self::NAME_BOOL;
+            case TType::BYTE:
+                return self::NAME_BYTE;
+            case TType::I16:
+                return self::NAME_I16;
+            case TType::I32:
+                return self::NAME_I32;
+            case TType::I64:
+                return self::NAME_I64;
+            case TType::DOUBLE:
+                return self::NAME_DOUBLE;
+            case TType::STRING:
+                return self::NAME_STRING;
+            case TType::STRUCT:
+                return self::NAME_STRUCT;
+            case TType::MAP:
+                return self::NAME_MAP;
+            case TType::SET:
+                return self::NAME_SET;
+            case TType::LST:
+                return self::NAME_LIST;
+            default:
+                throw new TProtocolException("Unrecognized type", TProtocolException::UNKNOWN);
+        }
+    }
+
+    private function getTypeIDForTypeName($name)
+    {
+        $result = TType::STOP;
+
+        if (strlen($name) > 1) {
+            switch (substr($name, 0, 1)) {
+                case 'd':
+                    $result = TType::DOUBLE;
+                    break;
+                case 'i':
+                    switch (substr($name, 1, 1)) {
+                        case '8':
+                            $result = TType::BYTE;
+                            break;
+                        case '1':
+                            $result = TType::I16;
+                            break;
+                        case '3':
+                            $result = TType::I32;
+                            break;
+                        case '6':
+                            $result = TType::I64;
+                            break;
+                    }
+                    break;
+                case 'l':
+                    $result = TType::LST;
+                    break;
+                case 'm':
+                    $result = TType::MAP;
+                    break;
+                case 'r':
+                    $result = TType::STRUCT;
+                    break;
+                case 's':
+                    if (substr($name, 1, 1) == 't') {
+                        $result = TType::STRING;
+                    } elseif (substr($name, 1, 1) == 'e') {
+                        $result = TType::SET;
+                    }
+                    break;
+                case 't':
+                    $result = TType::BOOL;
+                    break;
+            }
+        }
+        if ($result == TType::STOP) {
+            throw new TProtocolException("Unrecognized type", TProtocolException::INVALID_DATA);
+        }
+
+        return $result;
+    }
+
+    public $contextStack_ = array();
+    public $context_;
+    public $reader_;
+
+    private function pushContext($c)
+    {
+        array_push($this->contextStack_, $this->context_);
+        $this->context_ = $c;
+    }
+
+    private function popContext()
+    {
+        $this->context_ = array_pop($this->contextStack_);
+    }
+
+    public function __construct($trans)
+    {
+        parent::__construct($trans);
+        $this->context_ = new BaseContext();
+        $this->reader_ = new LookaheadReader($this);
+    }
+
+    public function reset()
+    {
+        $this->contextStack_ = array();
+        $this->context_ = new BaseContext();
+        $this->reader_ = new LookaheadReader($this);
+    }
+
+    private $tmpbuf_ = array(4);
+
+    public function readJSONSyntaxChar($b)
+    {
+        $ch = $this->reader_->read();
+
+        if (substr($ch, 0, 1) != $b) {
+            throw new TProtocolException("Unexpected character: " . $ch, TProtocolException::INVALID_DATA);
+        }
+    }
+
+    private function hexVal($s)
+    {
+        for ($i = 0; $i < strlen($s); $i++) {
+            $ch = substr($s, $i, 1);
+
+            if (!($ch >= "a" && $ch <= "f") && !($ch >= "0" && $ch <= "9")) {
+                throw new TProtocolException("Expected hex character " . $ch, TProtocolException::INVALID_DATA);
+            }
+        }
+
+        return hexdec($s);
+    }
+
+    private function hexChar($val)
+    {
+        return dechex($val);
+    }
+
+    private function writeJSONString($b)
+    {
+        $this->context_->write();
+
+        if (is_numeric($b) && $this->context_->escapeNum()) {
+            $this->trans_->write(self::QUOTE);
+        }
+
+        $this->trans_->write(json_encode($b));
+
+        if (is_numeric($b) && $this->context_->escapeNum()) {
+            $this->trans_->write(self::QUOTE);
+        }
+    }
+
+    private function writeJSONInteger($num)
+    {
+        $this->context_->write();
+
+        if ($this->context_->escapeNum()) {
+            $this->trans_->write(self::QUOTE);
+        }
+
+        $this->trans_->write($num);
+
+        if ($this->context_->escapeNum()) {
+            $this->trans_->write(self::QUOTE);
+        }
+    }
+
+    private function writeJSONDouble($num)
+    {
+        $this->context_->write();
+
+        if ($this->context_->escapeNum()) {
+            $this->trans_->write(self::QUOTE);
+        }
+
+        $this->trans_->write(json_encode($num));
+
+        if ($this->context_->escapeNum()) {
+            $this->trans_->write(self::QUOTE);
+        }
+    }
+
+    private function writeJSONBase64($data)
+    {
+        $this->context_->write();
+        $this->trans_->write(self::QUOTE);
+        $this->trans_->write(json_encode(base64_encode($data)));
+        $this->trans_->write(self::QUOTE);
+    }
+
+    private function writeJSONObjectStart()
+    {
+      $this->context_->write();
+      $this->trans_->write(self::LBRACE);
+      $this->pushContext(new PairContext($this));
+    }
+
+    private function writeJSONObjectEnd()
+    {
+      $this->popContext();
+      $this->trans_->write(self::RBRACE);
+    }
+
+    private function writeJSONArrayStart()
+    {
+      $this->context_->write();
+      $this->trans_->write(self::LBRACKET);
+      $this->pushContext(new ListContext($this));
+    }
+
+    private function writeJSONArrayEnd()
+    {
+      $this->popContext();
+      $this->trans_->write(self::RBRACKET);
+    }
+
+    private function readJSONString($skipContext)
+    {
+      if (!$skipContext) {
+        $this->context_->read();
+      }
+
+      $jsonString = '';
+      $lastChar = null;
+      while (true) {
+        $ch = $this->reader_->read();
+        $jsonString .= $ch;
+        if ($ch == self::QUOTE &&
+          $lastChar !== NULL &&
+            $lastChar !== self::ESCSEQ) {
+          break;
+        }
+        if ($ch == self::ESCSEQ && $lastChar == self::ESCSEQ) {
+          $lastChar = self::DOUBLEESC;
+        } else {
+          $lastChar = $ch;
+        }
+      }
+
+      return json_decode($jsonString);
+    }
+
+    private function isJSONNumeric($b)
+    {
+        switch ($b) {
+            case '+':
+            case '-':
+            case '.':
+            case '0':
+            case '1':
+            case '2':
+            case '3':
+            case '4':
+            case '5':
+            case '6':
+            case '7':
+            case '8':
+            case '9':
+            case 'E':
+            case 'e':
+              return true;
+            }
+
+        return false;
+    }
+
+    private function readJSONNumericChars()
+    {
+        $strbld = array();
+
+        while (true) {
+            $ch = $this->reader_->peek();
+
+            if (!$this->isJSONNumeric($ch)) {
+                break;
+            }
+
+            $strbld[] = $this->reader_->read();
+        }
+
+        return implode("", $strbld);
+    }
+
+    private function readJSONInteger()
+    {
+        $this->context_->read();
+
+        if ($this->context_->escapeNum()) {
+            $this->readJSONSyntaxChar(self::QUOTE);
+        }
+
+        $str = $this->readJSONNumericChars();
+
+        if ($this->context_->escapeNum()) {
+            $this->readJSONSyntaxChar(self::QUOTE);
+        }
+
+        if (!is_numeric($str)) {
+            throw new TProtocolException("Invalid data in numeric: " . $str, TProtocolException::INVALID_DATA);
+        }
+
+        return intval($str);
+    }
+
+    /**
+     * Identical to readJSONInteger but without the final cast.
+     * Needed for proper handling of i64 on 32 bit machines.  Why a
+     * separate function?  So we don't have to force the rest of the
+     * use cases through the extra conditional.
+     */
+    private function readJSONIntegerAsString()
+    {
+        $this->context_->read();
+
+        if ($this->context_->escapeNum()) {
+            $this->readJSONSyntaxChar(self::QUOTE);
+        }
+
+        $str = $this->readJSONNumericChars();
+
+        if ($this->context_->escapeNum()) {
+            $this->readJSONSyntaxChar(self::QUOTE);
+        }
+
+        if (!is_numeric($str)) {
+            throw new TProtocolException("Invalid data in numeric: " . $str, TProtocolException::INVALID_DATA);
+        }
+
+        return $str;
+    }
+
+    private function readJSONDouble()
+    {
+        $this->context_->read();
+
+        if (substr($this->reader_->peek(), 0, 1) == self::QUOTE) {
+            $arr = $this->readJSONString(true);
+
+            if ($arr == "NaN") {
+                return NAN;
+            } elseif ($arr == "Infinity") {
+                return INF;
+            } elseif (!$this->context_->escapeNum()) {
+                throw new TProtocolException("Numeric data unexpectedly quoted " . $arr,
+                                              TProtocolException::INVALID_DATA);
+            }
+
+            return floatval($arr);
+        } else {
+            if ($this->context_->escapeNum()) {
+                $this->readJSONSyntaxChar(self::QUOTE);
+            }
+
+            return floatval($this->readJSONNumericChars());
+        }
+    }
+
+    private function readJSONBase64()
+    {
+        $arr = $this->readJSONString(false);
+        $data = base64_decode($arr, true);
+
+        if ($data === false) {
+            throw new TProtocolException("Invalid base64 data " . $arr, TProtocolException::INVALID_DATA);
+        }
+
+        return $data;
+    }
+
+    private function readJSONObjectStart()
+    {
+        $this->context_->read();
+        $this->readJSONSyntaxChar(self::LBRACE);
+        $this->pushContext(new PairContext($this));
+    }
+
+    private function readJSONObjectEnd()
+    {
+        $this->readJSONSyntaxChar(self::RBRACE);
+        $this->popContext();
+    }
+
+    private function readJSONArrayStart()
+    {
+        $this->context_->read();
+        $this->readJSONSyntaxChar(self::LBRACKET);
+        $this->pushContext(new ListContext($this));
+    }
+
+    private function readJSONArrayEnd()
+    {
+        $this->readJSONSyntaxChar(self::RBRACKET);
+        $this->popContext();
+    }
+
+    /**
+     * Writes the message header
+     *
+     * @param string $name  Function name
+     * @param int    $type  message type TMessageType::CALL or TMessageType::REPLY
+     * @param int    $seqid The sequence id of this message
+     */
+    public function writeMessageBegin($name, $type, $seqid)
+    {
+        $this->writeJSONArrayStart();
+        $this->writeJSONInteger(self::VERSION);
+        $this->writeJSONString($name);
+        $this->writeJSONInteger($type);
+        $this->writeJSONInteger($seqid);
+    }
+
+    /**
+     * Close the message
+     */
+    public function writeMessageEnd()
+    {
+        $this->writeJSONArrayEnd();
+    }
+
+    /**
+     * Writes a struct header.
+     *
+     * @param  string     $name Struct name
+     * @throws TException on write error
+     * @return int        How many bytes written
+     */
+    public function writeStructBegin($name)
+    {
+        $this->writeJSONObjectStart();
+    }
+
+    /**
+     * Close a struct.
+     *
+     * @throws TException on write error
+     * @return int        How many bytes written
+     */
+    public function writeStructEnd()
+    {
+        $this->writeJSONObjectEnd();
+    }
+
+    public function writeFieldBegin($fieldName, $fieldType, $fieldId)
+    {
+        $this->writeJSONInteger($fieldId);
+        $this->writeJSONObjectStart();
+        $this->writeJSONString($this->getTypeNameForTypeID($fieldType));
+    }
+
+    public function writeFieldEnd()
+    {
+        $this->writeJsonObjectEnd();
+    }
+
+    public function writeFieldStop()
+    {
+    }
+
+    public function writeMapBegin($keyType, $valType, $size)
+    {
+        $this->writeJSONArrayStart();
+        $this->writeJSONString($this->getTypeNameForTypeID($keyType));
+        $this->writeJSONString($this->getTypeNameForTypeID($valType));
+        $this->writeJSONInteger($size);
+        $this->writeJSONObjectStart();
+    }
+
+    public function writeMapEnd()
+    {
+        $this->writeJSONObjectEnd();
+        $this->writeJSONArrayEnd();
+    }
+
+    public function writeListBegin($elemType, $size)
+    {
+        $this->writeJSONArrayStart();
+        $this->writeJSONString($this->getTypeNameForTypeID($elemType));
+        $this->writeJSONInteger($size);
+    }
+
+    public function writeListEnd()
+    {
+        $this->writeJSONArrayEnd();
+    }
+
+    public function writeSetBegin($elemType, $size)
+    {
+        $this->writeJSONArrayStart();
+        $this->writeJSONString($this->getTypeNameForTypeID($elemType));
+        $this->writeJSONInteger($size);
+    }
+
+    public function writeSetEnd()
+    {
+        $this->writeJSONArrayEnd();
+    }
+
+    public function writeBool($bool)
+    {
+        $this->writeJSONInteger($bool ? 1 : 0);
+    }
+
+    public function writeByte($byte)
+    {
+        $this->writeJSONInteger($byte);
+    }
+
+    public function writeI16($i16)
+    {
+        $this->writeJSONInteger($i16);
+    }
+
+    public function writeI32($i32)
+    {
+        $this->writeJSONInteger($i32);
+    }
+
+    public function writeI64($i64)
+    {
+        $this->writeJSONInteger($i64);
+    }
+
+    public function writeDouble($dub)
+    {
+        $this->writeJSONDouble($dub);
+    }
+
+    public function writeString($str)
+    {
+        $this->writeJSONString($str);
+    }
+
+    /**
+     * Reads the message header
+     *
+     * @param string $name Function name
+     * @param int    $type message type TMessageType::CALL or TMessageType::REPLY
+     * @parem int $seqid The sequence id of this message
+     */
+    public function readMessageBegin(&$name, &$type, &$seqid)
+    {
+        $this->readJSONArrayStart();
+
+        if ($this->readJSONInteger() != self::VERSION) {
+            throw new TProtocolException("Message contained bad version", TProtocolException::BAD_VERSION);
+        }
+
+        $name = $this->readJSONString(false);
+        $type = $this->readJSONInteger();
+        $seqid = $this->readJSONInteger();
+
+        return true;
+    }
+
+    /**
+     * Read the close of message
+     */
+    public function readMessageEnd()
+    {
+        $this->readJSONArrayEnd();
+    }
+
+    public function readStructBegin(&$name)
+    {
+        $this->readJSONObjectStart();
+
+        return 0;
+    }
+
+    public function readStructEnd()
+    {
+        $this->readJSONObjectEnd();
+    }
+
+    public function readFieldBegin(&$name, &$fieldType, &$fieldId)
+    {
+        $ch = $this->reader_->peek();
+        $name = "";
+
+        if (substr($ch, 0, 1) == self::RBRACE) {
+            $fieldType = TType::STOP;
+        } else {
+            $fieldId = $this->readJSONInteger();
+            $this->readJSONObjectStart();
+            $fieldType = $this->getTypeIDForTypeName($this->readJSONString(false));
+        }
+    }
+
+    public function readFieldEnd()
+    {
+        $this->readJSONObjectEnd();
+    }
+
+    public function readMapBegin(&$keyType, &$valType, &$size)
+    {
+        $this->readJSONArrayStart();
+        $keyType = $this->getTypeIDForTypeName($this->readJSONString(false));
+        $valType = $this->getTypeIDForTypeName($this->readJSONString(false));
+        $size = $this->readJSONInteger();
+        $this->readJSONObjectStart();
+    }
+
+    public function readMapEnd()
+    {
+        $this->readJSONObjectEnd();
+        $this->readJSONArrayEnd();
+    }
+
+    public function readListBegin(&$elemType, &$size)
+    {
+        $this->readJSONArrayStart();
+        $elemType = $this->getTypeIDForTypeName($this->readJSONString(false));
+        $size = $this->readJSONInteger();
+
+        return true;
+    }
+
+    public function readListEnd()
+    {
+        $this->readJSONArrayEnd();
+    }
+
+    public function readSetBegin(&$elemType, &$size)
+    {
+        $this->readJSONArrayStart();
+        $elemType = $this->getTypeIDForTypeName($this->readJSONString(false));
+        $size = $this->readJSONInteger();
+
+        return true;
+    }
+
+    public function readSetEnd()
+    {
+        $this->readJSONArrayEnd();
+    }
+
+    public function readBool(&$bool)
+    {
+        $bool = $this->readJSONInteger() == 0 ? false : true;
+
+        return true;
+    }
+
+    public function readByte(&$byte)
+    {
+        $byte = $this->readJSONInteger();
+
+        return true;
+    }
+
+    public function readI16(&$i16)
+    {
+        $i16 = $this->readJSONInteger();
+
+        return true;
+    }
+
+    public function readI32(&$i32)
+    {
+        $i32 = $this->readJSONInteger();
+
+        return true;
+    }
+
+    public function readI64(&$i64)
+    {
+        if (PHP_INT_SIZE === 4) {
+            $i64 = $this->readJSONIntegerAsString();
+        } else {
+            $i64 = $this->readJSONInteger();
+        }
+
+        return true;
+    }
+
+    public function readDouble(&$dub)
+    {
+        $dub = $this->readJSONDouble();
+
+        return true;
+    }
+
+    public function readString(&$str)
+    {
+        $str = $this->readJSONString(false);
+
+        return true;
+    }
+}

http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/165a5113/airavata-mock-multiplexed-api/mock-airavata-api-php-stubs/src/main/resources/lib/Thrift/Protocol/TMultiplexedProtocol.php
----------------------------------------------------------------------
diff --git a/airavata-mock-multiplexed-api/mock-airavata-api-php-stubs/src/main/resources/lib/Thrift/Protocol/TMultiplexedProtocol.php b/airavata-mock-multiplexed-api/mock-airavata-api-php-stubs/src/main/resources/lib/Thrift/Protocol/TMultiplexedProtocol.php
new file mode 100755
index 0000000..d579c09
--- /dev/null
+++ b/airavata-mock-multiplexed-api/mock-airavata-api-php-stubs/src/main/resources/lib/Thrift/Protocol/TMultiplexedProtocol.php
@@ -0,0 +1,85 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ * @package thrift.protocol
+ */
+
+namespace Thrift\Protocol;
+
+use Thrift\Type\TMessageType;
+
+/**
+ * <code>TMultiplexedProtocol</code> is a protocol-independent concrete decorator
+ * that allows a Thrift client to communicate with a multiplexing Thrift server,
+ * by prepending the service name to the function name during function calls.
+ *
+ * @package Thrift\Protocol
+ */
+class TMultiplexedProtocol extends TProtocolDecorator
+{
+    /**
+     * Separator between service name and function name.
+     * Should be the same as used at multiplexed Thrift server.
+     *
+     * @var string
+     */
+    const SEPARATOR = ":";
+
+    /**
+     * The name of service.
+     *
+     * @var string
+     */
+    private $serviceName_;
+
+    /**
+     * Constructor of <code>TMultiplexedProtocol</code> class.
+     *
+     * Wrap the specified protocol, allowing it to be used to communicate with a
+     * multiplexing server.  The <code>$serviceName</code> is required as it is
+     * prepended to the message header so that the multiplexing server can broker
+     * the function call to the proper service.
+     *
+     * @param TProtocol $protocol
+     * @param string    $serviceName The name of service.
+     */
+    public function __construct(TProtocol $protocol, $serviceName)
+    {
+        parent::__construct($protocol);
+        $this->serviceName_ = $serviceName;
+    }
+
+    /**
+     * Writes the message header.
+     * Prepends the service name to the function name, separated by <code>TMultiplexedProtocol::SEPARATOR</code>.
+     *
+     * @param string $name  Function name.
+     * @param int    $type  Message type.
+     * @param int    $seqid The sequence id of this message.
+     */
+    public function writeMessageBegin($name, $type, $seqid)
+    {
+        if ($type == TMessageType::CALL || $type == TMessageType::ONEWAY) {
+            $nameWithService = $this->serviceName_ . self::SEPARATOR . $name;
+            parent::writeMessageBegin($nameWithService, $type, $seqid);
+        } else {
+            parent::writeMessageBegin($name, $type, $seqid);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/165a5113/airavata-mock-multiplexed-api/mock-airavata-api-php-stubs/src/main/resources/lib/Thrift/Protocol/TProtocol.php
----------------------------------------------------------------------
diff --git a/airavata-mock-multiplexed-api/mock-airavata-api-php-stubs/src/main/resources/lib/Thrift/Protocol/TProtocol.php b/airavata-mock-multiplexed-api/mock-airavata-api-php-stubs/src/main/resources/lib/Thrift/Protocol/TProtocol.php
new file mode 100755
index 0000000..0e3bc0d
--- /dev/null
+++ b/airavata-mock-multiplexed-api/mock-airavata-api-php-stubs/src/main/resources/lib/Thrift/Protocol/TProtocol.php
@@ -0,0 +1,352 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ * @package thrift.protocol
+ */
+
+namespace Thrift\Protocol;
+
+use Thrift\Type\TType;
+use Thrift\Exception\TProtocolException;
+
+/**
+ * Protocol base class module.
+ */
+abstract class TProtocol
+{
+  /**
+   * Underlying transport
+   *
+   * @var TTransport
+   */
+  protected $trans_;
+
+  /**
+   * Constructor
+   */
+  protected function __construct($trans)
+  {
+    $this->trans_ = $trans;
+  }
+
+  /**
+   * Accessor for transport
+   *
+   * @return TTransport
+   */
+  public function getTransport()
+  {
+    return $this->trans_;
+  }
+
+  /**
+   * Writes the message header
+   *
+   * @param string $name Function name
+   * @param int $type message type TMessageType::CALL or TMessageType::REPLY
+   * @param int $seqid The sequence id of this message
+   */
+  abstract public function writeMessageBegin($name, $type, $seqid);
+
+  /**
+   * Close the message
+   */
+  abstract public function writeMessageEnd();
+
+  /**
+   * Writes a struct header.
+   *
+   * @param string     $name Struct name
+   * @throws TException on write error
+   * @return int How many bytes written
+   */
+  abstract public function writeStructBegin($name);
+
+  /**
+   * Close a struct.
+   *
+   * @throws TException on write error
+   * @return int How many bytes written
+   */
+  abstract public function writeStructEnd();
+
+  /*
+   * Starts a field.
+   *
+   * @param string     $name Field name
+   * @param int        $type Field type
+   * @param int        $fid  Field id
+   * @throws TException on write error
+   * @return int How many bytes written
+   */
+  abstract public function writeFieldBegin($fieldName, $fieldType, $fieldId);
+
+  abstract public function writeFieldEnd();
+
+  abstract public function writeFieldStop();
+
+  abstract public function writeMapBegin($keyType, $valType, $size);
+
+  abstract public function writeMapEnd();
+
+  abstract public function writeListBegin($elemType, $size);
+
+  abstract public function writeListEnd();
+
+  abstract public function writeSetBegin($elemType, $size);
+
+  abstract public function writeSetEnd();
+
+  abstract public function writeBool($bool);
+
+  abstract public function writeByte($byte);
+
+  abstract public function writeI16($i16);
+
+  abstract public function writeI32($i32);
+
+  abstract public function writeI64($i64);
+
+  abstract public function writeDouble($dub);
+
+  abstract public function writeString($str);
+
+  /**
+   * Reads the message header
+   *
+   * @param string $name Function name
+   * @param int $type message type TMessageType::CALL or TMessageType::REPLY
+   * @parem int $seqid The sequence id of this message
+   */
+  abstract public function readMessageBegin(&$name, &$type, &$seqid);
+
+  /**
+   * Read the close of message
+   */
+  abstract public function readMessageEnd();
+
+  abstract public function readStructBegin(&$name);
+
+  abstract public function readStructEnd();
+
+  abstract public function readFieldBegin(&$name, &$fieldType, &$fieldId);
+
+  abstract public function readFieldEnd();
+
+  abstract public function readMapBegin(&$keyType, &$valType, &$size);
+
+  abstract public function readMapEnd();
+
+  abstract public function readListBegin(&$elemType, &$size);
+
+  abstract public function readListEnd();
+
+  abstract public function readSetBegin(&$elemType, &$size);
+
+  abstract public function readSetEnd();
+
+  abstract public function readBool(&$bool);
+
+  abstract public function readByte(&$byte);
+
+  abstract public function readI16(&$i16);
+
+  abstract public function readI32(&$i32);
+
+  abstract public function readI64(&$i64);
+
+  abstract public function readDouble(&$dub);
+
+  abstract public function readString(&$str);
+
+  /**
+   * The skip function is a utility to parse over unrecognized date without
+   * causing corruption.
+   *
+   * @param TType $type What type is it
+   */
+  public function skip($type)
+  {
+    switch ($type) {
+    case TType::BOOL:
+      return $this->readBool($bool);
+    case TType::BYTE:
+      return $this->readByte($byte);
+    case TType::I16:
+      return $this->readI16($i16);
+    case TType::I32:
+      return $this->readI32($i32);
+    case TType::I64:
+      return $this->readI64($i64);
+    case TType::DOUBLE:
+      return $this->readDouble($dub);
+    case TType::STRING:
+      return $this->readString($str);
+    case TType::STRUCT:
+      {
+        $result = $this->readStructBegin($name);
+        while (true) {
+          $result += $this->readFieldBegin($name, $ftype, $fid);
+          if ($ftype == TType::STOP) {
+            break;
+          }
+          $result += $this->skip($ftype);
+          $result += $this->readFieldEnd();
+        }
+        $result += $this->readStructEnd();
+
+        return $result;
+      }
+    case TType::MAP:
+      {
+        $result = $this->readMapBegin($keyType, $valType, $size);
+        for ($i = 0; $i < $size; $i++) {
+          $result += $this->skip($keyType);
+          $result += $this->skip($valType);
+        }
+        $result += $this->readMapEnd();
+
+        return $result;
+      }
+    case TType::SET:
+      {
+        $result = $this->readSetBegin($elemType, $size);
+        for ($i = 0; $i < $size; $i++) {
+          $result += $this->skip($elemType);
+        }
+        $result += $this->readSetEnd();
+
+        return $result;
+      }
+    case TType::LST:
+      {
+        $result = $this->readListBegin($elemType, $size);
+        for ($i = 0; $i < $size; $i++) {
+          $result += $this->skip($elemType);
+        }
+        $result += $this->readListEnd();
+
+        return $result;
+      }
+    default:
+      throw new TProtocolException('Unknown field type: '.$type,
+                                   TProtocolException::INVALID_DATA);
+    }
+  }
+
+  /**
+   * Utility for skipping binary data
+   *
+   * @param TTransport $itrans TTransport object
+   * @param int        $type   Field type
+   */
+  public static function skipBinary($itrans, $type)
+  {
+    switch ($type) {
+    case TType::BOOL:
+      return $itrans->readAll(1);
+    case TType::BYTE:
+      return $itrans->readAll(1);
+    case TType::I16:
+      return $itrans->readAll(2);
+    case TType::I32:
+      return $itrans->readAll(4);
+    case TType::I64:
+      return $itrans->readAll(8);
+    case TType::DOUBLE:
+      return $itrans->readAll(8);
+    case TType::STRING:
+      $len = unpack('N', $itrans->readAll(4));
+      $len = $len[1];
+      if ($len > 0x7fffffff) {
+        $len = 0 - (($len - 1) ^ 0xffffffff);
+      }
+
+      return 4 + $itrans->readAll($len);
+    case TType::STRUCT:
+      {
+        $result = 0;
+        while (true) {
+          $ftype = 0;
+          $fid = 0;
+          $data = $itrans->readAll(1);
+          $arr = unpack('c', $data);
+          $ftype = $arr[1];
+          if ($ftype == TType::STOP) {
+            break;
+          }
+          // I16 field id
+          $result += $itrans->readAll(2);
+          $result += self::skipBinary($itrans, $ftype);
+        }
+
+        return $result;
+      }
+    case TType::MAP:
+      {
+        // Ktype
+        $data = $itrans->readAll(1);
+        $arr = unpack('c', $data);
+        $ktype = $arr[1];
+        // Vtype
+        $data = $itrans->readAll(1);
+        $arr = unpack('c', $data);
+        $vtype = $arr[1];
+        // Size
+        $data = $itrans->readAll(4);
+        $arr = unpack('N', $data);
+        $size = $arr[1];
+        if ($size > 0x7fffffff) {
+          $size = 0 - (($size - 1) ^ 0xffffffff);
+        }
+        $result = 6;
+        for ($i = 0; $i < $size; $i++) {
+          $result += self::skipBinary($itrans, $ktype);
+          $result += self::skipBinary($itrans, $vtype);
+        }
+
+        return $result;
+      }
+    case TType::SET:
+    case TType::LST:
+      {
+        // Vtype
+        $data = $itrans->readAll(1);
+        $arr = unpack('c', $data);
+        $vtype = $arr[1];
+        // Size
+        $data = $itrans->readAll(4);
+        $arr = unpack('N', $data);
+        $size = $arr[1];
+        if ($size > 0x7fffffff) {
+          $size = 0 - (($size - 1) ^ 0xffffffff);
+        }
+        $result = 5;
+        for ($i = 0; $i < $size; $i++) {
+          $result += self::skipBinary($itrans, $vtype);
+        }
+
+        return $result;
+      }
+    default:
+      throw new TProtocolException('Unknown field type: '.$type,
+                                   TProtocolException::INVALID_DATA);
+    }
+  }
+}