2
* Copyright 2001-2004 The Apache Software Foundation.
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* You may obtain a copy of the License at
8
* http://www.apache.org/licenses/LICENSE-2.0
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
17
package org.apache.axis.message;
21
* @author Glen Daniels (gdaniels@allaire.com)
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;
34
public class HeaderBuilder extends SOAPHandler
36
protected static Log log =
37
LogFactory.getLog(HeaderBuilder.class.getName());
39
private SOAPHeaderElement header;
40
private SOAPEnvelope envelope;
42
HeaderBuilder(SOAPEnvelope envelope)
44
this.envelope = envelope;
47
public void startElement(String namespace, String localName,
48
String prefix, Attributes attributes,
49
DeserializationContext context)
52
SOAPConstants soapConstants = context.getSOAPConstants();
54
if (soapConstants == SOAPConstants.SOAP12_CONSTANTS &&
55
attributes.getValue(Constants.URI_SOAP12_ENV, Constants.ATTR_ENCODING_STYLE) != null) {
57
AxisFault fault = new AxisFault(Constants.FAULT_SOAP12_SENDER,
58
null, Messages.getMessage("noEncodingStyleAttrAppear", "Header"), null, null, null);
60
throw new SAXException(fault);
63
if (!context.isDoneParsing()) {
64
if (myElement == null) {
66
myElement = new SOAPHeader(namespace, localName, prefix,
68
envelope.getSOAPConstants());
69
} catch (AxisFault axisFault) {
70
throw new SAXException(axisFault);
72
envelope.setHeader((SOAPHeader)myElement);
74
context.pushNewElement(myElement);
78
public SOAPHandler onStartChild(String namespace,
81
Attributes attributes,
82
DeserializationContext context)
86
header = new SOAPHeaderElement(namespace, localName, prefix,
88
} catch (AxisFault axisFault) {
89
throw new SAXException(axisFault);
92
SOAPHandler handler = new SOAPHandler();
93
handler.myElement = header;
98
public void onEndChild(String namespace, String localName,
99
DeserializationContext context)