src/share/jaxws_classes/com/sun/xml/internal/ws/encoding/SOAPBindingCodec.java

Fri, 14 Feb 2014 11:13:45 +0100

author
mkos
date
Fri, 14 Feb 2014 11:13:45 +0100
changeset 515
6cd506508147
parent 368
0989ad8c0860
child 637
9c07ef4934dd
permissions
-rw-r--r--

8026188: Enhance envelope factory
Summary: Avoiding caching data initialized via TCCL in static context; fix also reviewed by Alexander Fomin
Reviewed-by: ahgross, mgrebac, skoivu

ohair@286 1 /*
alanb@368 2 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
ohair@286 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
ohair@286 4 *
ohair@286 5 * This code is free software; you can redistribute it and/or modify it
ohair@286 6 * under the terms of the GNU General Public License version 2 only, as
ohair@286 7 * published by the Free Software Foundation. Oracle designates this
ohair@286 8 * particular file as subject to the "Classpath" exception as provided
ohair@286 9 * by Oracle in the LICENSE file that accompanied this code.
ohair@286 10 *
ohair@286 11 * This code is distributed in the hope that it will be useful, but WITHOUT
ohair@286 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
ohair@286 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
ohair@286 14 * version 2 for more details (a copy is included in the LICENSE file that
ohair@286 15 * accompanied this code).
ohair@286 16 *
ohair@286 17 * You should have received a copy of the GNU General Public License version
ohair@286 18 * 2 along with this work; if not, write to the Free Software Foundation,
ohair@286 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
ohair@286 20 *
ohair@286 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
ohair@286 22 * or visit www.oracle.com if you need additional information or have any
ohair@286 23 * questions.
ohair@286 24 */
ohair@286 25
ohair@286 26 package com.sun.xml.internal.ws.encoding;
ohair@286 27
ohair@286 28 import com.sun.xml.internal.ws.api.SOAPVersion;
ohair@286 29 import com.sun.xml.internal.ws.api.WSFeatureList;
ohair@286 30 import com.sun.xml.internal.ws.api.client.SelectOptimalEncodingFeature;
ohair@286 31 import com.sun.xml.internal.ws.api.fastinfoset.FastInfosetFeature;
ohair@286 32 import com.sun.xml.internal.ws.api.message.Message;
ohair@286 33 import com.sun.xml.internal.ws.api.message.Packet;
ohair@286 34 import com.sun.xml.internal.ws.api.message.ExceptionHasMessage;
ohair@286 35 import com.sun.xml.internal.ws.api.pipe.Codec;
ohair@286 36 import com.sun.xml.internal.ws.api.pipe.Codecs;
ohair@286 37 import com.sun.xml.internal.ws.api.pipe.ContentType;
ohair@286 38 import com.sun.xml.internal.ws.api.pipe.StreamSOAPCodec;
ohair@286 39 import com.sun.xml.internal.ws.client.ContentNegotiation;
ohair@286 40 import com.sun.xml.internal.ws.protocol.soap.MessageCreationException;
ohair@286 41 import com.sun.xml.internal.ws.resources.StreamingMessages;
ohair@286 42 import com.sun.xml.internal.ws.server.UnsupportedMediaException;
ohair@286 43 import static com.sun.xml.internal.ws.binding.WebServiceFeatureList.getSoapVersion;
ohair@286 44
ohair@286 45 import javax.xml.ws.WebServiceException;
ohair@286 46 import javax.xml.ws.WebServiceFeature;
ohair@286 47 import javax.xml.ws.soap.MTOMFeature;
ohair@286 48 import java.io.IOException;
ohair@286 49 import java.io.InputStream;
ohair@286 50 import java.io.OutputStream;
ohair@286 51 import java.lang.reflect.Method;
ohair@286 52 import java.nio.channels.ReadableByteChannel;
ohair@286 53 import java.nio.channels.WritableByteChannel;
alanb@368 54 //import java.util.StringTokenizer;
ohair@286 55
ohair@286 56 /**
ohair@286 57 * SOAP binding {@link Codec} that can handle MTOM, SwA, and SOAP messages
ohair@286 58 * encoded using XML or Fast Infoset.
ohair@286 59 *
ohair@286 60 * <p>
ohair@286 61 * This is used when we need to determine the encoding from what we received (for decoding)
ohair@286 62 * and from configuration and {@link Message} contents (for encoding)
ohair@286 63 *
ohair@286 64 * <p>
ohair@286 65 * TODO: Split this Codec into two, one that supports FI and one that does not.
ohair@286 66 * Then further split the FI Codec into two, one for client and one for
ohair@286 67 * server. This will simplify the logic and make it easier to understand/maintain.
ohair@286 68 *
ohair@286 69 * @author Vivek Pandey
ohair@286 70 * @author Kohsuke Kawaguchi
ohair@286 71 */
ohair@286 72 public class SOAPBindingCodec extends MimeCodec implements com.sun.xml.internal.ws.api.pipe.SOAPBindingCodec {
ohair@286 73
ohair@286 74 public static final String UTF8_ENCODING = "utf-8";
ohair@286 75 public static final String DEFAULT_ENCODING = UTF8_ENCODING;
ohair@286 76
ohair@286 77
ohair@286 78 /**
ohair@286 79 * True if Fast Infoset functionality has been
ohair@286 80 * configured to be disabled, or the Fast Infoset
ohair@286 81 * runtime is not available.
ohair@286 82 */
ohair@286 83 private boolean isFastInfosetDisabled;
ohair@286 84
ohair@286 85 /**
ohair@286 86 * True if the Fast Infoset codec should be used for encoding.
ohair@286 87 */
ohair@286 88 private boolean useFastInfosetForEncoding;
ohair@286 89
ohair@286 90 /**
ohair@286 91 * True if the content negotiation property should
ohair@286 92 * be ignored by the client. This will be used in
ohair@286 93 * the case of Fast Infoset being configured to be
ohair@286 94 * disabled or automatically selected.
ohair@286 95 */
ohair@286 96 private boolean ignoreContentNegotiationProperty;
ohair@286 97
ohair@286 98 // The XML SOAP codec
ohair@286 99 private final StreamSOAPCodec xmlSoapCodec;
ohair@286 100
ohair@286 101 // The Fast Infoset SOAP codec
ohair@286 102 private final Codec fiSoapCodec;
ohair@286 103
ohair@286 104 // The XML MTOM codec
ohair@286 105 private final MimeCodec xmlMtomCodec;
ohair@286 106
ohair@286 107 // The XML SWA codec
ohair@286 108 private final MimeCodec xmlSwaCodec;
ohair@286 109
ohair@286 110 // The Fast Infoset SWA codec
ohair@286 111 private final MimeCodec fiSwaCodec;
ohair@286 112
ohair@286 113 /**
ohair@286 114 * The XML SOAP MIME type
ohair@286 115 */
ohair@286 116 private final String xmlMimeType;
ohair@286 117
ohair@286 118 /**
ohair@286 119 * The Fast Infoset SOAP MIME type
ohair@286 120 */
ohair@286 121 private final String fiMimeType;
ohair@286 122
ohair@286 123 /**
ohair@286 124 * The Accept header for XML encodings
ohair@286 125 */
ohair@286 126 private final String xmlAccept;
ohair@286 127
ohair@286 128 /**
ohair@286 129 * The Accept header for Fast Infoset and XML encodings
ohair@286 130 */
ohair@286 131 private final String connegXmlAccept;
ohair@286 132
ohair@286 133 public StreamSOAPCodec getXMLCodec() {
ohair@286 134 return xmlSoapCodec;
ohair@286 135 }
ohair@286 136
alanb@368 137 private ContentTypeImpl setAcceptHeader(Packet p, ContentTypeImpl c) {
alanb@368 138 String _accept;
alanb@368 139 if (!ignoreContentNegotiationProperty && p.contentNegotiation != ContentNegotiation.none) {
alanb@368 140 _accept = connegXmlAccept;
alanb@368 141 } else {
alanb@368 142 _accept = xmlAccept;
ohair@286 143 }
alanb@368 144 c.setAcceptHeader(_accept);
alanb@368 145 return c;
ohair@286 146 }
ohair@286 147
ohair@286 148 public SOAPBindingCodec(WSFeatureList features) {
ohair@286 149 this(features, Codecs.createSOAPEnvelopeXmlCodec(features));
ohair@286 150 }
ohair@286 151
ohair@286 152 public SOAPBindingCodec(WSFeatureList features, StreamSOAPCodec xmlSoapCodec) {
ohair@286 153 super(getSoapVersion(features), features);
ohair@286 154
ohair@286 155 this.xmlSoapCodec = xmlSoapCodec;
ohair@286 156 xmlMimeType = xmlSoapCodec.getMimeType();
ohair@286 157
ohair@286 158 xmlMtomCodec = new MtomCodec(version, xmlSoapCodec, features);
ohair@286 159
ohair@286 160 xmlSwaCodec = new SwACodec(version, features, xmlSoapCodec);
ohair@286 161
ohair@286 162 String clientAcceptedContentTypes = xmlSoapCodec.getMimeType() + ", " +
ohair@286 163 xmlMtomCodec.getMimeType();
ohair@286 164
ohair@286 165 WebServiceFeature fi = features.get(FastInfosetFeature.class);
ohair@286 166 isFastInfosetDisabled = (fi != null && !fi.isEnabled());
ohair@286 167 if (!isFastInfosetDisabled) {
ohair@286 168 fiSoapCodec = getFICodec(xmlSoapCodec, version);
ohair@286 169 if (fiSoapCodec != null) {
ohair@286 170 fiMimeType = fiSoapCodec.getMimeType();
ohair@286 171 fiSwaCodec = new SwACodec(version, features, fiSoapCodec);
ohair@286 172 connegXmlAccept = fiMimeType + ", " + clientAcceptedContentTypes;
ohair@286 173
ohair@286 174 /**
ohair@286 175 * This feature will only be present on the client side.
ohair@286 176 *
ohair@286 177 * Fast Infoset is enabled on the client if the service
ohair@286 178 * explicitly supports Fast Infoset.
ohair@286 179 */
ohair@286 180 WebServiceFeature select = features.get(SelectOptimalEncodingFeature.class);
ohair@286 181 if (select != null) { // if the client FI feature is set - ignore negotiation property
ohair@286 182 ignoreContentNegotiationProperty = true;
ohair@286 183 if (select.isEnabled()) {
ohair@286 184 // If the client's FI encoding feature is enabled, and server's is not disabled
ohair@286 185 if (fi != null) { // if server's FI feature also enabled
ohair@286 186 useFastInfosetForEncoding = true;
ohair@286 187 }
ohair@286 188
ohair@286 189 clientAcceptedContentTypes = connegXmlAccept;
ohair@286 190 } else { // If client FI feature is disabled
ohair@286 191 isFastInfosetDisabled = true;
ohair@286 192 }
ohair@286 193 }
ohair@286 194 } else {
ohair@286 195 // Fast Infoset could not be loaded by the runtime
ohair@286 196 isFastInfosetDisabled = true;
ohair@286 197 fiSwaCodec = null;
ohair@286 198 fiMimeType = "";
ohair@286 199 connegXmlAccept = clientAcceptedContentTypes;
ohair@286 200 ignoreContentNegotiationProperty = true;
ohair@286 201 }
ohair@286 202 } else {
ohair@286 203 // Fast Infoset is explicitly not supported by the service
ohair@286 204 fiSoapCodec = fiSwaCodec = null;
ohair@286 205 fiMimeType = "";
ohair@286 206 connegXmlAccept = clientAcceptedContentTypes;
ohair@286 207 ignoreContentNegotiationProperty = true;
ohair@286 208 }
ohair@286 209
ohair@286 210 xmlAccept = clientAcceptedContentTypes;
ohair@286 211
ohair@286 212 if(getSoapVersion(features) == null)
ohair@286 213 throw new WebServiceException("Expecting a SOAP binding but found ");
ohair@286 214 }
ohair@286 215
ohair@286 216 public String getMimeType() {
ohair@286 217 return null;
ohair@286 218 }
ohair@286 219
ohair@286 220 public ContentType getStaticContentType(Packet packet) {
ohair@286 221 ContentType toAdapt = getEncoder(packet).getStaticContentType(packet);
alanb@368 222 return setAcceptHeader(packet, (ContentTypeImpl)toAdapt);
ohair@286 223 }
ohair@286 224
ohair@286 225 public ContentType encode(Packet packet, OutputStream out) throws IOException {
ohair@286 226 preEncode(packet);
alanb@368 227 ContentType ct = getEncoder(packet).encode(packet, out);
alanb@368 228 ct = setAcceptHeader(packet, (ContentTypeImpl)ct);
ohair@286 229 postEncode();
ohair@286 230 return ct;
ohair@286 231 }
ohair@286 232
ohair@286 233 public ContentType encode(Packet packet, WritableByteChannel buffer) {
ohair@286 234 preEncode(packet);
alanb@368 235 ContentType ct = getEncoder(packet).encode(packet, buffer);
alanb@368 236 ct = setAcceptHeader(packet, (ContentTypeImpl)ct);
ohair@286 237 postEncode();
ohair@286 238 return ct;
ohair@286 239 }
ohair@286 240
ohair@286 241 /**
ohair@286 242 * Should be called before encode().
ohair@286 243 * Set the state so that such state is used by encode process.
ohair@286 244 */
ohair@286 245 private void preEncode(Packet p) {
ohair@286 246 }
ohair@286 247
ohair@286 248 /**
ohair@286 249 * Should be called after encode()
ohair@286 250 * Reset the encoding state.
ohair@286 251 */
ohair@286 252 private void postEncode() {
ohair@286 253 }
ohair@286 254
ohair@286 255 /**
ohair@286 256 * Should be called before decode().
ohair@286 257 * Set the state so that such state is used by decode().
ohair@286 258 */
ohair@286 259 private void preDecode(Packet p) {
ohair@286 260 if (p.contentNegotiation == null)
ohair@286 261 useFastInfosetForEncoding = false;
ohair@286 262 }
ohair@286 263
ohair@286 264 /**
ohair@286 265 * Should be called after decode().
ohair@286 266 * Set the state so that such state is used by encode().
ohair@286 267 */
ohair@286 268 private void postDecode(Packet p) {
alanb@368 269 p.setFastInfosetDisabled(isFastInfosetDisabled);
alanb@368 270 if(features.isEnabled(MTOMFeature.class)) p.checkMtomAcceptable();
alanb@368 271 // p.setMtomAcceptable( isMtomAcceptable(p.acceptableMimeTypes) );
alanb@368 272 MTOMFeature mtomFeature = features.get(MTOMFeature.class);
alanb@368 273 if (mtomFeature != null) {
alanb@368 274 p.setMtomFeature(mtomFeature);
alanb@368 275 }
ohair@286 276 if (!useFastInfosetForEncoding) {
alanb@368 277 useFastInfosetForEncoding = p.getFastInfosetAcceptable(fiMimeType);
alanb@368 278 // useFastInfosetForEncoding = isFastInfosetAcceptable(p.acceptableMimeTypes);
ohair@286 279 }
ohair@286 280 }
ohair@286 281
ohair@286 282 public void decode(InputStream in, String contentType, Packet packet) throws IOException {
ohair@286 283 if (contentType == null) {
ohair@286 284 contentType = xmlMimeType;
ohair@286 285 }
alanb@368 286 packet.setContentType(new ContentTypeImpl(contentType));
ohair@286 287 preDecode(packet);
ohair@286 288 try {
ohair@286 289 if(isMultipartRelated(contentType))
ohair@286 290 // parse the multipart portion and then decide whether it's MTOM or SwA
ohair@286 291 super.decode(in, contentType, packet);
ohair@286 292 else if(isFastInfoset(contentType)) {
ohair@286 293 if (!ignoreContentNegotiationProperty && packet.contentNegotiation == ContentNegotiation.none)
ohair@286 294 throw noFastInfosetForDecoding();
ohair@286 295
ohair@286 296 useFastInfosetForEncoding = true;
ohair@286 297 fiSoapCodec.decode(in, contentType, packet);
ohair@286 298 } else
ohair@286 299 xmlSoapCodec.decode(in, contentType, packet);
ohair@286 300 } catch(RuntimeException we) {
ohair@286 301 if (we instanceof ExceptionHasMessage || we instanceof UnsupportedMediaException) {
ohair@286 302 throw we;
ohair@286 303 } else {
ohair@286 304 throw new MessageCreationException(version, we);
ohair@286 305 }
ohair@286 306 }
ohair@286 307 postDecode(packet);
ohair@286 308 }
ohair@286 309
ohair@286 310 public void decode(ReadableByteChannel in, String contentType, Packet packet) {
ohair@286 311 if (contentType == null) {
ohair@286 312 throw new UnsupportedMediaException();
ohair@286 313 }
ohair@286 314
ohair@286 315 preDecode(packet);
ohair@286 316 try {
ohair@286 317 if(isMultipartRelated(contentType))
ohair@286 318 super.decode(in, contentType, packet);
ohair@286 319 else if(isFastInfoset(contentType)) {
ohair@286 320 if (packet.contentNegotiation == ContentNegotiation.none)
ohair@286 321 throw noFastInfosetForDecoding();
ohair@286 322
ohair@286 323 useFastInfosetForEncoding = true;
ohair@286 324 fiSoapCodec.decode(in, contentType, packet);
ohair@286 325 } else
ohair@286 326 xmlSoapCodec.decode(in, contentType, packet);
ohair@286 327 } catch(RuntimeException we) {
ohair@286 328 if (we instanceof ExceptionHasMessage || we instanceof UnsupportedMediaException) {
ohair@286 329 throw we;
ohair@286 330 } else {
ohair@286 331 throw new MessageCreationException(version, we);
ohair@286 332 }
ohair@286 333 }
ohair@286 334 postDecode(packet);
ohair@286 335 }
ohair@286 336
ohair@286 337 public SOAPBindingCodec copy() {
ohair@286 338 return new SOAPBindingCodec(features, (StreamSOAPCodec)xmlSoapCodec.copy());
ohair@286 339 }
ohair@286 340
ohair@286 341 @Override
ohair@286 342 protected void decode(MimeMultipartParser mpp, Packet packet) throws IOException {
ohair@286 343 // is this SwA or XOP?
ohair@286 344 final String rootContentType = mpp.getRootPart().getContentType();
alanb@368 345 boolean isMTOM = isApplicationXopXml(rootContentType);
alanb@368 346 packet.setMtomRequest(isMTOM);
alanb@368 347 if(isMTOM) {
ohair@286 348 xmlMtomCodec.decode(mpp,packet);
ohair@286 349 } else if (isFastInfoset(rootContentType)) {
ohair@286 350 if (packet.contentNegotiation == ContentNegotiation.none)
ohair@286 351 throw noFastInfosetForDecoding();
ohair@286 352
ohair@286 353 useFastInfosetForEncoding = true;
ohair@286 354 fiSwaCodec.decode(mpp,packet);
ohair@286 355 } else if (isXml(rootContentType))
ohair@286 356 xmlSwaCodec.decode(mpp,packet);
ohair@286 357 else {
ohair@286 358 // TODO localize exception
ohair@286 359 throw new IOException("");
ohair@286 360 }
ohair@286 361 // checkDuplicateKnownHeaders(packet);
ohair@286 362 }
ohair@286 363
ohair@286 364 private boolean isMultipartRelated(String contentType) {
ohair@286 365 return compareStrings(contentType, MimeCodec.MULTIPART_RELATED_MIME_TYPE);
ohair@286 366 }
ohair@286 367
ohair@286 368 private boolean isApplicationXopXml(String contentType) {
ohair@286 369 return compareStrings(contentType, MtomCodec.XOP_XML_MIME_TYPE);
ohair@286 370 }
ohair@286 371
ohair@286 372 private boolean isXml(String contentType) {
ohair@286 373 return compareStrings(contentType, xmlMimeType);
ohair@286 374 }
ohair@286 375
ohair@286 376 private boolean isFastInfoset(String contentType) {
ohair@286 377 if (isFastInfosetDisabled) return false;
ohair@286 378
ohair@286 379 return compareStrings(contentType, fiMimeType);
ohair@286 380 }
ohair@286 381
ohair@286 382 private boolean compareStrings(String a, String b) {
ohair@286 383 return a.length() >= b.length() &&
ohair@286 384 b.equalsIgnoreCase(
ohair@286 385 a.substring(0,
ohair@286 386 b.length()));
ohair@286 387 }
ohair@286 388
alanb@368 389 // private boolean isFastInfosetAcceptable(String accept) {
alanb@368 390 // if (accept == null || isFastInfosetDisabled) return false;
alanb@368 391 //
alanb@368 392 // StringTokenizer st = new StringTokenizer(accept, ",");
alanb@368 393 // while (st.hasMoreTokens()) {
alanb@368 394 // final String token = st.nextToken().trim();
alanb@368 395 // if (token.equalsIgnoreCase(fiMimeType)) {
alanb@368 396 // return true;
alanb@368 397 // }
alanb@368 398 // }
alanb@368 399 // return false;
alanb@368 400 // }
ohair@286 401
ohair@286 402 /*
ohair@286 403 * Just check if the Accept header contains application/xop+xml,
ohair@286 404 * no need to worry about q values.
ohair@286 405 */
alanb@368 406 // private boolean isMtomAcceptable(String accept) {
alanb@368 407 // if (accept == null || isFastInfosetDisabled) return false;
alanb@368 408 // StringTokenizer st = new StringTokenizer(accept, ",");
alanb@368 409 // while (st.hasMoreTokens()) {
alanb@368 410 // final String token = st.nextToken().trim();
alanb@368 411 // if (token.toLowerCase().contains(MtomCodec.XOP_XML_MIME_TYPE)) {
alanb@368 412 // return true;
alanb@368 413 // }
alanb@368 414 // }
alanb@368 415 // return false;
alanb@368 416 // }
ohair@286 417
ohair@286 418 /**
ohair@286 419 * Determines the encoding codec.
ohair@286 420 */
ohair@286 421 private Codec getEncoder(Packet p) {
ohair@286 422 /**
ohair@286 423 * The following logic is only for outbound packets
ohair@286 424 * to be encoded by a client.
ohair@286 425 * For a server the p.contentNegotiation == null.
ohair@286 426 */
ohair@286 427 if (!ignoreContentNegotiationProperty) {
ohair@286 428 if (p.contentNegotiation == ContentNegotiation.none) {
ohair@286 429 // The client may have changed the negotiation property from
ohair@286 430 // pessismistic to none between invocations
ohair@286 431 useFastInfosetForEncoding = false;
ohair@286 432 } else if (p.contentNegotiation == ContentNegotiation.optimistic) {
ohair@286 433 // Always encode using Fast Infoset if in optimisitic mode
ohair@286 434 useFastInfosetForEncoding = true;
ohair@286 435 }
ohair@286 436 }
ohair@286 437
ohair@286 438 // Override the MTOM binding for now
ohair@286 439 // Note: Using FI with MTOM does not make sense
ohair@286 440 if (useFastInfosetForEncoding) {
ohair@286 441 final Message m = p.getMessage();
ohair@286 442 if(m==null || m.getAttachments().isEmpty() || features.isEnabled(MTOMFeature.class))
ohair@286 443 return fiSoapCodec;
ohair@286 444 else
ohair@286 445 return fiSwaCodec;
ohair@286 446 }
ohair@286 447
alanb@368 448 //If the packet does not have a binding, explicitly set the MTOMFeature
alanb@368 449 //on the packet so that it has a way to determine whether to use MTOM
alanb@368 450 if (p.getBinding() == null) {
alanb@368 451 if (features != null) {
alanb@368 452 p.setMtomFeature(features.get(MTOMFeature.class));
alanb@368 453 }
alanb@368 454 }
alanb@368 455
alanb@368 456 if (p.shouldUseMtom()) {
alanb@368 457 return xmlMtomCodec;
ohair@286 458 }
ohair@286 459
ohair@286 460 Message m = p.getMessage();
ohair@286 461 if(m==null || m.getAttachments().isEmpty())
ohair@286 462 return xmlSoapCodec;
ohair@286 463 else
ohair@286 464 return xmlSwaCodec;
ohair@286 465 }
ohair@286 466
ohair@286 467 private RuntimeException noFastInfosetForDecoding() {
ohair@286 468 return new RuntimeException(StreamingMessages.FASTINFOSET_DECODING_NOT_ACCEPTED());
ohair@286 469 }
ohair@286 470
ohair@286 471 /**
ohair@286 472 * Obtain an FI SOAP codec instance using reflection.
ohair@286 473 */
ohair@286 474 private static Codec getFICodec(StreamSOAPCodec soapCodec, SOAPVersion version) {
ohair@286 475 try {
ohair@286 476 Class c = Class.forName("com.sun.xml.internal.ws.encoding.fastinfoset.FastInfosetStreamSOAPCodec");
ohair@286 477 Method m = c.getMethod("create", StreamSOAPCodec.class, SOAPVersion.class);
ohair@286 478 return (Codec)m.invoke(null, soapCodec, version);
ohair@286 479 } catch (Exception e) {
ohair@286 480 // TODO Log that FI cannot be loaded
ohair@286 481 return null;
ohair@286 482 }
ohair@286 483 }
ohair@286 484 }

mercurial