× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Bill,
I did see several posts for XStream. I should look at it too. I haven't
tried JAXB on the System i yet. We have a couple V5R4 and one V6R1, which
Java 5 is the default (finally!).

Just to share the code real quick.

@XmlRootElement
public class Customer implements Serializable {
...

/**
* This method will return a XML version of the customer.
* <p>
* Uses the JAXB <code>Marshaller</code> to create the XML string.
*
* @return a XML version of the customer
*/
public String toXML() {
String xml = "";
//
try {
JAXBContext context = JAXBContext.newInstance(this.getClass());
Marshaller m = context.createMarshaller();
m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
ByteArrayOutputStream out = new ByteArrayOutputStream();
m.marshal(this, out);
xml = out.toString();
try {
out.close();
} catch (IOException e) {
// Nothing to do
}
} catch (JAXBException e) {
e.printStackTrace();
xml = null;
}
return xml;
}

The output:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<customer>
<billToAddress>
<addressLine>60 Broadway</addressLine>
<city>San Antonio</city>
<country>USA</country>
<name>Text Customer</name>
<state>TX</state>
<zipCode>75301</zipCode>
</billToAddress>
<countyTaxChargeable>true</countyTaxChargeable>
<customerClass>1</customerClass>
<defaultInventoryLocation>01</defaultInventoryLocation>
<emailAddress></emailAddress>
<FOBPoint></FOBPoint>
<faxNumber>210-888-8952</faxNumber>
<freightChargeable>true</freightChargeable>
<handlingChargeable>true</handlingChargeable>
<logoPath></logoPath>
<phoneNumber>210-888-8951</phoneNumber>
<routeNumber></routeNumber>
<salesRep>3</salesRep>
<salesRep>0</salesRep>
<shipTo></shipTo>
<shipToAddress>
<addressLine>60 Broadway</addressLine>
<city>San Antonio</city>
<country>USA</country>
<name>Test Customer</name>
<state>TX</state>
<zipCode>75301</zipCode>
</shipToAddress>
<stateTaxChargeable>true</stateTaxChargeable>
<statusCode>A</statusCode>
<territory>WEST</territory>
<truckStop>0</truckStop>
<URL></URL>
</customer>


James R. Perkins

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.