Confused about websockets and java - java

I have been looking at tutorials like this, java websockets using Tyrus and I see a server implementation, a java client, and a javascript client. I was expecting only a server implementation and a javascript client to handle messages from the server. Why is there a java client? If I am running my application with a browser then do I skip the Java client?

Yes. It's just an example, they could have Ruby, Python and C clients too. It just shows that it's not limited to only Javascript clients.

Related

Bayeux/CometD C Lang Client

I'am trying to connect a WebRTC C client to a Java Server under CometD through Websocket.
The problem is that, it is not possible to use regular websocket libraries like "Libwebsockets" to handshake the Java Bayeux Server.
Is there any C library that allows us to handshake a Bayeux Server or let us make a custom handshake form ?
If not, i will have to code my own connector.
This scenario taken into account, do you have any ideas where to start or
what to use to allow me to make a custom handshake form in C ?
Any help would be much appreciated.
The Bayeux protocol is defined here.
In itself, the protocol is quite simple, and there are two implementations in the CometD project: one in JavaScript and one in Java.
A C implementation was discussed a while back, but lacked traction, so it was never implemented.
Perhaps it won't be impossible to call the Java implementation via JNI, but of course that has its drawbacks.
You are more than welcome to discuss this in the CometD mailing list or on a CometD issue.

how to create a Server in PHP and client in JAVA

I like to implement server as backend server service and front as a regular website using php..Is it possible to create like this.Also how can integrate this by using a java swing application as client (client is on localhost)?
You may use web services. So you can create server in php and client in java.

Does Java handle HTTPS encoding behind the scenes when I call my SOAP service?

In Java, I am building a stand alone web service client that manipulates records in a cloud based CRM by using its SOAP API. I generated my classes using the wsimport utility with WSDLs that all have addresses prefixed with https in the port binding section of the WSDL. Is Java handling behind the scenes all the wire-level security simply because the address is https? If so, how can I confirm that the SOAP message is being encrypted? My code does work, and I have not needed to worry about security until now, because I am developing in a staging environment with temporary passwords.
Thank you for your help!
Putting https in the URL will almost always do the trick. Even if your code is not capable of https, the webserver at the other end will almost never allow you to talk in HTTP when using the HTTPS port. At least, I've never seen one that does.
It's not a 100% guarantee that you'd bet your business on, but it is close.
If the code you write works on any website that does require https, you are the rest of the way there in terms of assurances.
You can confirm the traffic is encrypted by running a traffic analyzer aka packet sniffer.

Is possible to get the server and language information from a web server?

I'm connection to web servers using HttpURLConnection.
Is there a way to ask to the server to send the language that the page is built (PHP, Java, Python, Ruby, etc) and the web server that is running (Apache, ISS, etc.)?
As web servers just deliver whatever the end content is (html/javascript/a mp3 -- whatever), they are only obligated to tell you what the content they are giving you is, not how they created it. Often you will find a Server header that tells you the Apache/PHP version, but most people see that as as security vulnerability and a lot of people will disable it.
The two headers you'll want to look for are Server and X-Powered-By.
http://en.wikipedia.org/wiki/List_of_HTTP_header_fields
As far as I know, no servers have any kind of built in API for asking what the server is. If you own the server you're wondering this about, you could of course make an API with JSP or PHP or whatever. I'm assuming that's not the case though or you'd already know :).

How to facilitate communication between php script on a server to a running Java application on another server?

How to establish a way for Java application to listen to data being sent by php ? Sockets or Http POST ?
Essentially, I have Java application running on another server waiting for certain string data sent by PHP script running on other server.
Any library suggestions or example codes will be appreciated.
I suggest implementing a REST api. If you can't or don't want to, using sockets is the most secure way...
If you are sending FROM php, I recommend using a RESTful API with authentication. Send JSON data, get JSON data back. It allows for better future expansion too.
Your best bet is probably going to be to set up a java servlet "container" (server), such as tomcat (you can pay a lot of money for something else, if you have to for corporate reasons).
http://tomcat.apache.org/
http://tomcat.apache.org/tomcat-5.5-doc/servletapi/javax/servlet/ServletRequest.html#getReader()
or
http://tomcat.apache.org/tomcat-5.5-doc/servletapi/javax/servlet/ServletRequest.html#getInputStream()
Be aware there is a bit of work up front, just to set up and host "hello.jsp", but adding the mapping for the "myservice" servlet in web.xml is not too bad.

Categories