This discussion is archived
6 Replies Latest reply: Jun 1, 2011 6:40 PM by jmart RSS

Server communication in JavaFX

865809 Newbie
Currently Being Moderated
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?
  • 1. Re: Server communication in JavaFX
    gimbal2 Guru
    Currently Being Moderated
    862806 wrote:
    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?
    JSON is a way to format data, not a communication protocol. See it as related to XML and YAML.

    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.
  • 2. Re: Server communication in JavaFX
    865809 Newbie
    Currently Being Moderated
    NO, I never think JavaFX is a replacement of java. I know JavaFX is another choice in client side.
    But I think if JavaFX can provide tools or mechanism to facilitate the client side effort in communication to server´╝î especially to java app server, JavaFX would be more successful among competitors.
  • 3. Re: Server communication in JavaFX
    jmart Explorer
    Currently Being Moderated
    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
    jose
  • 4. Re: Server communication in JavaFX
    jmart Explorer
    Currently Being Moderated
    By the way... my post is all Java... not javaFX. But as you know you can use access/call Java classes in javaFX... so this implementation will work in a javaFX application.
  • 5. Re: Server communication in JavaFX
    865809 Newbie
    Currently Being Moderated
    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.
  • 6. Re: Server communication in JavaFX
    jmart Explorer
    Currently Being Moderated
    Great points.

    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.

    thanks
    jose

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points