1 17 package org.apache.servicemix.soap; 18 19 import java.net.URI ; 20 21 import javax.xml.namespace.QName ; 22 import javax.xml.transform.Source ; 23 24 import org.apache.servicemix.soap.marshalers.SoapMarshaler; 25 26 34 public class SoapFault extends Exception { 35 36 private static final long serialVersionUID = 984561453557136677L; 37 38 public static final QName SENDER = SoapMarshaler.SOAP_12_CODE_SENDER; 39 public static final QName RECEIVER = SoapMarshaler.SOAP_12_CODE_RECEIVER; 40 41 private QName code; 42 private QName subcode; 43 private String reason; 44 private URI node; 45 private URI role; 46 private Source details; 47 48 public SoapFault(Exception cause) { 49 super(cause); 50 } 51 52 public SoapFault(QName code, String reason) { 53 super(reason); 54 this.code = code; 55 this.reason = reason; 56 } 57 58 public SoapFault(QName code, QName subcode, String reason) { 59 super(reason); 60 this.code = code; 61 this.subcode = subcode; 62 this.reason = reason; 63 } 64 65 public SoapFault(QName code, String reason, URI node, URI role) { 66 super(reason); 67 this.code = code; 68 this.reason = reason; 69 this.node = node; 70 this.role = role; 71 } 72 73 public SoapFault(QName code, String reason, URI node, URI role, Source details) { 74 super(reason); 75 this.code = code; 76 this.reason = reason; 77 this.node = node; 78 this.role = role; 79 this.details = details; 80 } 81 82 public SoapFault(QName code, QName subcode, String reason, URI node, URI role, Source details) { 83 super(reason); 84 this.code = code; 85 this.subcode = subcode; 86 this.reason = reason; 87 this.node = node; 88 this.role = role; 89 this.details = details; 90 } 91 92 public QName getCode() { 93 return code; 94 } 95 96 public QName getSubcode() { 97 return subcode; 98 } 99 100 public String getReason() { 101 return reason; 102 } 103 104 public URI getNode() { 105 return node; 106 } 107 108 public URI getRole() { 109 return role; 110 } 111 112 public Source getDetails() { 113 return details; 114 } 115 116 public void translateCodeTo11() { 117 if (code != null) { 118 if (subcode != null) { 119 code = subcode; 120 subcode = null; 121 } else if (SoapMarshaler.SOAP_12_CODE_DATAENCODINGUNKNOWN.equals(code)) { 122 code = SoapMarshaler.SOAP_11_CODE_CLIENT; 123 } else if (SoapMarshaler.SOAP_12_CODE_MUSTUNDERSTAND.equals(code)) { 124 code = SoapMarshaler.SOAP_11_CODE_MUSTUNDERSTAND; 125 } else if (SoapMarshaler.SOAP_12_CODE_RECEIVER.equals(code)) { 126 code = SoapMarshaler.SOAP_11_CODE_SERVER; 127 } else if (SoapMarshaler.SOAP_12_CODE_SENDER.equals(code)) { 128 code = SoapMarshaler.SOAP_11_CODE_CLIENT; 129 } 130 } else { 131 code = SoapMarshaler.SOAP_11_CODE_SERVER; 132 } 133 } 134 135 public void translateCodeTo12() { 136 if (code != null && subcode == null) { 137 if (SoapMarshaler.SOAP_11_CODE_CLIENT.equals(code)) { 138 code = SoapMarshaler.SOAP_12_CODE_SENDER; 139 } else if (SoapMarshaler.SOAP_11_CODE_MUSTUNDERSTAND.equals(code)) { 140 code = SoapMarshaler.SOAP_12_CODE_MUSTUNDERSTAND; 141 } else if (SoapMarshaler.SOAP_11_CODE_SERVER.equals(code)) { 142 code = SoapMarshaler.SOAP_12_CODE_RECEIVER; 143 } else if (SoapMarshaler.SOAP_11_CODE_VERSIONMISMATCH.equals(code)) { 144 code = SoapMarshaler.SOAP_12_CODE_VERSIONMISMATCH; 145 } else { 146 subcode = code; 147 code = SoapMarshaler.SOAP_12_CODE_SENDER; 148 } 149 } else if (code == null) { 150 code = SoapMarshaler.SOAP_12_CODE_RECEIVER; 151 } 152 } 153 } 154 | Popular Tags |