2017-08-16 105 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.