Thu, 31 Aug 2017 15:18:52 +0800
merge
aoqi@0 | 1 | /* |
aoqi@0 | 2 | * Copyright (c) 2005, 2013, 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 javax.xml.ws.soap; |
aoqi@0 | 27 | |
aoqi@0 | 28 | import javax.xml.ws.WebServiceFeature; |
aoqi@0 | 29 | import javax.xml.ws.Endpoint; |
aoqi@0 | 30 | import javax.xml.ws.Service; |
aoqi@0 | 31 | |
aoqi@0 | 32 | /** |
aoqi@0 | 33 | * AddressingFeature represents the use of WS-Addressing with either |
aoqi@0 | 34 | * the SOAP 1.1/HTTP or SOAP 1.2/HTTP binding. Using this feature |
aoqi@0 | 35 | * with any other binding is undefined. |
aoqi@0 | 36 | * <p> |
aoqi@0 | 37 | * This feature can be used during the creation of SEI proxy, and |
aoqi@0 | 38 | * {@link javax.xml.ws.Dispatch} instances on the client side and {@link Endpoint} |
aoqi@0 | 39 | * instances on the server side. This feature cannot be used for {@link Service} |
aoqi@0 | 40 | * instance creation on the client side. |
aoqi@0 | 41 | * <p> |
aoqi@0 | 42 | * The following describes the effects of this feature with respect |
aoqi@0 | 43 | * to be enabled or disabled: |
aoqi@0 | 44 | * <ul> |
aoqi@0 | 45 | * <li> ENABLED: In this Mode, WS-Addressing will be enabled. It means |
aoqi@0 | 46 | * the endpoint supports WS-Addressing but does not require its use. |
aoqi@0 | 47 | * A sender could send messages with WS-Addressing headers or without |
aoqi@0 | 48 | * WS-Addressing headers. But a receiver MUST consume both types of |
aoqi@0 | 49 | * messages. |
aoqi@0 | 50 | * <li> DISABLED: In this Mode, WS-Addressing will be disabled. |
aoqi@0 | 51 | * At runtime, WS-Addressing headers MUST NOT be used by a sender or |
aoqi@0 | 52 | * receiver. |
aoqi@0 | 53 | * </ul> |
aoqi@0 | 54 | * <p> |
aoqi@0 | 55 | * If the feature is enabled, the <code>required</code> property determines |
aoqi@0 | 56 | * whether the endpoint requires WS-Addressing. If it is set true, |
aoqi@0 | 57 | * WS-Addressing headers MUST be present on incoming and outgoing messages. |
aoqi@0 | 58 | * By default the <code>required</code> property is <code>false</code>. |
aoqi@0 | 59 | * |
aoqi@0 | 60 | * <p> |
aoqi@0 | 61 | * If the web service developer has not explicitly enabled this feature, |
aoqi@0 | 62 | * WSDL's wsam:Addressing policy assertion is used to find |
aoqi@0 | 63 | * the use of WS-Addressing. By using the feature explicitly, an application |
aoqi@0 | 64 | * overrides WSDL's indication of the use of WS-Addressing. In some cases, |
aoqi@0 | 65 | * this is really required. For example, if an application has implemented |
aoqi@0 | 66 | * WS-Addressing itself, it can use this feature to disable addressing. That |
aoqi@0 | 67 | * means a JAX-WS implementation doesn't consume or produce WS-Addressing |
aoqi@0 | 68 | * headers. |
aoqi@0 | 69 | * |
aoqi@0 | 70 | * <p> |
aoqi@0 | 71 | * If addressing is enabled, a corresponding wsam:Addressing policy assertion |
aoqi@0 | 72 | * must be generated in the WSDL as per |
aoqi@0 | 73 | * <a href="http://www.w3.org/TR/ws-addr-metadata/#wspolicyassertions"> |
aoqi@0 | 74 | * 3.1 WS-Policy Assertions</a> |
aoqi@0 | 75 | * |
aoqi@0 | 76 | * <p> |
aoqi@0 | 77 | * <b>Example 1: </b>Possible Policy Assertion in the generated WSDL for |
aoqi@0 | 78 | * <code>@Addressing</code> |
aoqi@0 | 79 | * <pre> |
aoqi@0 | 80 | * <wsam:Addressing wsp:Optional="true"> |
aoqi@0 | 81 | * <wsp:Policy/> |
aoqi@0 | 82 | * </wsam:Addressing> |
aoqi@0 | 83 | * </pre> |
aoqi@0 | 84 | * |
aoqi@0 | 85 | * <p> |
aoqi@0 | 86 | * <b>Example 2: </b>Possible Policy Assertion in the generated WSDL for |
aoqi@0 | 87 | * <code>@Addressing(required=true)</code> |
aoqi@0 | 88 | * <pre> |
aoqi@0 | 89 | * <wsam:Addressing> |
aoqi@0 | 90 | * <wsp:Policy/> |
aoqi@0 | 91 | * </wsam:Addressing> |
aoqi@0 | 92 | * </pre> |
aoqi@0 | 93 | * |
aoqi@0 | 94 | * <p> |
aoqi@0 | 95 | * <b>Example 3: </b>Possible Policy Assertion in the generated WSDL for |
aoqi@0 | 96 | * <code>@Addressing(required=true, responses=Responses.ANONYMOUS)</code> |
aoqi@0 | 97 | * <pre> |
aoqi@0 | 98 | * <wsam:Addressing> |
aoqi@0 | 99 | * <wsp:Policy> |
aoqi@0 | 100 | * <wsam:AnonymousResponses/> |
aoqi@0 | 101 | * </wsp:Policy> |
aoqi@0 | 102 | * </wsam:Addressing> |
aoqi@0 | 103 | * </pre> |
aoqi@0 | 104 | * |
aoqi@0 | 105 | * <p> |
aoqi@0 | 106 | * See <a href="http://www.w3.org/TR/2006/REC-ws-addr-core-20060509/"> |
aoqi@0 | 107 | * Web Services Addressing - Core</a>, |
aoqi@0 | 108 | * <a href="http://www.w3.org/TR/2006/REC-ws-addr-soap-20060509/"> |
aoqi@0 | 109 | * Web Services Addressing 1.0 - SOAP Binding</a>, |
aoqi@0 | 110 | * and <a href="http://www.w3.org/TR/ws-addr-metadata/"> |
aoqi@0 | 111 | * Web Services Addressing 1.0 - Metadata</a> |
aoqi@0 | 112 | * for more information on WS-Addressing. |
aoqi@0 | 113 | * |
aoqi@0 | 114 | * @see Addressing |
aoqi@0 | 115 | * @since JAX-WS 2.1 |
aoqi@0 | 116 | */ |
aoqi@0 | 117 | |
aoqi@0 | 118 | public final class AddressingFeature extends WebServiceFeature { |
aoqi@0 | 119 | /** |
aoqi@0 | 120 | * Constant value identifying the AddressingFeature |
aoqi@0 | 121 | */ |
aoqi@0 | 122 | public static final String ID = "http://www.w3.org/2005/08/addressing/module"; |
aoqi@0 | 123 | |
aoqi@0 | 124 | /** |
aoqi@0 | 125 | * If addressing is enabled, this property determines whether the endpoint |
aoqi@0 | 126 | * requires WS-Addressing. If required is true, WS-Addressing headers MUST |
aoqi@0 | 127 | * be present on incoming and outgoing messages. |
aoqi@0 | 128 | */ |
aoqi@0 | 129 | // should be private final, keeping original modifier due to backwards compatibility |
aoqi@0 | 130 | protected boolean required; |
aoqi@0 | 131 | |
aoqi@0 | 132 | /** |
aoqi@0 | 133 | * If addressing is enabled, this property determines if endpoint requires |
aoqi@0 | 134 | * the use of only anonymous responses, or only non-anonymous responses, or all. |
aoqi@0 | 135 | * |
aoqi@0 | 136 | * <p> |
aoqi@0 | 137 | * {@link Responses#ALL} supports all response types and this is the default |
aoqi@0 | 138 | * value. |
aoqi@0 | 139 | * |
aoqi@0 | 140 | * <p> |
aoqi@0 | 141 | * {@link Responses#ANONYMOUS} requires the use of only anonymous |
aoqi@0 | 142 | * responses. It will result into wsam:AnonymousResponses nested assertion |
aoqi@0 | 143 | * as specified in |
aoqi@0 | 144 | * <a href="http://www.w3.org/TR/ws-addr-metadata/#wspolicyanonresponses"> |
aoqi@0 | 145 | * 3.1.2 AnonymousResponses Assertion</a> in the generated WSDL. |
aoqi@0 | 146 | * |
aoqi@0 | 147 | * <p> |
aoqi@0 | 148 | * {@link Responses#NON_ANONYMOUS} requires the use of only non-anonymous |
aoqi@0 | 149 | * responses. It will result into |
aoqi@0 | 150 | * wsam:NonAnonymousResponses nested assertion as specified in |
aoqi@0 | 151 | * <a href="http://www.w3.org/TR/ws-addr-metadata/#wspolicynonanonresponses"> |
aoqi@0 | 152 | * 3.1.3 NonAnonymousResponses Assertion</a> in the generated WSDL. |
aoqi@0 | 153 | * |
aoqi@0 | 154 | * @since JAX-WS 2.2 |
aoqi@0 | 155 | */ |
aoqi@0 | 156 | public enum Responses { |
aoqi@0 | 157 | /** |
aoqi@0 | 158 | * Specifies the use of only anonymous |
aoqi@0 | 159 | * responses. It will result into wsam:AnonymousResponses nested assertion |
aoqi@0 | 160 | * as specified in |
aoqi@0 | 161 | * <a href="http://www.w3.org/TR/ws-addr-metadata/#wspolicyanonresponses"> |
aoqi@0 | 162 | * 3.1.2 AnonymousResponses Assertion</a> in the generated WSDL. |
aoqi@0 | 163 | */ |
aoqi@0 | 164 | ANONYMOUS, |
aoqi@0 | 165 | |
aoqi@0 | 166 | /** |
aoqi@0 | 167 | * Specifies the use of only non-anonymous |
aoqi@0 | 168 | * responses. It will result into |
aoqi@0 | 169 | * wsam:NonAnonymousResponses nested assertion as specified in |
aoqi@0 | 170 | * <a href="http://www.w3.org/TR/ws-addr-metadata/#wspolicynonanonresponses"> |
aoqi@0 | 171 | * 3.1.3 NonAnonymousResponses Assertion</a> in the generated WSDL. |
aoqi@0 | 172 | */ |
aoqi@0 | 173 | NON_ANONYMOUS, |
aoqi@0 | 174 | |
aoqi@0 | 175 | /** |
aoqi@0 | 176 | * Supports all response types and this is the default |
aoqi@0 | 177 | */ |
aoqi@0 | 178 | ALL |
aoqi@0 | 179 | } |
aoqi@0 | 180 | |
aoqi@0 | 181 | private final Responses responses; |
aoqi@0 | 182 | |
aoqi@0 | 183 | /** |
aoqi@0 | 184 | * Creates and configures an <code>AddressingFeature</code> with the |
aoqi@0 | 185 | * use of addressing requirements. The created feature enables |
aoqi@0 | 186 | * ws-addressing i.e. supports ws-addressing but doesn't require |
aoqi@0 | 187 | * its use. It is also configured to accept all the response types. |
aoqi@0 | 188 | */ |
aoqi@0 | 189 | public AddressingFeature() { |
aoqi@0 | 190 | this(true, false, Responses.ALL); |
aoqi@0 | 191 | } |
aoqi@0 | 192 | |
aoqi@0 | 193 | /** |
aoqi@0 | 194 | * Creates and configures an <code>AddressingFeature</code> with the |
aoqi@0 | 195 | * use of addressing requirements. If <code>enabled</code> is true, |
aoqi@0 | 196 | * it enables ws-addressing i.e. supports ws-addressing but doesn't |
aoqi@0 | 197 | * require its use. It also configures to accept all the response types. |
aoqi@0 | 198 | * |
aoqi@0 | 199 | * @param enabled true enables ws-addressing i.e.ws-addressing |
aoqi@0 | 200 | * is supported but doesn't require its use |
aoqi@0 | 201 | */ |
aoqi@0 | 202 | public AddressingFeature(boolean enabled) { |
aoqi@0 | 203 | this(enabled, false, Responses.ALL); |
aoqi@0 | 204 | } |
aoqi@0 | 205 | |
aoqi@0 | 206 | /** |
aoqi@0 | 207 | * Creates and configures an <code>AddressingFeature</code> with the |
aoqi@0 | 208 | * use of addressing requirements. If <code>enabled</code> and |
aoqi@0 | 209 | * <code>required</code> are true, it enables ws-addressing and |
aoqi@0 | 210 | * requires its use. It also configures to accept all the response types. |
aoqi@0 | 211 | * |
aoqi@0 | 212 | * @param enabled true enables ws-addressing i.e.ws-addressing |
aoqi@0 | 213 | * is supported but doesn't require its use |
aoqi@0 | 214 | * @param required true means requires the use of ws-addressing . |
aoqi@0 | 215 | */ |
aoqi@0 | 216 | public AddressingFeature(boolean enabled, boolean required) { |
aoqi@0 | 217 | this(enabled, required, Responses.ALL); |
aoqi@0 | 218 | } |
aoqi@0 | 219 | |
aoqi@0 | 220 | /** |
aoqi@0 | 221 | * Creates and configures an <code>AddressingFeature</code> with the |
aoqi@0 | 222 | * use of addressing requirements. If <code>enabled</code> and |
aoqi@0 | 223 | * <code>required</code> are true, it enables ws-addressing and |
aoqi@0 | 224 | * requires its use. Also, the response types can be configured using |
aoqi@0 | 225 | * <code>responses</code> parameter. |
aoqi@0 | 226 | * |
aoqi@0 | 227 | * @param enabled true enables ws-addressing i.e.ws-addressing |
aoqi@0 | 228 | * is supported but doesn't require its use |
aoqi@0 | 229 | * @param required true means requires the use of ws-addressing . |
aoqi@0 | 230 | * @param responses specifies what type of responses are required |
aoqi@0 | 231 | * |
aoqi@0 | 232 | * @since JAX-WS 2.2 |
aoqi@0 | 233 | */ |
aoqi@0 | 234 | public AddressingFeature(boolean enabled, boolean required, Responses responses) { |
aoqi@0 | 235 | this.enabled = enabled; |
aoqi@0 | 236 | this.required = required; |
aoqi@0 | 237 | this.responses = responses; |
aoqi@0 | 238 | } |
aoqi@0 | 239 | |
aoqi@0 | 240 | /** |
aoqi@0 | 241 | * {@inheritDoc} |
aoqi@0 | 242 | */ |
aoqi@0 | 243 | public String getID() { |
aoqi@0 | 244 | return ID; |
aoqi@0 | 245 | } |
aoqi@0 | 246 | |
aoqi@0 | 247 | /** |
aoqi@0 | 248 | * If addressing is enabled, this property determines whether the endpoint |
aoqi@0 | 249 | * requires WS-Addressing. If required is true, WS-Addressing headers MUST |
aoqi@0 | 250 | * be present on incoming and outgoing messages. |
aoqi@0 | 251 | * |
aoqi@0 | 252 | * @return the current required value |
aoqi@0 | 253 | */ |
aoqi@0 | 254 | public boolean isRequired() { |
aoqi@0 | 255 | return required; |
aoqi@0 | 256 | } |
aoqi@0 | 257 | |
aoqi@0 | 258 | /** |
aoqi@0 | 259 | * If addressing is enabled, this property determines whether endpoint |
aoqi@0 | 260 | * requires the use of anonymous responses, or non-anonymous responses, |
aoqi@0 | 261 | * or all responses. |
aoqi@0 | 262 | * |
aoqi@0 | 263 | * <p> |
aoqi@0 | 264 | * @return {@link Responses#ALL} when endpoint supports all types of |
aoqi@0 | 265 | * responses, |
aoqi@0 | 266 | * {@link Responses#ANONYMOUS} when endpoint requires the use of |
aoqi@0 | 267 | * only anonymous responses, |
aoqi@0 | 268 | * {@link Responses#NON_ANONYMOUS} when endpoint requires the use |
aoqi@0 | 269 | * of only non-anonymous responses |
aoqi@0 | 270 | * |
aoqi@0 | 271 | * @since JAX-WS 2.2 |
aoqi@0 | 272 | */ |
aoqi@0 | 273 | public Responses getResponses() { |
aoqi@0 | 274 | return responses; |
aoqi@0 | 275 | } |
aoqi@0 | 276 | |
aoqi@0 | 277 | } |