001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one
003: * or more contributor license agreements. See the NOTICE file
004: * distributed with this work for additional information
005: * regarding copyright ownership. The ASF licenses this file
006: * to you under the Apache License, Version 2.0 (the
007: * "License"); you may not use this file except in compliance
008: * with the License. You may obtain a copy of the License at
009: *
010: * http://www.apache.org/licenses/LICENSE-2.0
011: *
012: * Unless required by applicable law or agreed to in writing,
013: * software distributed under the License is distributed on an
014: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015: * KIND, either express or implied. See the License for the
016: * specific language governing permissions and limitations
017: * under the License.
018: */
019: package org.apache.axis2.jaxws.message;
020:
021: import javax.xml.namespace.QName;
022:
023: /**
024: * This is a value class that is an agnostic representation of a fault. The XMLFault can be added to
025: * or queried from a Message/XMLPart.
026: * <p/>
027: * Even though XMLFault is SOAP 1.1/SOAP 1.2 agnostic, SOAP 1.2 terms will be used. For example,
028: * "reason" means SOAP 1.2 Reason or SOAP 1.1 faultstring.
029: *
030: * @see XMLFaultUtils
031: */
032: public class XMLFault {
033:
034: // Here is a sample comprehensive SOAP 1.2 fault which will help you understand the
035: // structure of XMLFault.
036: // <env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope"
037: // xmlns:m="http://www.example.org/timeouts"
038: // xmlns:xml="http://www.w3.org/XML/1998/namespace">
039: // <env:Body>
040: // <env:Fault>
041: // <env:Code>
042: // <env:Value>env:Sender</env:Value>
043: // <env:Subcode>
044: // <env:Value>m:MessageTimeout</env:Value>
045: // </env:Subcode>
046: // </env:Code>
047: // <env:Reason>
048: // <env:Text xml:lang="en">Sender Timeout</env:Text>
049: // <env:Text xml:lang="de">Sender Timeout</env:Text>
050: // </env:Reason>
051: // <env:Node>http://my.example.org/Node</env:Node>
052: // <env:Role>http://my.example.org/Role</env:Role>
053: // <env:Detail>
054: // <m:MaxTime>P5M</m:MaxTime>
055: // </env:Detail>
056: // </env:Fault>
057: // </env:Body>
058: // </env:Envelope>
059:
060: // Here is the same information rendered as a SOAP 1.1 fault. Notice
061: // that this is a subset of information.
062: // <env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope"
063: // xmlns:m="http://www.example.org/timeouts"
064: // xmlns:xml="http://www.w3.org/XML/1998/namespace">
065: // <env:Body>
066: // <env:Fault>
067: // <faultcode>env.Client</faultcode>
068: // <faultstring>Sender Timeout</faultstring>
069: // <actor>http://my.example.org/Role</actor>
070: // <detail>
071: // <m:MaxTime>P5M</m:MaxTime>
072: // <detail>
073: // </env:Fault>
074: // </env:Body>
075: // </env:Envelope>
076:
077: // The required information (necessary for both SOAP 1.1 and SOAP 1.2)
078: private XMLFaultCode code;
079: private XMLFaultReason reason;
080: private Block[] detailBlocks;
081:
082: // The optional information (can be set on XMLFault, but only rendered in SOAP 1.2 Faults)
083: private String role;
084: private String node;
085: private QName[] subCodes = null; // The subCodes are user-defined. The values are not defined by a specification
086: private XMLFaultReason[] secondaryReasons = null;
087:
088: /**
089: * Construct Application XMLFault with minimum required information
090: *
091: * @param code - XMLFaultCode or null if default XMLFaultCode
092: * @param reason - String reason
093: * @param detailBlocks - Block[] or null if no detailBlocks
094: */
095: public XMLFault(XMLFaultCode code, XMLFaultReason reason,
096: Block[] detailBlocks) {
097: if (code == null) {
098: code = XMLFaultCode.RECEIVER;
099: }
100: this .code = code;
101: this .reason = reason;
102: this .detailBlocks = detailBlocks;
103: }
104:
105: /**
106: * Construct System XMLFault with minimum required information
107: *
108: * @param code - XMLFaultCode or null if default XMLFaultCode
109: * @param reason - String reason
110: */
111: public XMLFault(XMLFaultCode code, XMLFaultReason reason) {
112: this (code, reason, null);
113: }
114:
115: /** @return Returns the code. */
116: public XMLFaultCode getCode() {
117: return code;
118: }
119:
120: /** @return Returns the detailBlocks. */
121: public Block[] getDetailBlocks() {
122: return detailBlocks;
123: }
124:
125: /** @return Returns the reason. */
126: public XMLFaultReason getReason() {
127: return reason;
128: }
129:
130: /** @return Returns the node. */
131: public String getNode() {
132: return node;
133: }
134:
135: /** @param node The node to set. */
136: public void setNode(String node) {
137: this .node = node;
138: }
139:
140: /** @return Returns the role. */
141: public String getRole() {
142: return role;
143: }
144:
145: /** @param role The role to set. */
146: public void setRole(String role) {
147: this .role = role;
148: }
149:
150: /** @return Returns the secondaryReasons. */
151: public XMLFaultReason[] getSecondaryReasons() {
152: return secondaryReasons;
153: }
154:
155: /** @param secondaryReasons The secondaryReasons to set. */
156: public void setSecondaryReasons(XMLFaultReason[] secondaryReasons) {
157: this .secondaryReasons = secondaryReasons;
158: }
159:
160: /** @return Returns the subCodes. */
161: public QName[] getSubCodes() {
162: return subCodes;
163: }
164:
165: /** @param subCodes The subCodes to set. */
166: public void setSubCodes(QName[] subCodes) {
167: this.subCodes = subCodes;
168: }
169:
170: }
|