This content has been marked as final. Show 6 replies
862806 wrote:JSON is a way to format data, not a communication protocol. See it as related to XML and YAML.
As we know that it's a common task for client to communicate with server, and we know there are may ways we can do that, such as RPC, JavaFX on websservices, JSON.
What's the best practice? Or is there any approach which JavaFX team prefer when they design and developer JavaFX?
This question you pose here makes it seem like you think JavaFX is somehow a replacement for Java. It is not, it is built on top of the Java platform. As such, nothing changes. You still use what is available for the Java platform and you use JavaFX to deliver the rich client part of your application, for which the framework is designed.
A personal favorite is RESTful webservices. I like Tomcat as the container. Jersey as the RESTful framework to create the server and client code. You can use JAXB to turn XML schema into java beans. The Java beans will be communicated from the client to the server as a POST. The server will take the passed object and can read it. The server in turn can respond with its own java bean object.
Notes: You will have to create the XML schema first. Use JAXB to turn the XML schema into java code... real java bean classes. Both the server and the client must have access to these java classes.
Thanks a lot for your comments.
Yes, there are several ways to do that. Both JAXB and RESTful are good choice.
I think RESTful has better payhead but some limitation, and for JAXB, what about the JAXB jar size? about 1M? and what about performance between java object and xml, and you have to maintain the xml schema.
So it is still left unanswered, what's the best practice?
Is there anyone who is familiar with JSON, pls give some comments about using JSON string to convey data between client and server.
I never had to deal with size limitations so never took that into account. There is also Spring to accomplish the same, but the documentation was lacking. The reason I am a fan of RESTful is that is uses standard highly-nonblocked protocols and ports... http/80/8080.
There is also RMI and JNDI. Uses port 1099 and I would not assume the ports will be open through firewalls and networks. With RMI you need to setup an RMI listener (server). Objects are marshaled between the server and client through the wire using the RMI protocol. Its different than making requests to a server. Instead you use JNDI to get the identifier of a remote object. You then use RMI registry to get access to that remote object. You then call the remote objects methods to use it. You can pass it objects as input to its method calls.
I like it but do not have mush exp with it.
At work we use SOAP. Luckily I am the architect and do not have to mess with it much. The creators of the SOAP services publish WSDL documents. You can take these WSDL files and some how put them into your code to access the services. I should really get a better understanding of it since we are using it heavily. I think it is easier to use SOAP services than to have to create them.
There is also security. For some of the SOAP services we use we have to pass a username and password... though I am unsure as to which layer controls that.
With RESTful you can implement SSL. I think RMI also has some security features.