views:

57

answers:

3

I am writing a client server iPhone app. The server is J2EE based. I need to communicate the state of my client object (objective C) to the server. It is possible (and feasible) to say encode the objective C object, send the bytes to the J2EE server through a socket and create a Java object out of this stream. If so, can you kindly point me to a starting point.

Thanks in advance

+5  A: 

Anything is possible, but that does not make it feasible. Except the technical difficulties these interfaces tend over time to create a lot of management headaches, example when one or both sides perform an upgrade.

I would seriously consider using some encoding to some platform neutral format like protobuf, thrift, JSON, XML or similar.

Peter Tillemans
Especially if you use something like Xstream on the server and equivalent on the client, you can effectively pass Java/ObjC objects back and forth with an extra step of calling "toString()"
Chris Thompson
+1  A: 

It sounds like it would be easier to serialize the Objective-C object to XML, JSON, or another text-based representation and ingest and unmarshal that in Java. To return it, reverse the process.

Andy
+1  A: 

There are myriad ways to skin this cat. If you are using J2EE, you might even consider using a standard means of communication rather than rolling your own. For example, you could use a webservice, REST, etc. Objectice-C has good support for HTTP connections and it is fairly trivial to create an XML or JSON payload. SudzC is a great tool for creating a client proxy from WSDL.

Here are a few tools on the Objective-C side:

json-framework
SudzC

Wayne Hartman