1 16 17 package org.apache.axis.message; 18 19 23 24 import org.apache.axis.AxisFault; 25 import org.apache.axis.Constants; 26 import org.apache.axis.components.logger.LogFactory; 27 import org.apache.axis.encoding.DeserializationContext; 28 import org.apache.axis.soap.SOAPConstants; 29 import org.apache.axis.utils.Messages; 30 import org.apache.commons.logging.Log; 31 import org.xml.sax.Attributes ; 32 import org.xml.sax.SAXException ; 33 34 public class HeaderBuilder extends SOAPHandler 35 { 36 protected static Log log = 37 LogFactory.getLog(HeaderBuilder.class.getName()); 38 39 private SOAPHeaderElement header; 40 private SOAPEnvelope envelope; 41 42 HeaderBuilder(SOAPEnvelope envelope) 43 { 44 this.envelope = envelope; 45 } 46 47 public void startElement(String namespace, String localName, 48 String prefix, Attributes attributes, 49 DeserializationContext context) 50 throws SAXException 51 { 52 SOAPConstants soapConstants = context.getSOAPConstants(); 53 54 if (soapConstants == SOAPConstants.SOAP12_CONSTANTS && 55 attributes.getValue(Constants.URI_SOAP12_ENV, Constants.ATTR_ENCODING_STYLE) != null) { 56 57 AxisFault fault = new AxisFault(Constants.FAULT_SOAP12_SENDER, 58 null, Messages.getMessage("noEncodingStyleAttrAppear", "Header"), null, null, null); 59 60 throw new SAXException (fault); 61 } 62 63 if (!context.isDoneParsing()) { 64 if (myElement == null) { 65 try { 66 myElement = new SOAPHeader(namespace, localName, prefix, 67 attributes, context, 68 envelope.getSOAPConstants()); 69 } catch (AxisFault axisFault) { 70 throw new SAXException (axisFault); 71 } 72 envelope.setHeader((SOAPHeader)myElement); 73 } 74 context.pushNewElement(myElement); 75 } 76 } 77 78 public SOAPHandler onStartChild(String namespace, 79 String localName, 80 String prefix, 81 Attributes attributes, 82 DeserializationContext context) 83 throws SAXException 84 { 85 try { 86 header = new SOAPHeaderElement(namespace, localName, prefix, 87 attributes, context); 88 } catch (AxisFault axisFault) { 89 throw new SAXException (axisFault); 90 } 91 92 SOAPHandler handler = new SOAPHandler(); 93 handler.myElement = header; 94 95 return handler; 96 } 97 98 public void onEndChild(String namespace, String localName, 99 DeserializationContext context) 100 { 101 } 102 } 103 | Popular Tags |