@Documented @Retention(value=RUNTIME) @Target(value=METHOD) public @interface FaultAction
FaultAction
注解用于内部Action
注释以允许WS寻址的显式关联Action
与消息寻址属性fault
从异常类映射到的WSDL操作的消息。
该wsam:Action
在属性值fault
在映射所生成的WSDL操作消息className
类是等于在相应的值FaultAction
。 有关故障消息的wsam:Action
值的精确计算,请参考JAX-WS规范中的算法。
示例1 :如果Java方法仅抛出一个特定于服务的input
, output
和fault
消息指定Action
消息寻址属性的显式值。
@WebService(targetNamespace="http://example.com/numbers")
public class AddNumbersImpl {
@Action(
fault = {
@FaultAction(className=AddNumbersException.class, value="http://example.com/faultAction")
})
public int addNumbers(int number1, int number2)
throws AddNumbersException {
return number1 + number2;
}
}
生成的WSDL如下所示:
<definitions targetNamespace="http://example.com/numbers" ...>
...
<portType name="AddNumbersPortType">
<operation name="AddNumbers">
...
<fault message="tns:AddNumbersException" name="AddNumbersException"
wsam:Action="http://example.com/faultAction"/>
</operation>
</portType>
...
</definitions>
示例2:这是一个示例,显示服务特定异常的Action
消息寻址属性的显式值是否不存在。
@WebService(targetNamespace="http://example.com/numbers")
public class AddNumbersImpl {
public int addNumbers(int number1, int number2)
throws AddNumbersException {
return number1 + number2;
}
}
生成的WSDL如下所示:
<definitions targetNamespace="http://example.com/numbers" ...>
...
<portType name="AddNumbersPortType">
<operation name="AddNumbers">
...
<fault message="tns:addNumbersFault" name="InvalidNumbers"
wsam:Action="http://example.com/numbers/AddNumbersPortType/AddNumbers/Fault/AddNumbersException"/>
</operation>
</portType>
...
</definitions>
示例3:下面是一个示例,显示如果Java方法抛出多个服务特定异常,则如何指定Action
消息寻址属性的显式值。
@WebService(targetNamespace="http://example.com/numbers")
public class AddNumbersImpl {
@Action(
fault = {
@FaultAction(className=AddNumbersException.class, value="http://example.com/addFaultAction"), @FaultAction(className=TooBigNumbersException.class, value="http://example.com/toobigFaultAction")
})
public int addNumbers(int number1, int number2)
throws AddNumbersException, TooBigNumbersException {
return number1 + number2;
}
}
生成的WSDL如下所示:
<definitions targetNamespace="http://example.com/numbers" ...>
...
<portType name="AddNumbersPortType">
<operation name="AddNumbers">
...
<fault message="tns:addNumbersFault" name="AddNumbersException"
wsam:Action="http://example.com/addFaultAction"/>
<fault message="tns:tooBigNumbersFault" name="TooBigNumbersException"
wsam:Action="http://example.com/toobigFaultAction"/>
</operation>
</portType>
...
</definitions>
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.