1 package org.objectweb.celtix.tools.extensions.xmlformat; 2 3 import java.io.PrintWriter ; 4 5 import javax.wsdl.Definition; 6 import javax.wsdl.WSDLException; 7 import javax.wsdl.extensions.ExtensibilityElement; 8 import javax.wsdl.extensions.ExtensionDeserializer; 9 import javax.wsdl.extensions.ExtensionRegistry; 10 import javax.wsdl.extensions.ExtensionSerializer; 11 import javax.xml.namespace.QName ; 12 13 import org.w3c.dom.Element ; 14 15 import org.objectweb.celtix.helpers.XMLUtils; 16 import org.objectweb.celtix.tools.common.ToolConstants; 17 18 public class XMLHttpSerializer implements ExtensionSerializer, ExtensionDeserializer { 19 20 XMLUtils xmlUtils = new XMLUtils(); 21 public void marshall(Class parentType, QName elementType, ExtensibilityElement extension, PrintWriter pw, 22 Definition def, ExtensionRegistry extReg) throws WSDLException { 23 24 XMLHttpAddress xmlHttpAddress = (XMLHttpAddress)extension; 25 StringBuffer sb = new StringBuffer (300); 26 sb.append("<" + xmlUtils.writeQName(def, elementType) + " "); 27 if (xmlHttpAddress.getLocation() != null) { 28 sb.append(ToolConstants.XMLBINDING_HTTP_LOCATION + "=\"" + xmlHttpAddress.getLocation() + "\""); 29 } 30 sb.append(" />"); 31 pw.print(sb.toString()); 32 pw.println(); 33 } 34 35 public ExtensibilityElement unmarshall(Class parentType, QName elementType, Element el, Definition def, 36 ExtensionRegistry extReg) throws WSDLException { 37 38 XMLHttpAddress xmlHttpAddress = (XMLHttpAddress)extReg.createExtension(parentType, elementType); 39 xmlHttpAddress.setElement(el); 40 xmlHttpAddress.setElementType(elementType); 41 xmlHttpAddress.setDocumentBaseURI(def.getDocumentBaseURI()); 42 xmlHttpAddress.setLocation(el.getAttribute(ToolConstants.XMLBINDING_HTTP_LOCATION)); 43 return xmlHttpAddress; 44 } 45 46 } 47 | Popular Tags |