| 207 | } |
| 208 | |
| 209 | private String thriftRequest(byte[] input){ |
| 210 | try{ |
| 211 | |
| 212 | //Input |
| 213 | TMemoryBuffer inbuffer = new TMemoryBuffer(input.length); |
| 214 | inbuffer.write(input); |
| 215 | TProtocol inprotocol = new TJSONProtocol(inbuffer); |
| 216 | |
| 217 | //Output |
| 218 | TMemoryBuffer outbuffer = new TMemoryBuffer(100); |
| 219 | TProtocol outprotocol = new TJSONProtocol(outbuffer); |
| 220 | |
| 221 | TProcessor processor = new ThriftTest.Processor(new TestHandler()); |
| 222 | processor.process(inprotocol, outprotocol); |
| 223 | |
| 224 | byte[] output = new byte[outbuffer.length()]; |
| 225 | outbuffer.readAll(output, 0, output.length); |
| 226 | |
| 227 | return new String(output,"UTF-8"); |
| 228 | }catch(Throwable t){ |
| 229 | return "Error:"+t.getMessage(); |
| 230 | } |
| 231 | |
| 232 | |
| 233 | } |
| 234 | |
| 235 | } |
| 236 | |