1 /*
2 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
78 if (s.isXML()) {
79 if (xmlCodec == null) xmlCodec = Codecs.createXMLCodec(features);
80 } else {
81 if (soapCodec == null) soapCodec = Codecs.createSOAPBindingCodec(features);
82 singleSoapStyle = s;
83 }
84 }
85 }
86
87 protected com.oracle.webservices.internal.api.message.MessageContextFactory newFactory(WebServiceFeature... f) {
88 return new com.sun.xml.internal.ws.api.message.MessageContextFactory(f);
89 }
90
91
92 public com.oracle.webservices.internal.api.message.MessageContext createContext() {
93 return packet(null);
94 }
95
96 public com.oracle.webservices.internal.api.message.MessageContext createContext(SOAPMessage soap) {
97 throwIfIllegalMessageArgument(soap);
98 return packet(Messages.create(soap));
99 }
100
101 public MessageContext createContext(Source m, com.oracle.webservices.internal.api.EnvelopeStyle.Style envelopeStyle) {
102 throwIfIllegalMessageArgument(m);
103 return packet(Messages.create(m, SOAPVersion.from(envelopeStyle)));
104 }
105
106 public com.oracle.webservices.internal.api.message.MessageContext createContext(Source m) {
107 throwIfIllegalMessageArgument(m);
108 return packet(Messages.create(m, SOAPVersion.from(singleSoapStyle)));
109 }
110
111 public com.oracle.webservices.internal.api.message.MessageContext createContext(InputStream in, String contentType) throws IOException {
112 throwIfIllegalMessageArgument(in);
113 //TODO when do we use xmlCodec?
114 Packet p = packet(null);
115 soapCodec.decode(in, contentType, p);
116 return p;
117 }
145 }
146 values.add(mh.getValue());
147 }
148 return map;
149 }
150
151 public MessageContext createContext(Message m) {
152 throwIfIllegalMessageArgument(m);
153 return packet(m);
154 }
155
156 private Packet packet(Message m) {
157 final Packet p = new Packet();
158 //TODO when do we use xmlCodec?
159 p.codec = soapCodec;
160 if (m != null) p.setMessage(m);
161 MTOMFeature mf = features.get(MTOMFeature.class);
162 if (mf != null) {
163 p.setMtomFeature(mf);
164 }
165 return p;
166 }
167
168 private void throwIfIllegalMessageArgument(Object message)
169 throws IllegalArgumentException
170 {
171 if (message == null) {
172 throw new IllegalArgumentException("null messages are not allowed. Consider using MessageContextFactory.createContext()");
173 }
174 }
175
176 @Deprecated
177 public com.oracle.webservices.internal.api.message.MessageContext doCreate() {
178 return packet(null);
179 }
180 @Deprecated
181 public com.oracle.webservices.internal.api.message.MessageContext doCreate(SOAPMessage m) {
182 return createContext(m);
183 }
184 @Deprecated
|
1 /*
2 * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
78 if (s.isXML()) {
79 if (xmlCodec == null) xmlCodec = Codecs.createXMLCodec(features);
80 } else {
81 if (soapCodec == null) soapCodec = Codecs.createSOAPBindingCodec(features);
82 singleSoapStyle = s;
83 }
84 }
85 }
86
87 protected com.oracle.webservices.internal.api.message.MessageContextFactory newFactory(WebServiceFeature... f) {
88 return new com.sun.xml.internal.ws.api.message.MessageContextFactory(f);
89 }
90
91
92 public com.oracle.webservices.internal.api.message.MessageContext createContext() {
93 return packet(null);
94 }
95
96 public com.oracle.webservices.internal.api.message.MessageContext createContext(SOAPMessage soap) {
97 throwIfIllegalMessageArgument(soap);
98 if (saajFactory!= null) return packet(saajFactory.createMessage(soap));
99 return packet(Messages.create(soap));
100 }
101
102 public MessageContext createContext(Source m, com.oracle.webservices.internal.api.EnvelopeStyle.Style envelopeStyle) {
103 throwIfIllegalMessageArgument(m);
104 return packet(Messages.create(m, SOAPVersion.from(envelopeStyle)));
105 }
106
107 public com.oracle.webservices.internal.api.message.MessageContext createContext(Source m) {
108 throwIfIllegalMessageArgument(m);
109 return packet(Messages.create(m, SOAPVersion.from(singleSoapStyle)));
110 }
111
112 public com.oracle.webservices.internal.api.message.MessageContext createContext(InputStream in, String contentType) throws IOException {
113 throwIfIllegalMessageArgument(in);
114 //TODO when do we use xmlCodec?
115 Packet p = packet(null);
116 soapCodec.decode(in, contentType, p);
117 return p;
118 }
146 }
147 values.add(mh.getValue());
148 }
149 return map;
150 }
151
152 public MessageContext createContext(Message m) {
153 throwIfIllegalMessageArgument(m);
154 return packet(m);
155 }
156
157 private Packet packet(Message m) {
158 final Packet p = new Packet();
159 //TODO when do we use xmlCodec?
160 p.codec = soapCodec;
161 if (m != null) p.setMessage(m);
162 MTOMFeature mf = features.get(MTOMFeature.class);
163 if (mf != null) {
164 p.setMtomFeature(mf);
165 }
166 p.setSAAJFactory(saajFactory);
167 return p;
168 }
169
170 private void throwIfIllegalMessageArgument(Object message)
171 throws IllegalArgumentException
172 {
173 if (message == null) {
174 throw new IllegalArgumentException("null messages are not allowed. Consider using MessageContextFactory.createContext()");
175 }
176 }
177
178 @Deprecated
179 public com.oracle.webservices.internal.api.message.MessageContext doCreate() {
180 return packet(null);
181 }
182 @Deprecated
183 public com.oracle.webservices.internal.api.message.MessageContext doCreate(SOAPMessage m) {
184 return createContext(m);
185 }
186 @Deprecated
|