2017-08-16 106 views
0
<soap:Fault> 
    <faultcode>soap:Server</faultcode> 

我想自定義肥皂:我的自定義字符串服務器字符串。如何自定義肥皂<FaultCode>

我正在爲我的項目使用駱駝cxf。並使用POJO模型來消費和公開服務。

回答

0

faultCodeQName作爲值,即它需要在特定名稱空間中定義的名稱。在你的例子中,檢查短代碼soap的名稱空間定義,它可能是http://schemas.xmlsoap.org/soap/envelope/,因爲你沒有定製任何東西。

要改變它,你將不得不手動構建一個錯誤的對象在你的代碼,並在faultCode場設置QName,像這樣(假設SOAP 1.1,1.2將類似)

SOAPBody body = message.getSOAPBody(); 
SOAPFault fault = body.addFault(); 
QName faultName = new QName("http://your.namespace.here.com/and/some/more", "Your Error code here"); 
fault.setFaultCode(faultName); 
fault.setFaultActor("Fault actor name"); 
fault.setFaultString("Say what's wrong here"); 

You can read more about it here.