aoqi@0: /* aoqi@0: * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. aoqi@0: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. aoqi@0: * aoqi@0: * This code is free software; you can redistribute it and/or modify it aoqi@0: * under the terms of the GNU General Public License version 2 only, as aoqi@0: * published by the Free Software Foundation. Oracle designates this aoqi@0: * particular file as subject to the "Classpath" exception as provided aoqi@0: * by Oracle in the LICENSE file that accompanied this code. aoqi@0: * aoqi@0: * This code is distributed in the hope that it will be useful, but WITHOUT aoqi@0: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or aoqi@0: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License aoqi@0: * version 2 for more details (a copy is included in the LICENSE file that aoqi@0: * accompanied this code). aoqi@0: * aoqi@0: * You should have received a copy of the GNU General Public License version aoqi@0: * 2 along with this work; if not, write to the Free Software Foundation, aoqi@0: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. aoqi@0: * aoqi@0: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA aoqi@0: * or visit www.oracle.com if you need additional information or have any aoqi@0: * questions. aoqi@0: */ aoqi@0: aoqi@0: package javax.xml.ws.soap; aoqi@0: aoqi@0: import javax.xml.ws.WebServiceFeature; aoqi@0: import javax.xml.ws.Endpoint; aoqi@0: import javax.xml.ws.Service; aoqi@0: aoqi@0: /** aoqi@0: * AddressingFeature represents the use of WS-Addressing with either aoqi@0: * the SOAP 1.1/HTTP or SOAP 1.2/HTTP binding. Using this feature aoqi@0: * with any other binding is undefined. aoqi@0: *
aoqi@0: * This feature can be used during the creation of SEI proxy, and aoqi@0: * {@link javax.xml.ws.Dispatch} instances on the client side and {@link Endpoint} aoqi@0: * instances on the server side. This feature cannot be used for {@link Service} aoqi@0: * instance creation on the client side. aoqi@0: *
aoqi@0: * The following describes the effects of this feature with respect aoqi@0: * to be enabled or disabled: aoqi@0: *
aoqi@0: * If the feature is enabled, the required
property determines
aoqi@0: * whether the endpoint requires WS-Addressing. If it is set true,
aoqi@0: * WS-Addressing headers MUST be present on incoming and outgoing messages.
aoqi@0: * By default the required
property is false
.
aoqi@0: *
aoqi@0: *
aoqi@0: * If the web service developer has not explicitly enabled this feature, aoqi@0: * WSDL's wsam:Addressing policy assertion is used to find aoqi@0: * the use of WS-Addressing. By using the feature explicitly, an application aoqi@0: * overrides WSDL's indication of the use of WS-Addressing. In some cases, aoqi@0: * this is really required. For example, if an application has implemented aoqi@0: * WS-Addressing itself, it can use this feature to disable addressing. That aoqi@0: * means a JAX-WS implementation doesn't consume or produce WS-Addressing aoqi@0: * headers. aoqi@0: * aoqi@0: *
aoqi@0: * If addressing is enabled, a corresponding wsam:Addressing policy assertion aoqi@0: * must be generated in the WSDL as per aoqi@0: * aoqi@0: * 3.1 WS-Policy Assertions aoqi@0: * aoqi@0: *
aoqi@0: * Example 1: Possible Policy Assertion in the generated WSDL for
aoqi@0: * @Addressing
aoqi@0: *
aoqi@0: * <wsam:Addressing wsp:Optional="true"> aoqi@0: * <wsp:Policy/> aoqi@0: * </wsam:Addressing> aoqi@0: *aoqi@0: * aoqi@0: *
aoqi@0: * Example 2: Possible Policy Assertion in the generated WSDL for
aoqi@0: * @Addressing(required=true)
aoqi@0: *
aoqi@0: * <wsam:Addressing> aoqi@0: * <wsp:Policy/> aoqi@0: * </wsam:Addressing> aoqi@0: *aoqi@0: * aoqi@0: *
aoqi@0: * Example 3: Possible Policy Assertion in the generated WSDL for
aoqi@0: * @Addressing(required=true, responses=Responses.ANONYMOUS)
aoqi@0: *
aoqi@0: * <wsam:Addressing> aoqi@0: * <wsp:Policy> aoqi@0: * <wsam:AnonymousResponses/> aoqi@0: * </wsp:Policy> aoqi@0: * </wsam:Addressing> aoqi@0: *aoqi@0: * aoqi@0: *
aoqi@0: * See aoqi@0: * Web Services Addressing - Core, aoqi@0: * aoqi@0: * Web Services Addressing 1.0 - SOAP Binding, aoqi@0: * and aoqi@0: * Web Services Addressing 1.0 - Metadata aoqi@0: * for more information on WS-Addressing. aoqi@0: * aoqi@0: * @see Addressing aoqi@0: * @since JAX-WS 2.1 aoqi@0: */ aoqi@0: aoqi@0: public final class AddressingFeature extends WebServiceFeature { aoqi@0: /** aoqi@0: * Constant value identifying the AddressingFeature aoqi@0: */ aoqi@0: public static final String ID = "http://www.w3.org/2005/08/addressing/module"; aoqi@0: aoqi@0: /** aoqi@0: * If addressing is enabled, this property determines whether the endpoint aoqi@0: * requires WS-Addressing. If required is true, WS-Addressing headers MUST aoqi@0: * be present on incoming and outgoing messages. aoqi@0: */ aoqi@0: // should be private final, keeping original modifier due to backwards compatibility aoqi@0: protected boolean required; aoqi@0: aoqi@0: /** aoqi@0: * If addressing is enabled, this property determines if endpoint requires aoqi@0: * the use of only anonymous responses, or only non-anonymous responses, or all. aoqi@0: * aoqi@0: *
aoqi@0: * {@link Responses#ALL} supports all response types and this is the default aoqi@0: * value. aoqi@0: * aoqi@0: *
aoqi@0: * {@link Responses#ANONYMOUS} requires the use of only anonymous aoqi@0: * responses. It will result into wsam:AnonymousResponses nested assertion aoqi@0: * as specified in aoqi@0: * aoqi@0: * 3.1.2 AnonymousResponses Assertion in the generated WSDL. aoqi@0: * aoqi@0: *
aoqi@0: * {@link Responses#NON_ANONYMOUS} requires the use of only non-anonymous
aoqi@0: * responses. It will result into
aoqi@0: * wsam:NonAnonymousResponses nested assertion as specified in
aoqi@0: *
aoqi@0: * 3.1.3 NonAnonymousResponses Assertion in the generated WSDL.
aoqi@0: *
aoqi@0: * @since JAX-WS 2.2
aoqi@0: */
aoqi@0: public enum Responses {
aoqi@0: /**
aoqi@0: * Specifies the use of only anonymous
aoqi@0: * responses. It will result into wsam:AnonymousResponses nested assertion
aoqi@0: * as specified in
aoqi@0: *
aoqi@0: * 3.1.2 AnonymousResponses Assertion in the generated WSDL.
aoqi@0: */
aoqi@0: ANONYMOUS,
aoqi@0:
aoqi@0: /**
aoqi@0: * Specifies the use of only non-anonymous
aoqi@0: * responses. It will result into
aoqi@0: * wsam:NonAnonymousResponses nested assertion as specified in
aoqi@0: *
aoqi@0: * 3.1.3 NonAnonymousResponses Assertion in the generated WSDL.
aoqi@0: */
aoqi@0: NON_ANONYMOUS,
aoqi@0:
aoqi@0: /**
aoqi@0: * Supports all response types and this is the default
aoqi@0: */
aoqi@0: ALL
aoqi@0: }
aoqi@0:
aoqi@0: private final Responses responses;
aoqi@0:
aoqi@0: /**
aoqi@0: * Creates and configures an AddressingFeature
with the
aoqi@0: * use of addressing requirements. The created feature enables
aoqi@0: * ws-addressing i.e. supports ws-addressing but doesn't require
aoqi@0: * its use. It is also configured to accept all the response types.
aoqi@0: */
aoqi@0: public AddressingFeature() {
aoqi@0: this(true, false, Responses.ALL);
aoqi@0: }
aoqi@0:
aoqi@0: /**
aoqi@0: * Creates and configures an AddressingFeature
with the
aoqi@0: * use of addressing requirements. If enabled
is true,
aoqi@0: * it enables ws-addressing i.e. supports ws-addressing but doesn't
aoqi@0: * require its use. It also configures to accept all the response types.
aoqi@0: *
aoqi@0: * @param enabled true enables ws-addressing i.e.ws-addressing
aoqi@0: * is supported but doesn't require its use
aoqi@0: */
aoqi@0: public AddressingFeature(boolean enabled) {
aoqi@0: this(enabled, false, Responses.ALL);
aoqi@0: }
aoqi@0:
aoqi@0: /**
aoqi@0: * Creates and configures an AddressingFeature
with the
aoqi@0: * use of addressing requirements. If enabled
and
aoqi@0: * required
are true, it enables ws-addressing and
aoqi@0: * requires its use. It also configures to accept all the response types.
aoqi@0: *
aoqi@0: * @param enabled true enables ws-addressing i.e.ws-addressing
aoqi@0: * is supported but doesn't require its use
aoqi@0: * @param required true means requires the use of ws-addressing .
aoqi@0: */
aoqi@0: public AddressingFeature(boolean enabled, boolean required) {
aoqi@0: this(enabled, required, Responses.ALL);
aoqi@0: }
aoqi@0:
aoqi@0: /**
aoqi@0: * Creates and configures an AddressingFeature
with the
aoqi@0: * use of addressing requirements. If enabled
and
aoqi@0: * required
are true, it enables ws-addressing and
aoqi@0: * requires its use. Also, the response types can be configured using
aoqi@0: * responses
parameter.
aoqi@0: *
aoqi@0: * @param enabled true enables ws-addressing i.e.ws-addressing
aoqi@0: * is supported but doesn't require its use
aoqi@0: * @param required true means requires the use of ws-addressing .
aoqi@0: * @param responses specifies what type of responses are required
aoqi@0: *
aoqi@0: * @since JAX-WS 2.2
aoqi@0: */
aoqi@0: public AddressingFeature(boolean enabled, boolean required, Responses responses) {
aoqi@0: this.enabled = enabled;
aoqi@0: this.required = required;
aoqi@0: this.responses = responses;
aoqi@0: }
aoqi@0:
aoqi@0: /**
aoqi@0: * {@inheritDoc}
aoqi@0: */
aoqi@0: public String getID() {
aoqi@0: return ID;
aoqi@0: }
aoqi@0:
aoqi@0: /**
aoqi@0: * If addressing is enabled, this property determines whether the endpoint
aoqi@0: * requires WS-Addressing. If required is true, WS-Addressing headers MUST
aoqi@0: * be present on incoming and outgoing messages.
aoqi@0: *
aoqi@0: * @return the current required value
aoqi@0: */
aoqi@0: public boolean isRequired() {
aoqi@0: return required;
aoqi@0: }
aoqi@0:
aoqi@0: /**
aoqi@0: * If addressing is enabled, this property determines whether endpoint
aoqi@0: * requires the use of anonymous responses, or non-anonymous responses,
aoqi@0: * or all responses.
aoqi@0: *
aoqi@0: *
aoqi@0: * @return {@link Responses#ALL} when endpoint supports all types of aoqi@0: * responses, aoqi@0: * {@link Responses#ANONYMOUS} when endpoint requires the use of aoqi@0: * only anonymous responses, aoqi@0: * {@link Responses#NON_ANONYMOUS} when endpoint requires the use aoqi@0: * of only non-anonymous responses aoqi@0: * aoqi@0: * @since JAX-WS 2.2 aoqi@0: */ aoqi@0: public Responses getResponses() { aoqi@0: return responses; aoqi@0: } aoqi@0: aoqi@0: }