how is java object ent over http post in xml ??

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • javatoil260309
    New Member
    • Aug 2009
    • 8

    how is java object ent over http post in xml ??

    Hi,
    I'm trying to 'POST' http request to my local server... upto now i have had success sending only 'text' string in the message body.
    I now would like to try out sending java objects. And I understand, xml is the best wy to go about it...
    I have learnt that using xsd (xml schema defination) one can instantiate xml file and then post it to the server...
    I would like to know how I can use xsd to instantiate xml ...
    I have used a sample xml to generate xsd, using visual studio xsd.exe...
  • hsriat
    Recognized Expert Top Contributor
    • Jan 2008
    • 1653

    #2
    I can think of a simple solution. And that is make methods in all classes something like toString, toXML which return XML like
    Code:
    <object class="className">
        <variable name="" value="" />
    </object>
    And then finally pack the all object XMLs in a root tag before transferring it.

    Comment

    • hsriat
      Recognized Expert Top Contributor
      • Jan 2008
      • 1653

      #3
      Wait... if you are using HTTP POST, then there's no need to converting it to XML.
      Just convert all the objects into MAPs (or SETs of MAPs) and then convert these MAPs or SETs to URI encoded string.
      You can though convert it to XML on the receiving end.

      Comment

      • JosAH
        Recognized Expert MVP
        • Mar 2007
        • 11453

        #4
        ... also read about the XMLEncoder and the XMLDecoder classes.

        kind regards,

        Jos

        Comment

        Working...