First of all Im a bit curious why you want to use axis and bean serialization in a stand alone application. There are far better frameworks than Axis for converting beans to XML.
For example, check out JAXB and reference implementations http://java.sun.com/webservices/jaxb/index.jsp Castor can also be used. If you *really* want to do this, you should check out the static typedesc data, in the generated Axis xlasses. The typedescriptions define how the fields of the object is mapped to XML (and back I believe) Example type description section follows. Notice the elemField.setFieldName("companyName"); This is the bean property of the local object, and a method getcompanyName() is required in the bean. The following typedescription is for an entity called Company with two members companyName and companyAddress private static org.apache.axis.description.TypeDesc typeDesc = new org.apache.axis.description.TypeDesc(SetCompanyType.class, true); static { typeDesc.setXmlType(new javax.xml.namespace.QName("http://schemas.company.com", "Company")); org.apache.axis.description.ElementDesc elemField = new org.apache.axis.description.ElementDesc(); elemField.setFieldName("companyName"); elemField.setXmlName(new javax.xml.namespace.QName("http://schemas.company.com", "companyName")); elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); elemField.setNillable(false); typeDesc.addFieldDesc(elemField); elemField = new org.apache.axis.description.ElementDesc(); elemField.setFieldName("companyAddress"); elemField.setXmlName(new javax.xml.namespace.QName("http://schemas.company.com/", "companyAddress")); elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); elemField.setNillable(false); typeDesc.addFieldDesc(elemField); } Glenn Richard Bech From: sol myr [mailto:[EMAIL PROTECTED] Sent: 31. januar 2006 15:01 To: [email protected] Subject: Using BeanSerializer in standalone applications Hi, I'm trying to use Axis BeanSerializer in a stand-alone application (converting between java objects & xml). Example (assuming you have a "Customer" bean): Customer cust=new Customer("john", "ibm"); BeanSerializer ser=new BeanSerializer(Customer.class, null); SerializationContext ctx=new SerializationContext(new FileWriter("cust.xml")); ser.serialize(someQName, null, cust, ctx); My question: Can I *customize* this BeanSerializer, so as to control the XML output ? For example: - Configure xml namespaces - Configure xml tag-names (e.g. java field "Customer.surName" should be mapped to xml "< last-name >" ). Does axis allow such customization (from a stand-alone app) ? Is it somewhere on the API ? Or can you configure it from a file (similar to wsdd) ? Thanx. ________________________________________ Bring words and photos together (easily) with PhotoMail - it's free and works with Yahoo! Mail.
