Thrift transport in javascript client

倖福魔咒の 提交于 2019-12-03 12:01:55

To use a Javascript client you need a HTTP Thrift server (e.g. the one pointed out by yiding). You also need to use TJSONProtocol.

The files how to make a Thrift Java server work with an Thrift Javascript client are scattered throughout the source. I puzzled them together here: https://github.com/LukeOwncloud/ThriftJavaJavascriptDemo

The argument is a URL to a website endpoint that acts as a thrift server using the HTTP processor and JSON protocol. The source code contains a java test server example which can work with such a client.

For your own server, it should be able to act as a webserver, and handle things like CORS for cross-domain requests from your js client.

Ryan J

I think the answer yiding gave you has identified the problem. I don't have a complete answer, but can give you a few links that may help you get things figured out. If you're writing your server in PHP, this question may help. If you're writing your server in Java, this blog post which links to this sample code may help.

The above answers have already given enough clarity.

However to make things a bit more clear, assuming that your server is localhost and its running on port 8080.

Let your project name be Tutorial_service and endpoint in your server project be teach_thrift then you have to pass URL as below

var transport = new Thrift.Transport("http://localhost:8080/Tutorial_service/teach_thrift");

It should keep you going.. :)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!