• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Passing around java object

 
Jack Adams
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have MyClass that will be on TomCat.
I have a "procedure" that will be run on BEA(maybe others). This service queries DB that returns a java object.
I plan to call a servlet on BEA that returns this object.
So, MyClass in TomCat sends request to BEA servlet using java.net classes. Response from BEA sends back java object.
Seems ok? I want to avoid VPN to BEA. Should I be looking at different solution? How do I return java object? I have so far only returned text and such.
I would prefer something simple.
Any ideas/comments?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65229
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jack Adams wrote:sends request to BEA servlet using java.net classes.

We'll need more detail on this step.

Are you sending an HTTP request? If so, you are limited to text which is all that is supported by the protocol.

If you want true RPC capability you'll need to explore other mechanisms. Perhaps RMI?

In any case, this isn't a web services question as far as I can tell, so it's been moved along to a more appropriate forum.
 
Jack Adams
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hoping HTTP request

P.S. Any way of getting question out of sockets and protocols.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65229
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Again, if you need to use HTTP, you are limited to text responses. Is that what you want?
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13074
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This service queries DB that returns a java object.


In what form does this DB return a Java object?

You can serialize Java objects and move them around with HTTP just like other binary streams.

Bill
 
Peer Reynders
Bartender
Posts: 2968
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
RMI can work over HTTP (HTTP Tunneling). See:
Frequently Asked Questions: JavaTM RMI and Object Serialization
C.10 How can I make outgoing Java RMI calls through a local firewall?
rmiservlethandler.zip
However:
The major disadvantage of HTTP tunneling is that it does not permit inward calls or multiplexed connections. A secondary disadvantage is that the http-to-cgi method opens a dramatic security hole on the server side, since without modification it will redirect any incoming request to any port.

With servlets you are dealing with "the Web" and "the Web" doesn't know anything about Java or Java objects - it's all about the HTTP protocol and IANA MIME Media Types (as specified by the HTTP Content-Type entity-header). JSPs generate "text/html" content - that is HTML intended for consumption by web browsers. Ultimately you are interrested in the data that is the result of your DB query. Popular web content-types for machine-readable data are "application/xml" and "application/json". "application/json" is more targeted towards consumption by browser-based JavaScript code as it is the case with the Google AJAX Search API (Using Google's AJAX Search API with Java (2008-Jun-10)).

"application/xml" carries the data within an XML document - this approach is often referred to as "POX over HTTP" (POX: plain old XML). You can simply use XML Schema to define the documents to carry your query and result set data and then use something like JAXB (Object Serialization with the JAXB Libraries†) to do the XML-to-Java (unmarshal) and Java-to-XML (marshal) translation work for you. SOAP web services take this approach to the extreme as they carry the XML document as the "payload" in their "body" while they use SOAP headers for all sorts of enterprisy extensions.

† This tip is based on JAXB 1.0 that was part of the Java Developer Web Services Pack - however the approach is valid for JAXB 2.0 which is part of Java 6 (or can be used with Java 5) and the sample code contains a JAXBServlet.java which could be used as a starting point
 
Sandeep Kumar Jakkaraju
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I can tell you about BlazeDS ....it converts Java Object into a Action Script Object .....!!!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic