d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Basic Server Interaction
Add Reply New Topic New Poll
Member
Posts: 6,457
Joined: Mar 12 2007
Gold: 6,745.00
Jul 22 2014 05:26pm
I'm writing an app for android that is largely finished but for the final part I need to upload information to a server and then retrieve that data at a later time. I've been in Comp Sci for a little over a year now and feel like I have a decent handle on Java but I haven't done anything with server interaction or other languages and have no idea where to start with this.

All I need to do is basically upload an array or modify an array or some other data structure and then retrieve it later. Is there some simple way to accomplish this? From what I've found so far I'm looking at setting up apache and then running some kind of php script but I don't know anything about these and don't want to spend a ton of time trying to figure these if this is major overkill for what I'm trying to do. Anybody have some pointers to get me going in the right direction with this?
Member
Posts: 32,925
Joined: Jul 23 2006
Gold: 3,804.50
Jul 22 2014 05:44pm
you can write a RESTful web service. that's typically how i interact with server side code. you can do it just fine in java if that's your preference, but you can pick your favourite language.

as for persistence, you'll probably use some sort of database. either SQL (postgres, mysql, etc) or non-sql (MongoDB, NoSQL, db4o, etc)
Member
Posts: 13,425
Joined: Sep 29 2007
Gold: 0.00
Warn: 20%
Jul 22 2014 07:42pm
Many different ways to do it depending on the data.

Can create a php file which accepts a post and dumps it to a sql db (after validity checks and such). Another way is a XML RPC server in which you can setup a remote procedure call server which accepts XML formatted data, from there you can call on a remote function on a server with data to store it.

I love XML RPC for quick shit. You can pound out a client server protocol in a few hours. I made a hash brute forcing distribution server out of it along side with hashcat. The client would pole the server for the next range to brute force while keeping a keep alive packet going. If the client fails to keep alive the server assumes it is dead and readds its job to the list.

In ruby a XML RPC server is as simple as:

Code
require "xmlrpc/server"
server = XMLRPC::Server.new( 1234 )
server.add_handler('my_test.test') { |msg|"responce for #{msg}" }
server.serve


In which you define the server and the function handler as well as what the handler does with the data. In this case it sends back the data the client sent.

As for the client:

Code
require "xmlrpc/client"
client = XMLRPC::Client.new( "localhost", "/", 1234 )
s = client.call('my_test.test','asd')
puts s


You just connect to the server and call the remote function with any number of data sets you wish to send.

I am sure java and android would have something similar, it is a pretty popular protocol.
Member
Posts: 2,217
Joined: Sep 10 2007
Gold: 35.88
Jul 23 2014 08:00am
Quote (carteblanche @ Jul 22 2014 05:44pm)
you can write a RESTful web service. that's typically how i interact with server side code. you can do it just fine in java if that's your preference, but you can pick your favourite language.

as for persistence, you'll probably use some sort of database. either SQL (postgres, mysql, etc) or non-sql (MongoDB, NoSQL, db4o, etc)


I would also opt for something along this route.
I recommended MySQL if you're not doing anything fancy.

This post was edited by grievance on Jul 23 2014 08:00am
Member
Posts: 2,754
Joined: Nov 26 2007
Gold: 1,339.81
Jul 23 2014 08:52am
just use a java servlet since you already know java
Member
Posts: 62,204
Joined: Jun 3 2007
Gold: 9,039.20
Jul 23 2014 08:58am
Quote (AbDuCt @ Jul 22 2014 07:42pm)
Many different ways to do it depending on the data.

Can create a php file which accepts a post and dumps it to a sql db (after validity checks and such). Another way is a XML RPC server in which you can setup a remote procedure call server which accepts XML formatted data, from there you can call on a remote function on a server with data to store it.

I love XML RPC for quick shit. You can pound out a client server protocol in a few hours. I made a hash brute forcing distribution server out of it along side with hashcat. The client would pole the server for the next range to brute force while keeping a keep alive packet going. If the client fails to keep alive the server assumes it is dead and readds its job to the list.

In ruby a XML RPC server is as simple as:

Code
require "xmlrpc/server"
server = XMLRPC::Server.new( 1234 )
server.add_handler('my_test.test') { |msg|"responce for #{msg}" }
server.serve


In which you define the server and the function handler as well as what the handler does with the data. In this case it sends back the data the client sent.

As for the client:

Code
require "xmlrpc/client"
client = XMLRPC::Client.new( "localhost", "/", 1234 )
s = client.call('my_test.test','asd')
puts s


You just connect to the server and call the remote function with any number of data sets you wish to send.

I am sure java and android would have something similar, it is a pretty popular protocol.


XML-RPC in my opinion, as it is very lightweight.

Not familiar with Java really but was reading this and seems to go into great detail about it: http://oreilly.com/catalog/progxmlrpc/chapter/ch03.html
Member
Posts: 4,541
Joined: Sep 15 2011
Gold: 10,391.00
Jul 23 2014 04:51pm
for java, the path of least resistance will probably be to setup a Tomcat server and write a simple java servlet.

on the client side, you can use HttpClient to connect to your server, and from there, you can choose whatever serialization protocol you wish to use, including plaintext if it's just a collect project.
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll