1 55 56 package org.jboss.axis.message; 57 58 62 63 import org.jboss.axis.AxisFault; 64 import org.jboss.axis.Constants; 65 import org.jboss.axis.encoding.DeserializationContext; 66 import org.jboss.axis.soap.SOAPConstants; 67 import org.jboss.axis.utils.Messages; 68 import org.jboss.logging.Logger; 69 import org.xml.sax.Attributes ; 70 import org.xml.sax.SAXException ; 71 72 import javax.xml.soap.SOAPException ; 73 74 public class HeaderBuilder extends SOAPHandler 75 { 76 private static Logger log = Logger.getLogger(HeaderBuilder.class.getName()); 77 78 private SOAPHeaderElementAxisImpl headerElement; 79 private SOAPEnvelopeAxisImpl envelope; 80 81 HeaderBuilder(SOAPEnvelopeAxisImpl envelope) 82 { 83 this.envelope = envelope; 84 } 85 86 public void startElement(String namespace, String localName, 87 String prefix, Attributes attributes, 88 DeserializationContext context) 89 throws SAXException 90 { 91 SOAPConstants soapConstants = Constants.DEFAULT_SOAP_VERSION; 92 if (context.getMessageContext() != null) 93 soapConstants = context.getMessageContext().getSOAPConstants(); 94 95 if (soapConstants == SOAPConstants.SOAP12_CONSTANTS && 96 attributes.getValue(Constants.URI_SOAP12_ENV, Constants.ATTR_ENCODING_STYLE) != null) 97 { 98 99 AxisFault fault = new AxisFault(Constants.FAULT_SOAP12_SENDER, 100 null, Messages.getMessage("noEncodingStyleAttrAppear", "Header"), null, null, null); 101 102 throw new SAXException (fault); 103 } 104 105 if (!context.isDoneParsing()) 106 { 107 if (myElement == null) 108 { 109 try 110 { 111 myElement = new SOAPHeaderAxisImpl(namespace, localName, prefix, 112 attributes, context, 113 envelope.getSOAPConstants()); 114 } 115 catch (AxisFault axisFault) 116 { 117 throw new SAXException (axisFault); 118 } 119 envelope.setHeader((SOAPHeaderAxisImpl)myElement); 120 } 121 context.pushNewElement(myElement); 122 } 123 } 124 125 public SOAPHandler onStartChild(String namespace, 126 String localName, 127 String prefix, 128 Attributes attributes, 129 DeserializationContext context) 130 throws SAXException 131 { 132 try 133 { 134 headerElement = new SOAPHeaderElementAxisImpl(namespace, localName, prefix, attributes, context); 135 headerElement.setParentElement(envelope.getHeader()); 136 } 137 catch (AxisFault axisFault) 138 { 139 throw new SAXException (axisFault); 140 } 141 catch (SOAPException e) 142 { 143 throw new SAXException (e); 144 } 145 146 SOAPHandler handler = new SOAPHandler(); 147 handler.myElement = headerElement; 148 149 return handler; 150 } 151 152 public void onEndChild(String namespace, String localName, 153 DeserializationContext context) 154 { 155 } 156 } 157 | Popular Tags |