此規則會標示對擷取 SOAP 錯誤和字串的方法的呼叫。
在 WebSphere Application Server 第 8 版中,Web 服務執行時期環境傳回的預設錯誤碼和字串已經改變。
具體來說,會標示下列方法
-
javax.xml.soap.SOAPFault.getFaultCode()
-
javax.xml.soap.SOAPFault.getFaultString()
-
com.ibm.websphere.webservices.soap.IBMSOAPFault.getFaultCode()
-
com.ibm.websphere.webservices.soap.IBMSOAPFault.getFaultString()
-
javax.xml.rpc.soap.SOAPFaultException.getFaultCode()
-
javax.xml.rpc.soap.SOAPFaultException.getFaultString()
-
com.ibm.websphere.webservices.soap.SOAPException.getFaultCode()
-
com.ibm.websphere.webservices.soap.SOAPException.getFaultString()
變更預設錯誤碼和字串是為了利用 XML 加密來修正與 Web 服務相關的潛在安全漏洞。 在這項修正中,移除了 Web 服務執行時期環境產生的任何 SOAP 錯誤之中的詳細資訊。 依預設,在第 8 版中, Web 服務執行時期環境會將執行時期環境所產生的所有錯誤統一成單一類型的錯誤,其中包含錯誤碼
soapenv:Server
及錯誤字串
Internal Error
.
如果您的應用程式會預期執行時期環境錯誤碼或字串中的詳細資訊,您可能需要修改您的應用程式。
您也可以使用
webservices.unify.faults
Java 虛擬機器自訂內容,以變更預設行為。
若要回復舊版的行為,請設定
webservices.unify.faults
收件者
false
.
在 WebSphere Application Server 第 8 版之前,預設行為是在錯誤碼或字串中傳回詳細資訊。 在包括 6.0.2、6.1 和 7.0 的服務串流中,也修正了這個問題,但這些版本中的預設行為沒有改變。
對於服務版本,
webservices.unify.faults
具有預設值
false
. 將該值變更為
true
以取得與那些版次中第 8 版相同的行為。
JAX-WS 範例:
import javax.xml.ws.soap.SOAPFaultException;
import javax.xml.ws.soap.SOAPFault;
try {
// some code that causes a fault
...
} catch (SOAPFaultException e) {
SOAPFault soapFault = e.getFault();
String faultCode = soapFault.getFaultCode();
String faultString = soapFault.getFaultString();
...
}
JAX-RPC 範例:
import javax.xml.rpc.soap.SOAPFaultException;
import javax.xml.namespace.QName;
try {
// some code that causes a fault
...
} catch (SOAPFaultException e) {
QName faultCode = e.getFaultCode();
String faultString = e.getFaultString();
...
}
在這兩個範例中,呼叫
getFaultCode()
和
getFaultString()
方法會被標示。
如需相關資訊,請參閱: