KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > axis2 > soap > impl > llom > soap12 > SOAP12HeaderImpl


1 package org.apache.axis2.soap.impl.llom.soap12;
2
3 import org.apache.axis2.om.OMException;
4 import org.apache.axis2.om.OMNamespace;
5 import org.apache.axis2.om.OMXMLParserWrapper;
6 import org.apache.axis2.om.impl.llom.traverse.OMChildrenWithSpecificAttributeIterator;
7 import org.apache.axis2.soap.SOAPEnvelope;
8 import org.apache.axis2.soap.SOAPHeaderBlock;
9 import org.apache.axis2.soap.impl.llom.SOAPHeaderImpl;
10 import org.apache.axis2.soap.impl.llom.SOAPProcessingException;
11
12 import javax.xml.namespace.QName JavaDoc;
13 import java.util.Iterator JavaDoc;
14
15 /**
16  * Copyright 2001-2004 The Apache Software Foundation.
17  * <p/>
18  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
19  * use this file except in compliance with the License. You may obtain a copy of
20  * the License at
21  * <p/>
22  * http://www.apache.org/licenses/LICENSE-2.0
23  * <p/>
24  * Unless required by applicable law or agreed to in writing, software
25  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
26  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
27  * License for the specific language governing permissions and limitations under
28  * the License.
29  * <p/>
30  */

31 public class SOAP12HeaderImpl extends SOAPHeaderImpl {
32     /**
33      * Eran Chinthaka (chinthaka@apache.org)
34      */

35
36     /**
37      * @param envelope
38      */

39     public SOAP12HeaderImpl(SOAPEnvelope envelope) throws SOAPProcessingException {
40         super(envelope);
41     }
42
43     /**
44      * Constructor SOAPHeaderImpl
45      *
46      * @param envelope
47      * @param builder
48      */

49     public SOAP12HeaderImpl(SOAPEnvelope envelope, OMXMLParserWrapper builder) {
50         super(envelope, builder);
51     }
52
53     public SOAPHeaderBlock addHeaderBlock(String JavaDoc localName, OMNamespace ns) throws OMException {
54         if (ns == null || ns.getName() == null || "".equals(ns.getName())) {
55             throw new OMException("All the SOAP Header blocks should be namespace qualified");
56         }
57
58         OMNamespace namespace = findNamespace(ns.getName(), ns.getPrefix());
59         if (namespace != null) {
60             ns = namespace;
61         }
62
63         SOAPHeaderBlock soapHeaderBlock = null;
64         try {
65             soapHeaderBlock = new SOAP12HeaderBlockImpl(localName, ns, this);
66         } catch (SOAPProcessingException e) {
67             throw new OMException(e);
68         }
69         soapHeaderBlock.setComplete(true);
70         return soapHeaderBlock;
71     }
72
73
74     public Iterator extractHeaderBlocks(String JavaDoc role) {
75         return new OMChildrenWithSpecificAttributeIterator(getFirstChild(),
76                 new QName JavaDoc(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI,
77                         SOAP12Constants.SOAP_ROLE),
78                 role,
79                 true);
80     }
81
82 }
83
Popular Tags