Sending JSON objects between .NET server and Java server - java

I'm working on a .NET Web Application that uses a Database. Whenever data is changed, instead of directly updating the Database, I need to do it through a Java Server. That is, the Web Application has no access to the database but instead gets and sends all the information from/to the Java Server through TCP Sockets, which in turn handles the Database. Basically, I need to send JSON serialized objects from the .NET Server to the Java Server back and forth. What is the best approach to use in this situation? What DataStreams should I use on each side?

Related

How can i Get back source data of data contained in a script PHP with Java

I explain, I tried to open my database .sqlite contained in my server in Java with jdbc:sqlite:mydb, but it doesn't work because my database ".sqlite" is distant so i creat a script php based on my server which gets back me all of my databases.
So my question How can i Get back source data of data contained in a script PHP with Java?
Thanks a lot!
PS : Sorry for my english (I'm french)
One way would be to create a service in PHP which offers the data, so that your Java application can consume it.
E.g. PHP can expose the data in an XML or JSON format, for instance over HTTP. Your Java application would then call the HTTP URL and receive the data in JSON/XML/whatever, and then parse it to extract the data from that format.
There are other ways as well, e.g. a service bus could broker the data between the different systems, but that requires much more setup (though in the long run, it does have value, if you keep adding data that you want to expose to more and more systems).
You can create PHP WebService server and write some functions to operate that databases data for fixing your problems. Then just use Java to connect with soap to your created WebService functions.
How to start webservice, try to read this one:
http://greatgandhi.wordpress.com/2009/11/25/create-a-php-webservice-in-5min-using-php-soap-and-wsdl-technology-nusoap/
Its the best way i know, if you need to send some data back to your remote db. Its a little more complicated, but much more correct way to operate remote data.

What to I need to do to on my server to communicate with an Android app?

I am currently writing and Android app, and I need to do some stuff with a server. Actually I just don't know where to begin, since I don't know very much about server side.
My Android app will send Java objects and images to my server, so what do I need to write or use on my server ? Is it possible to write Java code instead of PHP on the server side ?
Could you please give me the steps to prepare my server ?
Is it possible to write Java code instead of PHP on the server side ?
You can use any programming language you like for server side programming. This question provides some useful information on various Java based approaches using the HTTP protocol.
will send Java objects
You will need to serialise them to a data format. JSON and XML are popular for transmitting structured data across HTTP.
and images to my server
HTTP allows the transmission of files and Java can construct the request.
I see that you just want to communicate between the server and client(Android). I would recommend considering REST style web service for your server, where you can use either JSON (recommended) or XML format.
How to implement REST in a web application?

Communicating between 2008 SQL Server DB and Android App

I've been doing a lot of reading about this subject and I am now of the conclusion that to communicate between a 2008 SQL Server database and an Android application, I need to create a RESTful Service to sit in between that returns JSON objects.
Would I be correct in saying that?
Yes, you need doing a server application who take data and returns to the Android application. JSON let you return complex objects.

Migrating Ajax web application to web socket

I think I'm just missing a little detail that is preventing me from seeing the whole picture.
I have a web application which use ajax request every x time to update client with new information or tasks.
I also have a long running process on the server which is a java computation engine. I would like this engine to send update to the client.
I am wondering how to migrate my web app to using websocket. Probably phpwebsocket or similar. Can my server 'decide' to send information to a specific client? It seems possible looking at the php-websocket.
Can my java backend long process use the websocket server to send notification to a specific client. How? well I can say that my java app could use a class that could send over websocket instead of http.
But how the websocket server knows to which client to send the 'info'. I am puzzle by all this. Any document that explain this in more details? It seems that the websocket could create an instance of my web application.
Thanks
Your server, which will have an arbitrary number of active client sockets, decides which ones to write to (possibly in response to input from the user).
phpwebsocket (which is still very rough around the edges) has a User class with $id, $socket (this is the underlying TCP socket), and $handshake fields. You could extend that class with additional metadata about the User (e.g. a computation identifier). Or you could use an array mapping from computation id to User.
Perhaps when Java computation n finishes, you can look up the socket associated with that computation, and write to its socket.

How to create a database connectivity sqlserver2000 through J2ME?

I want some helps from the professional people who know a lot in theJ2Me. I work on a mobile application that the user will be stored and retreve the data from the database using sqlserver 2000.
I am new in this area ( J2ME ) and I don’t know a lot, so I want help.
one more,
j2me is not directly support the database connectivity for that purpose we can achive with the help of servlets. Insted of servlets can we use JSP's for databaseconnectvity.
There is no standard JDBC on J2ME.
The typical implementation of what you are trying to do is to have your J2ME client make HTTP requests to a remote server.
The body of the request is made up of your own data transfer and security protocol.
The remote server decodes the request body, creates an SQL request, runs it on SQLServer, encodes the result, sends it to the J2ME client as a reply to the initial http request.
The J2ME client is then free to decode and process the SQL request result in any way it likes.
Using servlets or JSPs is your call, you can use either. Also you need to ensure that you return only very minimal data, say maybe content of 20 to 50 rows depending upon the rows size. Dont send XML or other textual data, rather send them as a binary stream which you can create using the DataOutputStream class.

Categories