Hi,
Has anyone has had a look at the AddressBook demo in Apache Soap.
Incase you have seen that, can someone throw more light with respect to
generating xml feeds from a vector of java objects. The AddressBook demo
has a SOAP Client (GetAllListings.java) which uses
call.setMethodName("getAllListings");
call.setEncodingStyleURI(Constants.NS_URI_LITERAL_XML);
getAllListings method in the AddressBook Class does just the
generation of a DOM-TREE !! (Eeeks! !! )
In my project usage...
For eg. Say I have a method returning a Hashtable of
MailInformationObjects. What should I do to convert this Hashtable into
XML using Apache-SOAP.
Solutions I propose ... (a) and (b) ... (a) is straight forward but
going to be messy. (b) needs to have the configuration set up well
(a) Use something like an Element Generator like in the AddressBook
sample (part of code pasted)
public Element getAllListings()
{
DocumentBuilder xdb =
XMLParserUtils.getXMLDocBuilder();
Document doc = xdb.newDocument();
Element bookEl = doc.createElement("AddressBook");
bookEl.appendChild(doc.createTextNode("\n"));
for (Enumeration keys = name2AddressTable.keys();
keys.hasMoreElements();)
{
String name = (String)keys.nextElement();
Address address = (Address)name2AddressTable.get(name);
Element listingEl = doc.createElement("Listing");
-----
----
----
-------
---------
listingEl.appendChild(addressEl);
listingEl.appendChild(doc.createTextNode("\n "));
bookEl.appendChild(doc.createTextNode(" "));
bookEl.appendChild(listingEl);
bookEl.appendChild(doc.createTextNode("\n"));
}
return bookEl;
}
Then use this Element in the SOAP Client Program and switch to XML
Literal encoding and use the XML feed ?
(b) Use some mapping facilities of APACHE-SOAP , (WHICH I AM NOT AWARE
OF )
or use either JAXB1.0 or Castor 0.9.2 (I have used before) to
generate xml feeds from my Hashtable of MailInformation Objects!!
Has anyone ecountered this situation earlier... ? ? I am sure someone
can propose more solutions?
Pls, throw more light and roll this discussion.
Regards,
Balaji Iyer
-----Original Message-----
From: Evyatar Shoresh [mailto:[EMAIL PROTECTED]]
Sent: Thursday, August 16, 2001 3:51 PM
To: [EMAIL PROTECTED]
Subject: xml to bean convertition.
Hi,
I'm having a client-server aplication using soap as my messaging, my aim
is to send a xml document from the client that will be transfered as an
object ( pre-defined in a deployment descriptor ) to the method in the
server as a parameter.
My problem is that no matter which descriptor i use the server takes my
xml as is and transfers it to the method as an Element object.
Do you have any sample showing such a scenario?
Thanx alot.