Path: blob/aarch64-shenandoah-jdk8u272-b10/jaxws/src/share/jaxws_classes/javax/xml/ws/FaultAction.java
38890 views
/*1* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package javax.xml.ws;2627import java.lang.annotation.Documented;28import java.lang.annotation.ElementType;29import java.lang.annotation.Retention;30import java.lang.annotation.RetentionPolicy;31import java.lang.annotation.Target;3233/**34* The <code>FaultAction</code> annotation is used inside an {@link Action}35* annotation to allow an explicit association of a WS-Addressing36* <code>Action</code> message addressing property with the <code>fault</code>37* messages of the WSDL operation mapped from the exception class.38* <p>39* The <code>wsam:Action</code> attribute value in the <code>fault</code>40* message in the generated WSDL operation mapped for <code>className</code>41* class is equal to the corresponding value in the <code>FaultAction</code>.42* For the exact computation of <code>wsam:Action</code> values for the43* fault messages, refer to the algorithm in the JAX-WS specification.44*45* <p>46* <b>Example 1</b>: Specify explicit values for <code>Action</code> message addressing47* property for the <code>input</code>, <code>output</code> and <code>fault</code> message48* if the Java method throws only one service specific exception.49*50* <pre>51* @WebService(targetNamespace="http://example.com/numbers")52* public class AddNumbersImpl {53* @Action(54* fault = {55* <b>@FaultAction(className=AddNumbersException.class, value="http://example.com/faultAction")</b>56* })57* public int addNumbers(int number1, int number2)58* throws AddNumbersException {59* return number1 + number2;60* }61* }62* </pre>63*64* The generated WSDL looks like:65*66* <pre>67* <definitions targetNamespace="http://example.com/numbers" ...>68* ...69* <portType name="AddNumbersPortType">70* <operation name="AddNumbers">71* ...72* <fault message="tns:AddNumbersException" name="AddNumbersException"73* <b>wsam:Action="http://example.com/faultAction"</b>/>74* </operation>75* </portType>76* ...77* </definitions>78* </pre>79*80* <p>81* Example 2: Here is an example that shows if the explicit value for <code>Action</code>82* message addressing property for the service specific exception is not present.83*84* <pre>85* @WebService(targetNamespace="http://example.com/numbers")86* public class AddNumbersImpl {87* public int addNumbers(int number1, int number2)88* throws AddNumbersException {89* return number1 + number2;90* }91* }92* </pre>93*94* The generated WSDL looks like:95*96* <pre>97* <definitions targetNamespace="http://example.com/numbers" ...>98* ...99* <portType name="AddNumbersPortType">100* <operation name="AddNumbers">101* ...102* <fault message="tns:addNumbersFault" name="InvalidNumbers"103* <b>wsam:Action="http://example.com/numbers/AddNumbersPortType/AddNumbers/Fault/AddNumbersException"</b>/>104* </operation>105* </portType>106* ...107* </definitions>108* </pre>109*110* <p>111* Example 3: Here is an example that shows how to specify explicit values for <code>Action</code>112* message addressing property if the Java method throws more than one service specific exception.113*114* <pre>115* @WebService(targetNamespace="http://example.com/numbers")116* public class AddNumbersImpl {117* @Action(118* fault = {119* <b>@FaultAction(className=AddNumbersException.class, value="http://example.com/addFaultAction"),120* @FaultAction(className=TooBigNumbersException.class, value="http://example.com/toobigFaultAction")</b>121* })122* public int addNumbers(int number1, int number2)123* throws AddNumbersException, TooBigNumbersException {124* return number1 + number2;125* }126* }127* </pre>128*129* The generated WSDL looks like:130*131* <pre>132* <definitions targetNamespace="http://example.com/numbers" ...>133* ...134* <portType name="AddNumbersPortType">135* <operation name="AddNumbers">136* ...137* <fault message="tns:addNumbersFault" name="AddNumbersException"138* <b>wsam:Action="http://example.com/addFaultAction"</b>/>139* <fault message="tns:tooBigNumbersFault" name="TooBigNumbersException"140* <b>wsam:Action="http://example.com/toobigFaultAction"</b>/>141* </operation>142* </portType>143* ...144* </definitions>145* </pre>146*147* @since JAX-WS 2.1148*/149150@Documented151@Retention(RetentionPolicy.RUNTIME)152@Target(ElementType.METHOD)153public @interface FaultAction {154/**155* Name of the exception class156*/157Class<? extends Exception> className();158159/**160* Value of WS-Addressing <code>Action</code> message addressing property for the exception161*/162String value() default "";163}164165166