Thu, 31 Aug 2017 15:18:52 +0800
merge
aoqi@0 | 1 | /* |
aoqi@0 | 2 | * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. |
aoqi@0 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
aoqi@0 | 4 | * |
aoqi@0 | 5 | * This code is free software; you can redistribute it and/or modify it |
aoqi@0 | 6 | * under the terms of the GNU General Public License version 2 only, as |
aoqi@0 | 7 | * published by the Free Software Foundation. Oracle designates this |
aoqi@0 | 8 | * particular file as subject to the "Classpath" exception as provided |
aoqi@0 | 9 | * by Oracle in the LICENSE file that accompanied this code. |
aoqi@0 | 10 | * |
aoqi@0 | 11 | * This code is distributed in the hope that it will be useful, but WITHOUT |
aoqi@0 | 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
aoqi@0 | 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
aoqi@0 | 14 | * version 2 for more details (a copy is included in the LICENSE file that |
aoqi@0 | 15 | * accompanied this code). |
aoqi@0 | 16 | * |
aoqi@0 | 17 | * You should have received a copy of the GNU General Public License version |
aoqi@0 | 18 | * 2 along with this work; if not, write to the Free Software Foundation, |
aoqi@0 | 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
aoqi@0 | 20 | * |
aoqi@0 | 21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
aoqi@0 | 22 | * or visit www.oracle.com if you need additional information or have any |
aoqi@0 | 23 | * questions. |
aoqi@0 | 24 | */ |
aoqi@0 | 25 | |
aoqi@0 | 26 | package com.sun.xml.internal.ws.api; |
aoqi@0 | 27 | |
aoqi@0 | 28 | import com.sun.istack.internal.NotNull; |
aoqi@0 | 29 | import com.sun.xml.internal.ws.api.message.Message; |
aoqi@0 | 30 | import com.sun.xml.internal.ws.api.pipe.Codec; |
aoqi@0 | 31 | import com.sun.xml.internal.ws.api.pipe.Tube; |
aoqi@0 | 32 | import com.sun.xml.internal.ws.binding.BindingImpl; |
aoqi@0 | 33 | import com.sun.xml.internal.ws.binding.SOAPBindingImpl; |
aoqi@0 | 34 | import com.sun.xml.internal.ws.binding.WebServiceFeatureList; |
aoqi@0 | 35 | import com.sun.xml.internal.ws.encoding.SOAPBindingCodec; |
aoqi@0 | 36 | import com.sun.xml.internal.ws.encoding.XMLHTTPBindingCodec; |
aoqi@0 | 37 | import com.sun.xml.internal.ws.encoding.soap.streaming.SOAPNamespaceConstants; |
aoqi@0 | 38 | import com.sun.xml.internal.ws.util.ServiceFinder; |
aoqi@0 | 39 | import com.sun.xml.internal.ws.developer.JAXWSProperties; |
aoqi@0 | 40 | |
aoqi@0 | 41 | import javax.xml.ws.BindingType; |
aoqi@0 | 42 | import javax.xml.ws.WebServiceException; |
aoqi@0 | 43 | import javax.xml.ws.WebServiceFeature; |
aoqi@0 | 44 | import javax.xml.ws.handler.Handler; |
aoqi@0 | 45 | import javax.xml.ws.http.HTTPBinding; |
aoqi@0 | 46 | import javax.xml.ws.soap.MTOMFeature; |
aoqi@0 | 47 | import javax.xml.ws.soap.SOAPBinding; |
aoqi@0 | 48 | |
aoqi@0 | 49 | import java.io.UnsupportedEncodingException; |
aoqi@0 | 50 | import java.net.URL; |
aoqi@0 | 51 | import java.net.URLDecoder; |
aoqi@0 | 52 | import java.util.HashMap; |
aoqi@0 | 53 | import java.util.Map; |
aoqi@0 | 54 | |
aoqi@0 | 55 | /** |
aoqi@0 | 56 | * Parsed binding ID string. |
aoqi@0 | 57 | * |
aoqi@0 | 58 | * <p> |
aoqi@0 | 59 | * {@link BindingID} is an immutable object that represents a binding ID, |
aoqi@0 | 60 | * much like how {@link URL} is a representation of an URL. |
aoqi@0 | 61 | * Like {@link URL}, this class offers a bunch of methods that let you |
aoqi@0 | 62 | * query various traits/properties of a binding ID. |
aoqi@0 | 63 | * |
aoqi@0 | 64 | * <p> |
aoqi@0 | 65 | * {@link BindingID} is extensible; one can plug in a parser from |
aoqi@0 | 66 | * {@link String} to {@link BindingID} to interpret binding IDs that |
aoqi@0 | 67 | * the JAX-WS RI does no a-priori knowledge of. |
aoqi@0 | 68 | * Technologies such as Tango uses this to make the JAX-WS RI understand |
aoqi@0 | 69 | * binding IDs defined in their world. |
aoqi@0 | 70 | * |
aoqi@0 | 71 | * Such technologies are free to extend this class and expose more characterstics. |
aoqi@0 | 72 | * |
aoqi@0 | 73 | * <p> |
aoqi@0 | 74 | * Even though this class defines a few well known constants, {@link BindingID} |
aoqi@0 | 75 | * instances do not necessarily have singleton semantics. Use {@link #equals(Object)} |
aoqi@0 | 76 | * for the comparison. |
aoqi@0 | 77 | * |
aoqi@0 | 78 | * <h3>{@link BindingID} and {@link WSBinding}</h3> |
aoqi@0 | 79 | * <p> |
aoqi@0 | 80 | * {@link WSBinding} is mutable and represents a particular "use" of a {@link BindingID}. |
aoqi@0 | 81 | * As such, it has state like a list of {@link Handler}s, which are inherently local |
aoqi@0 | 82 | * to a particular usage. For example, if you have two proxies, you need two instances. |
aoqi@0 | 83 | * |
aoqi@0 | 84 | * {@link BindingID}, OTOH, is immutable and thus the single instance |
aoqi@0 | 85 | * that represents "SOAP1.2/HTTP" can be shared and reused by all proxies in the same VM. |
aoqi@0 | 86 | * |
aoqi@0 | 87 | * @author Kohsuke Kawaguchi |
aoqi@0 | 88 | */ |
aoqi@0 | 89 | public abstract class BindingID { |
aoqi@0 | 90 | |
aoqi@0 | 91 | /** |
aoqi@0 | 92 | * Creates an instance of {@link WSBinding} (which is conceptually an "use" |
aoqi@0 | 93 | * of {@link BindingID}) from a {@link BindingID}. |
aoqi@0 | 94 | * |
aoqi@0 | 95 | * @return |
aoqi@0 | 96 | * Always a new instance. |
aoqi@0 | 97 | */ |
aoqi@0 | 98 | public final @NotNull WSBinding createBinding() { |
aoqi@0 | 99 | return BindingImpl.create(this); |
aoqi@0 | 100 | } |
aoqi@0 | 101 | |
aoqi@0 | 102 | /** |
aoqi@0 | 103 | * Returns wsdl:binding@transport attribute. Sub classes |
aoqi@0 | 104 | * are expected to override this method to provide their transport |
aoqi@0 | 105 | * attribute. |
aoqi@0 | 106 | * |
aoqi@0 | 107 | * @return wsdl:binding@transport attribute |
aoqi@0 | 108 | * @since JAX-WS RI 2.1.6 |
aoqi@0 | 109 | */ |
aoqi@0 | 110 | public @NotNull String getTransport() { |
aoqi@0 | 111 | return SOAPNamespaceConstants.TRANSPORT_HTTP; |
aoqi@0 | 112 | } |
aoqi@0 | 113 | |
aoqi@0 | 114 | public final @NotNull WSBinding createBinding(WebServiceFeature... features) { |
aoqi@0 | 115 | return BindingImpl.create(this, features); |
aoqi@0 | 116 | } |
aoqi@0 | 117 | |
aoqi@0 | 118 | public final @NotNull WSBinding createBinding(WSFeatureList features) { |
aoqi@0 | 119 | return createBinding(features.toArray()); |
aoqi@0 | 120 | } |
aoqi@0 | 121 | |
aoqi@0 | 122 | /** |
aoqi@0 | 123 | * Gets the SOAP version of this binding. |
aoqi@0 | 124 | * |
aoqi@0 | 125 | * TODO: clarify what to do with XML/HTTP binding |
aoqi@0 | 126 | * |
aoqi@0 | 127 | * @return |
aoqi@0 | 128 | * If the binding is using SOAP, this method returns |
aoqi@0 | 129 | * a {@link SOAPVersion} constant. |
aoqi@0 | 130 | * |
aoqi@0 | 131 | * If the binding is not based on SOAP, this method |
aoqi@0 | 132 | * returns null. See {@link Message} for how a non-SOAP |
aoqi@0 | 133 | * binding shall be handled by {@link Tube}s. |
aoqi@0 | 134 | */ |
aoqi@0 | 135 | public abstract SOAPVersion getSOAPVersion(); |
aoqi@0 | 136 | |
aoqi@0 | 137 | /** |
aoqi@0 | 138 | * Creates a new {@link Codec} for this binding. |
aoqi@0 | 139 | * |
aoqi@0 | 140 | * @param binding |
aoqi@0 | 141 | * Ocassionally some aspects of binding can be overridden by |
aoqi@0 | 142 | * {@link WSBinding} at runtime by users, so some {@link Codec}s |
aoqi@0 | 143 | * need to have access to {@link WSBinding} that it's working for. |
aoqi@0 | 144 | */ |
aoqi@0 | 145 | public abstract @NotNull Codec createEncoder(@NotNull WSBinding binding); |
aoqi@0 | 146 | |
aoqi@0 | 147 | /** |
aoqi@0 | 148 | * Gets the binding ID, which uniquely identifies the binding. |
aoqi@0 | 149 | * |
aoqi@0 | 150 | * <p> |
aoqi@0 | 151 | * The relevant specs define the binding IDs and what they mean. |
aoqi@0 | 152 | * The ID is used in many places to identify the kind of binding |
aoqi@0 | 153 | * (such as SOAP1.1, SOAP1.2, REST, ...) |
aoqi@0 | 154 | * |
aoqi@0 | 155 | * @return |
aoqi@0 | 156 | * Always non-null same value. |
aoqi@0 | 157 | */ |
aoqi@0 | 158 | @Override |
aoqi@0 | 159 | public abstract String toString(); |
aoqi@0 | 160 | |
aoqi@0 | 161 | /** |
aoqi@0 | 162 | * Returna a new {@link WebServiceFeatureList} instance |
aoqi@0 | 163 | * that represents the features that are built into this binding ID. |
aoqi@0 | 164 | * |
aoqi@0 | 165 | * <p> |
aoqi@0 | 166 | * For example, {@link BindingID} for |
aoqi@0 | 167 | * <tt>"{@value SOAPBinding#SOAP11HTTP_MTOM_BINDING}"</tt> |
aoqi@0 | 168 | * would always return a list that has {@link MTOMFeature} enabled. |
aoqi@0 | 169 | */ |
aoqi@0 | 170 | public WebServiceFeatureList createBuiltinFeatureList() { |
aoqi@0 | 171 | return new WebServiceFeatureList(); |
aoqi@0 | 172 | } |
aoqi@0 | 173 | |
aoqi@0 | 174 | /** |
aoqi@0 | 175 | * Returns true if this binding can generate WSDL. |
aoqi@0 | 176 | * |
aoqi@0 | 177 | * <p> |
aoqi@0 | 178 | * For e.g.: SOAP 1.1 and "XSOAP 1.2" is supposed to return true |
aoqi@0 | 179 | * from this method. For SOAP1.2, there is no standard WSDL, so the |
aoqi@0 | 180 | * runtime is not generating one and it expects the WSDL is packaged. |
aoqi@0 | 181 | * |
aoqi@0 | 182 | */ |
aoqi@0 | 183 | public boolean canGenerateWSDL() { |
aoqi@0 | 184 | return false; |
aoqi@0 | 185 | } |
aoqi@0 | 186 | |
aoqi@0 | 187 | /** |
aoqi@0 | 188 | * Returns a parameter of this binding ID. |
aoqi@0 | 189 | * |
aoqi@0 | 190 | * <p> |
aoqi@0 | 191 | * Some binding ID, such as those for SOAP/HTTP, uses the URL |
aoqi@0 | 192 | * query syntax (like <tt>?mtom=true</tt>) to control |
aoqi@0 | 193 | * the optional part of the binding. This method obtains |
aoqi@0 | 194 | * the value for such optional parts. |
aoqi@0 | 195 | * |
aoqi@0 | 196 | * <p> |
aoqi@0 | 197 | * For implementors of the derived classes, if your binding ID |
aoqi@0 | 198 | * does not define such optional parts (such as the XML/HTTP binding ID), |
aoqi@0 | 199 | * then you should simply return the specified default value |
aoqi@0 | 200 | * (which is what this implementation does.) |
aoqi@0 | 201 | * |
aoqi@0 | 202 | * @param parameterName |
aoqi@0 | 203 | * The parameter name, such as "mtom" in the above example. |
aoqi@0 | 204 | * @param defaultValue |
aoqi@0 | 205 | * If this binding ID doesn't have the specified parameter explicitly, |
aoqi@0 | 206 | * this value will be returned. |
aoqi@0 | 207 | * |
aoqi@0 | 208 | * @return |
aoqi@0 | 209 | * the value of the parameter, if it's present (such as "true" |
aoqi@0 | 210 | * in the above example.) If not present, this method returns |
aoqi@0 | 211 | * the {@code defaultValue}. |
aoqi@0 | 212 | */ |
aoqi@0 | 213 | public String getParameter(String parameterName, String defaultValue) { |
aoqi@0 | 214 | return defaultValue; |
aoqi@0 | 215 | } |
aoqi@0 | 216 | |
aoqi@0 | 217 | /** |
aoqi@0 | 218 | * Compares the equality based on {@link #toString()}. |
aoqi@0 | 219 | */ |
aoqi@0 | 220 | @Override |
aoqi@0 | 221 | public boolean equals(Object obj) { |
aoqi@0 | 222 | if(!(obj instanceof BindingID)) |
aoqi@0 | 223 | return false; |
aoqi@0 | 224 | return toString().equals(obj.toString()); |
aoqi@0 | 225 | } |
aoqi@0 | 226 | |
aoqi@0 | 227 | @Override |
aoqi@0 | 228 | public int hashCode() { |
aoqi@0 | 229 | return toString().hashCode(); |
aoqi@0 | 230 | } |
aoqi@0 | 231 | |
aoqi@0 | 232 | /** |
aoqi@0 | 233 | * Parses a binding ID string into a {@link BindingID} object. |
aoqi@0 | 234 | * |
aoqi@0 | 235 | * <p> |
aoqi@0 | 236 | * This method first checks for a few known values and then delegate |
aoqi@0 | 237 | * the parsing to {@link BindingIDFactory}. |
aoqi@0 | 238 | * |
aoqi@0 | 239 | * <p> |
aoqi@0 | 240 | * If parsing succeeds this method returns a value. Otherwise |
aoqi@0 | 241 | * throws {@link WebServiceException}. |
aoqi@0 | 242 | * |
aoqi@0 | 243 | * @throws WebServiceException |
aoqi@0 | 244 | * If the binding ID is not understood. |
aoqi@0 | 245 | */ |
aoqi@0 | 246 | public static @NotNull BindingID parse(String lexical) { |
aoqi@0 | 247 | if(lexical.equals(XML_HTTP.toString())) |
aoqi@0 | 248 | return XML_HTTP; |
aoqi@0 | 249 | if(lexical.equals(REST_HTTP.toString())) |
aoqi@0 | 250 | return REST_HTTP; |
aoqi@0 | 251 | if(belongsTo(lexical,SOAP11_HTTP.toString())) |
aoqi@0 | 252 | return customize(lexical,SOAP11_HTTP); |
aoqi@0 | 253 | if(belongsTo(lexical,SOAP12_HTTP.toString())) |
aoqi@0 | 254 | return customize(lexical,SOAP12_HTTP); |
aoqi@0 | 255 | if(belongsTo(lexical,SOAPBindingImpl.X_SOAP12HTTP_BINDING)) |
aoqi@0 | 256 | return customize(lexical,X_SOAP12_HTTP); |
aoqi@0 | 257 | |
aoqi@0 | 258 | // OK, it's none of the values JAX-WS understands. |
aoqi@0 | 259 | for( BindingIDFactory f : ServiceFinder.find(BindingIDFactory.class) ) { |
aoqi@0 | 260 | BindingID r = f.parse(lexical); |
aoqi@0 | 261 | if(r!=null) |
aoqi@0 | 262 | return r; |
aoqi@0 | 263 | } |
aoqi@0 | 264 | |
aoqi@0 | 265 | // nobody understood this value |
aoqi@0 | 266 | throw new WebServiceException("Wrong binding ID: "+lexical); |
aoqi@0 | 267 | } |
aoqi@0 | 268 | |
aoqi@0 | 269 | private static boolean belongsTo(String lexical, String id) { |
aoqi@0 | 270 | return lexical.equals(id) || lexical.startsWith(id+'?'); |
aoqi@0 | 271 | } |
aoqi@0 | 272 | |
aoqi@0 | 273 | /** |
aoqi@0 | 274 | * Parses parameter portion and returns appropriately populated {@link SOAPHTTPImpl} |
aoqi@0 | 275 | */ |
aoqi@0 | 276 | private static SOAPHTTPImpl customize(String lexical, SOAPHTTPImpl base) { |
aoqi@0 | 277 | if(lexical.equals(base.toString())) |
aoqi@0 | 278 | return base; |
aoqi@0 | 279 | |
aoqi@0 | 280 | // otherwise we must have query parameter |
aoqi@0 | 281 | // we assume the spec won't define any tricky parameters that require |
aoqi@0 | 282 | // complicated handling (such as %HH or non-ASCII char), so this parser |
aoqi@0 | 283 | // is quite simple-minded. |
aoqi@0 | 284 | SOAPHTTPImpl r = new SOAPHTTPImpl(base.getSOAPVersion(), lexical, base.canGenerateWSDL()); |
aoqi@0 | 285 | try { |
aoqi@0 | 286 | // With X_SOAP12_HTTP, base != lexical and lexical does n't have any query string |
aoqi@0 | 287 | if(lexical.indexOf('?') == -1) { |
aoqi@0 | 288 | return r; |
aoqi@0 | 289 | } |
aoqi@0 | 290 | String query = URLDecoder.decode(lexical.substring(lexical.indexOf('?')+1),"UTF-8"); |
aoqi@0 | 291 | for( String token : query.split("&") ) { |
aoqi@0 | 292 | int idx = token.indexOf('='); |
aoqi@0 | 293 | if(idx<0) |
aoqi@0 | 294 | throw new WebServiceException("Malformed binding ID (no '=' in "+token+")"); |
aoqi@0 | 295 | r.parameters.put(token.substring(0,idx),token.substring(idx+1)); |
aoqi@0 | 296 | } |
aoqi@0 | 297 | } catch (UnsupportedEncodingException e) { |
aoqi@0 | 298 | throw new AssertionError(e); // UTF-8 is supported everywhere |
aoqi@0 | 299 | } |
aoqi@0 | 300 | |
aoqi@0 | 301 | return r; |
aoqi@0 | 302 | } |
aoqi@0 | 303 | |
aoqi@0 | 304 | |
aoqi@0 | 305 | /** |
aoqi@0 | 306 | * Figures out the binding from {@link BindingType} annotation. |
aoqi@0 | 307 | * |
aoqi@0 | 308 | * @return |
aoqi@0 | 309 | * default to {@link BindingID#SOAP11_HTTP}, if no such annotation is present. |
aoqi@0 | 310 | * @see #parse(String) |
aoqi@0 | 311 | */ |
aoqi@0 | 312 | public static @NotNull BindingID parse(Class<?> implClass) { |
aoqi@0 | 313 | BindingType bindingType = implClass.getAnnotation(BindingType.class); |
aoqi@0 | 314 | if (bindingType != null) { |
aoqi@0 | 315 | String bindingId = bindingType.value(); |
aoqi@0 | 316 | if (bindingId.length() > 0) { |
aoqi@0 | 317 | return BindingID.parse(bindingId); |
aoqi@0 | 318 | } |
aoqi@0 | 319 | } |
aoqi@0 | 320 | return SOAP11_HTTP; |
aoqi@0 | 321 | } |
aoqi@0 | 322 | |
aoqi@0 | 323 | /** |
aoqi@0 | 324 | * Constant that represents implementation specific SOAP1.2/HTTP which is |
aoqi@0 | 325 | * used to generate non-standard WSDLs |
aoqi@0 | 326 | */ |
aoqi@0 | 327 | public static final SOAPHTTPImpl X_SOAP12_HTTP = new SOAPHTTPImpl( |
aoqi@0 | 328 | SOAPVersion.SOAP_12, SOAPBindingImpl.X_SOAP12HTTP_BINDING, true); |
aoqi@0 | 329 | |
aoqi@0 | 330 | /** |
aoqi@0 | 331 | * Constant that represents SOAP1.2/HTTP. |
aoqi@0 | 332 | */ |
aoqi@0 | 333 | public static final SOAPHTTPImpl SOAP12_HTTP = new SOAPHTTPImpl( |
aoqi@0 | 334 | SOAPVersion.SOAP_12, SOAPBinding.SOAP12HTTP_BINDING, true); |
aoqi@0 | 335 | /** |
aoqi@0 | 336 | * Constant that represents SOAP1.1/HTTP. |
aoqi@0 | 337 | */ |
aoqi@0 | 338 | public static final SOAPHTTPImpl SOAP11_HTTP = new SOAPHTTPImpl( |
aoqi@0 | 339 | SOAPVersion.SOAP_11, SOAPBinding.SOAP11HTTP_BINDING, true); |
aoqi@0 | 340 | |
aoqi@0 | 341 | /** |
aoqi@0 | 342 | * Constant that represents SOAP1.2/HTTP. |
aoqi@0 | 343 | */ |
aoqi@0 | 344 | public static final SOAPHTTPImpl SOAP12_HTTP_MTOM = new SOAPHTTPImpl( |
aoqi@0 | 345 | SOAPVersion.SOAP_12, SOAPBinding.SOAP12HTTP_MTOM_BINDING, true, true); |
aoqi@0 | 346 | /** |
aoqi@0 | 347 | * Constant that represents SOAP1.1/HTTP. |
aoqi@0 | 348 | */ |
aoqi@0 | 349 | public static final SOAPHTTPImpl SOAP11_HTTP_MTOM = new SOAPHTTPImpl( |
aoqi@0 | 350 | SOAPVersion.SOAP_11, SOAPBinding.SOAP11HTTP_MTOM_BINDING, true, true); |
aoqi@0 | 351 | |
aoqi@0 | 352 | |
aoqi@0 | 353 | /** |
aoqi@0 | 354 | * Constant that represents REST. |
aoqi@0 | 355 | */ |
aoqi@0 | 356 | public static final BindingID XML_HTTP = new Impl(SOAPVersion.SOAP_11, HTTPBinding.HTTP_BINDING,false) { |
aoqi@0 | 357 | @Override |
aoqi@0 | 358 | public Codec createEncoder(WSBinding binding) { |
aoqi@0 | 359 | return new XMLHTTPBindingCodec(binding.getFeatures()); |
aoqi@0 | 360 | } |
aoqi@0 | 361 | }; |
aoqi@0 | 362 | |
aoqi@0 | 363 | /** |
aoqi@0 | 364 | * Constant that represents REST. |
aoqi@0 | 365 | */ |
aoqi@0 | 366 | private static final BindingID REST_HTTP = new Impl(SOAPVersion.SOAP_11, JAXWSProperties.REST_BINDING,true) { |
aoqi@0 | 367 | @Override |
aoqi@0 | 368 | public Codec createEncoder(WSBinding binding) { |
aoqi@0 | 369 | return new XMLHTTPBindingCodec(binding.getFeatures()); |
aoqi@0 | 370 | } |
aoqi@0 | 371 | }; |
aoqi@0 | 372 | |
aoqi@0 | 373 | private static abstract class Impl extends BindingID { |
aoqi@0 | 374 | final SOAPVersion version; |
aoqi@0 | 375 | private final String lexical; |
aoqi@0 | 376 | private final boolean canGenerateWSDL; |
aoqi@0 | 377 | |
aoqi@0 | 378 | public Impl(SOAPVersion version, String lexical, boolean canGenerateWSDL) { |
aoqi@0 | 379 | this.version = version; |
aoqi@0 | 380 | this.lexical = lexical; |
aoqi@0 | 381 | this.canGenerateWSDL = canGenerateWSDL; |
aoqi@0 | 382 | } |
aoqi@0 | 383 | |
aoqi@0 | 384 | @Override |
aoqi@0 | 385 | public SOAPVersion getSOAPVersion() { |
aoqi@0 | 386 | return version; |
aoqi@0 | 387 | } |
aoqi@0 | 388 | |
aoqi@0 | 389 | @Override |
aoqi@0 | 390 | public String toString() { |
aoqi@0 | 391 | return lexical; |
aoqi@0 | 392 | } |
aoqi@0 | 393 | |
aoqi@0 | 394 | @Deprecated |
aoqi@0 | 395 | @Override |
aoqi@0 | 396 | public boolean canGenerateWSDL() { |
aoqi@0 | 397 | return canGenerateWSDL; |
aoqi@0 | 398 | } |
aoqi@0 | 399 | } |
aoqi@0 | 400 | |
aoqi@0 | 401 | /** |
aoqi@0 | 402 | * Internal implementation for SOAP/HTTP. |
aoqi@0 | 403 | */ |
aoqi@0 | 404 | private static final class SOAPHTTPImpl extends Impl implements Cloneable { |
aoqi@0 | 405 | /*final*/ Map<String,String> parameters = new HashMap<String,String>(); |
aoqi@0 | 406 | |
aoqi@0 | 407 | static final String MTOM_PARAM = "mtom"; |
aoqi@0 | 408 | |
aoqi@0 | 409 | public SOAPHTTPImpl(SOAPVersion version, String lexical, boolean canGenerateWSDL) { |
aoqi@0 | 410 | super(version, lexical, canGenerateWSDL); |
aoqi@0 | 411 | } |
aoqi@0 | 412 | |
aoqi@0 | 413 | public SOAPHTTPImpl(SOAPVersion version, String lexical, boolean canGenerateWSDL, |
aoqi@0 | 414 | boolean mtomEnabled) { |
aoqi@0 | 415 | this(version, lexical, canGenerateWSDL); |
aoqi@0 | 416 | String mtomStr = mtomEnabled ? "true" : "false"; |
aoqi@0 | 417 | parameters.put(MTOM_PARAM, mtomStr); |
aoqi@0 | 418 | } |
aoqi@0 | 419 | |
aoqi@0 | 420 | public @NotNull @Override Codec createEncoder(WSBinding binding) { |
aoqi@0 | 421 | return new SOAPBindingCodec(binding.getFeatures()); |
aoqi@0 | 422 | } |
aoqi@0 | 423 | |
aoqi@0 | 424 | private Boolean isMTOMEnabled() { |
aoqi@0 | 425 | String mtom = parameters.get(MTOM_PARAM); |
aoqi@0 | 426 | return mtom==null?null:Boolean.valueOf(mtom); |
aoqi@0 | 427 | } |
aoqi@0 | 428 | |
aoqi@0 | 429 | @Override |
aoqi@0 | 430 | public WebServiceFeatureList createBuiltinFeatureList() { |
aoqi@0 | 431 | WebServiceFeatureList r=super.createBuiltinFeatureList(); |
aoqi@0 | 432 | Boolean mtom = isMTOMEnabled(); |
aoqi@0 | 433 | if(mtom != null) |
aoqi@0 | 434 | r.add(new MTOMFeature(mtom)); |
aoqi@0 | 435 | return r; |
aoqi@0 | 436 | } |
aoqi@0 | 437 | |
aoqi@0 | 438 | @Override |
aoqi@0 | 439 | public String getParameter(String parameterName, String defaultValue) { |
aoqi@0 | 440 | if (parameters.get(parameterName) == null) |
aoqi@0 | 441 | return super.getParameter(parameterName, defaultValue); |
aoqi@0 | 442 | return parameters.get(parameterName); |
aoqi@0 | 443 | } |
aoqi@0 | 444 | |
aoqi@0 | 445 | @Override |
aoqi@0 | 446 | public SOAPHTTPImpl clone() throws CloneNotSupportedException { |
aoqi@0 | 447 | return (SOAPHTTPImpl) super.clone(); |
aoqi@0 | 448 | } |
aoqi@0 | 449 | } |
aoqi@0 | 450 | } |