01: /**
02: * Licensed to the Apache Software Foundation (ASF) under one
03: * or more contributor license agreements. See the NOTICE file
04: * distributed with this work for additional information
05: * regarding copyright ownership. The ASF licenses this file
06: * to you under the Apache License, Version 2.0 (the
07: * "License"); you may not use this file except in compliance
08: * with the License. You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing,
13: * software distributed under the License is distributed on an
14: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15: * KIND, either express or implied. See the License for the
16: * specific language governing permissions and limitations
17: * under the License.
18: */package org.apache.cxf.binding.soap;
19:
20: import java.util.ArrayList;
21: import java.util.List;
22:
23: import javax.xml.namespace.QName;
24:
25: import org.apache.cxf.headers.Header;
26: import org.apache.cxf.helpers.CastUtils;
27: import org.apache.cxf.message.AbstractWrappedMessage;
28: import org.apache.cxf.message.Message;
29:
30: public class SoapMessage extends AbstractWrappedMessage {
31: private SoapVersion version = Soap11.getInstance();
32:
33: public SoapMessage(Message message) {
34: super (message);
35: }
36:
37: public SoapVersion getVersion() {
38: return version;
39: }
40:
41: public void setVersion(SoapVersion v) {
42: this .version = v;
43: }
44:
45: public List<Header> getHeaders() {
46: List<Header> heads = CastUtils
47: .cast((List<?>) get(Header.HEADER_LIST));
48: if (heads == null) {
49: heads = new ArrayList<Header>();
50: put(Header.HEADER_LIST, heads);
51: }
52: return heads;
53: }
54:
55: public boolean hasHeader(QName qn) {
56: for (Header head : getHeaders()) {
57: if (head.getName().equals(qn)) {
58: return true;
59: }
60: }
61: return false;
62: }
63:
64: public Header getHeader(QName qn) {
65: for (Header head : getHeaders()) {
66: if (head.getName().equals(qn)) {
67: return head;
68: }
69: }
70: return null;
71: }
72:
73: public boolean hasHeaders() {
74: return containsKey(Header.HEADER_LIST)
75: && getHeaders().size() > 0;
76: }
77:
78: }
|