1 55 package org.jboss.axis.message; 56 57 61 62 import org.jboss.axis.AxisFault; 63 import org.jboss.axis.Constants; 64 import org.jboss.axis.encoding.DeserializationContext; 65 import org.jboss.axis.encoding.TypeMappingRegistry; 66 import org.jboss.axis.soap.SOAPConstants; 67 import org.jboss.axis.utils.Messages; 68 import org.xml.sax.Attributes ; 69 import org.xml.sax.SAXException ; 70 import org.xml.sax.helpers.DefaultHandler ; 71 72 public class SOAPHandler extends DefaultHandler 73 { 74 public SOAPElementAxisImpl myElement = null; 75 private SOAPElementAxisImpl[] myElements; 76 private int myIndex = 0; 77 78 public SOAPHandler() 79 { 80 } 81 82 88 public SOAPHandler(SOAPElementAxisImpl[] elements, int index) 89 { 90 myElements = elements; 91 myIndex = index; 92 } 93 94 public void startElement(String namespace, String localName, 95 String prefix, Attributes attributes, 96 DeserializationContext context) 97 throws SAXException 98 { 99 SOAPConstants soapConstants = Constants.DEFAULT_SOAP_VERSION; 100 if (context.getMessageContext() != null) 101 soapConstants = context.getMessageContext().getSOAPConstants(); 102 103 104 if (soapConstants == SOAPConstants.SOAP12_CONSTANTS) 105 { 106 String encodingStyle = attributes.getValue(Constants.URI_SOAP12_ENV, 107 Constants.ATTR_ENCODING_STYLE); 108 109 if (encodingStyle != null && !encodingStyle.equals("") 110 && !encodingStyle.equals(Constants.URI_SOAP12_NOENC) 111 && !Constants.isSOAP_ENC(encodingStyle)) 112 { 113 TypeMappingRegistry tmr = context.getTypeMappingRegistry(); 114 if (tmr.getTypeMapping(encodingStyle) == tmr.getDefaultTypeMapping()) 116 { 117 AxisFault fault = new AxisFault(Constants.FAULT_SOAP12_DATAENCODINGUNKNOWN, 118 null, Messages.getMessage("invalidEncodingStyle"), null, null, null); 119 120 throw new SAXException (fault); 121 } 122 } 123 } 124 125 126 if (!context.isDoneParsing() && !context.isProcessingRef()) 128 { 129 if (myElement == null) 130 { 131 try 132 { 133 myElement = makeNewElement(namespace, localName, prefix, 134 attributes, context); 135 } 136 catch (AxisFault axisFault) 137 { 138 throw new SAXException (axisFault); 139 } 140 } 141 context.pushNewElement(myElement); 142 } 143 } 144 145 public SOAPElementAxisImpl makeNewElement(String namespace, String localName, 146 String prefix, Attributes attributes, 147 DeserializationContext context) 148 throws AxisFault 149 { 150 return new SOAPElementAxisImpl(namespace, localName, 151 prefix, attributes, context); 152 } 153 154 public void endElement(String namespace, String localName, 155 DeserializationContext context) 156 throws SAXException 157 { 158 if (myElement != null) 159 { 160 if (myElements != null) 161 { 162 myElements[myIndex] = myElement; 163 } 164 myElement.setEndIndex(context.getCurrentRecordPos()); 165 } 166 } 167 168 public SOAPHandler onStartChild(String namespace, 169 String localName, 170 String prefix, 171 Attributes attributes, 172 DeserializationContext context) 173 throws SAXException 174 { 175 SOAPHandler handler = new SOAPHandler(); 176 return handler; 177 } 178 179 public void onEndChild(String namespace, String localName, 180 DeserializationContext context) 181 throws SAXException 182 { 183 } 184 } 185 | Popular Tags |