01: package org.objectweb.celtix.tools.extensions.xmlformat;
02:
03: import java.io.PrintWriter;
04:
05: import javax.wsdl.Definition;
06: import javax.wsdl.WSDLException;
07: import javax.wsdl.extensions.ExtensibilityElement;
08: import javax.wsdl.extensions.ExtensionDeserializer;
09: 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,
19: ExtensionDeserializer {
20:
21: XMLUtils xmlUtils = new XMLUtils();
22:
23: public void marshall(Class parentType, QName elementType,
24: ExtensibilityElement extension, PrintWriter pw,
25: Definition def, ExtensionRegistry extReg)
26: throws WSDLException {
27:
28: XMLHttpAddress xmlHttpAddress = (XMLHttpAddress) extension;
29: StringBuffer sb = new StringBuffer(300);
30: sb.append("<" + xmlUtils.writeQName(def, elementType) + " ");
31: if (xmlHttpAddress.getLocation() != null) {
32: sb.append(ToolConstants.XMLBINDING_HTTP_LOCATION + "=\""
33: + xmlHttpAddress.getLocation() + "\"");
34: }
35: sb.append(" />");
36: pw.print(sb.toString());
37: pw.println();
38: }
39:
40: public ExtensibilityElement unmarshall(Class parentType,
41: QName elementType, Element el, Definition def,
42: ExtensionRegistry extReg) throws WSDLException {
43:
44: XMLHttpAddress xmlHttpAddress = (XMLHttpAddress) extReg
45: .createExtension(parentType, elementType);
46: xmlHttpAddress.setElement(el);
47: xmlHttpAddress.setElementType(elementType);
48: xmlHttpAddress.setDocumentBaseURI(def.getDocumentBaseURI());
49: xmlHttpAddress.setLocation(el
50: .getAttribute(ToolConstants.XMLBINDING_HTTP_LOCATION));
51: return xmlHttpAddress;
52: }
53:
54: }
|