The JSON Transport is a very lightweight HTTP-based Transport implementation, supporting the JSON-RPC 2.0 protocol specification.
To use the JSON Transport in a server, the following three steps must be performed:
Following is an example code fragment for setting up a JSON Transport listener, and registering a service object for use with the listener.
Poco::Remoting::JSON::TransportFactory::registerFactory();
Poco::Remoting::ORB::instance().registerListener(
new PocoRemoting::JSON::Listener(8080)
);
std::string uri = MyProject::MyClassHelper::registerObject(
new MyProject::MyClass,
"MyObject",
8080,
Poco::Remoting::JSON::Transport::ID
);
To use the JSON Transport in a client, the following two steps must be performed:
Following is an example code fragment for setting up a JSON Transport, and registering a service object for use with the transport.
Poco::Remoting::JSON::TransportFactory::registerFactory();
MyProject::IMyClass::Ptr ptrObj = MyProject::MyClassHelper::findObject(
hostName,
"MyObject",
8080,
Poco::Remoting::JSON::Transport::ID
);
The Remoting JSON Transport should work well with other JSON-RPC client or server implementations, provided they support passing parameters by-name (as object). The Remoting JSON Transport cannot handle parameters passed by-position (as JSON array). Furthermore, the JSON Transport does not support batched requests.