1 8 9 package mx4j.tools.remote.soap.axis.ser; 10 11 import java.io.IOException ; 12 import java.security.Principal ; 13 import javax.xml.namespace.QName ; 14 15 import org.apache.axis.encoding.SerializationContext; 16 import org.apache.axis.encoding.XMLType; 17 import org.apache.axis.wsdl.fromJava.Types; 18 import org.w3c.dom.Element ; 19 import org.xml.sax.Attributes ; 20 21 24 public class PrincipalSer extends AxisSerializer 25 { 26 static final String TYPE = "Principal"; 27 static final String CLASS_NAME = "className"; 28 static final String NAME = "name"; 29 private static final QName CLASS_NAME_QNAME = new QName ("", CLASS_NAME); 30 private static final QName NAME_QNAME = new QName ("", NAME); 31 32 public void serialize(QName name, Attributes attributes, Object value, SerializationContext context) throws IOException 33 { 34 Principal principal = (Principal )value; 35 context.startElement(name, attributes); 36 context.serialize(CLASS_NAME_QNAME, null, principal.getClass().getName()); 37 context.serialize(NAME_QNAME, null, principal.getName()); 38 context.endElement(); 39 } 40 41 public Element writeSchema(Class javaType, Types types) throws Exception 42 { 43 Element complexType = types.createElement(SCHEMA_COMPLEX_TYPE); 44 complexType.setAttribute("name", TYPE); 45 Element allElement = types.createElement(SCHEMA_ALL); 46 complexType.appendChild(allElement); 47 Element classNameElement = types.createElement(SCHEMA_ELEMENT); 48 classNameElement.setAttribute("name", CLASS_NAME); 49 classNameElement.setAttribute("type", XMLType.XSD_STRING.getLocalPart()); 50 allElement.appendChild(classNameElement); 51 Element nameElement = types.createElement(SCHEMA_ELEMENT); 52 nameElement.setAttribute("name", NAME); 53 nameElement.setAttribute("type", XMLType.XSD_STRING.getLocalPart()); 54 allElement.appendChild(nameElement); 55 return complexType; 56 } 57 } 58 | Popular Tags |