我試圖實現自定義SOAP錯誤象下面這樣:自定義SOAP錯誤
@SoapFault(faultCode = FaultCode.CUSTOM, customFaultCode="{namespace}Server Error", faultStringOrReason="Error encountered when processing request message.")
public class SystemFault extends BusinessException{ }.
拋出SOAP錯誤是以下格式:
<.SOAP-ENV:Fault>
<.faultcode xmlns:ns0="namespace">ns0:star:Server Error<./faultcode>
<.faultstring xml:lang="en">Error Encountered when processing the request.<./faultstring>
<./SOAP-ENV:Fault>
,你可以請參閱錯誤代碼標籤出現在名稱空間聲明中。請讓我知道是否有任何迴避。 SOAP錯誤客戶端的格式期待是:
<.soapenv:Fault xmlns:star="http://www.starstandard.org/STAR/5">
<.faultcode>star:Custom Fault Code<./faultcode>
<.faultstring>Custom Fault message<./faultstring>
<./soapenv:Fault>
我經過AbstractSoapFaultDefinitionExceptionResolver.resolveExceptionInternal()
方法,它期待的故障代碼,而不是一個字符串QName
實例。請讓我知道如何解決這個問題。
嗨阿爾喬姆,感謝您的詳細的郵件。我發現這個問題。有一個來自AbstractSoapFaultDefinitionExceptionResolver.getFaultDefinition()的方法調用如下:fault = soap11Body.addFault(definition.getFaultCode(),faultStringOrReason,definition.getLocale());所以在SaajSoap11Body中,有一個Assert語句Assert.hasLength(faultCode.getNamespaceURI(),「faultCode的namespaceUri不能爲空」);.這是造成問題的原因。 –
好吧,如果你能夠在根目錄''上聲明'xmlns',你仍然可以像'{namespace}'實例一樣聲明它。根據'FaultImpl',它應該'確保NamespaceIsDeclared()',這意味着重用和現有的'xmlns'。 –
我能夠將名稱空間聲明帶入通過重寫resolveExceptionInternal方法,但我不能將名稱空間聲明帶到標籤 –