<soapenv:Fault xmlns:m="http://schemas.xmlsoap.org/soap/envelope/">
<faultcode>m:Server</faultcode>
<faultstring>someFaultString</faultstring>
<detail>
<NS1:confirmIdentityErrorInfo xmlns:NS1="example.com">
<faultInfo>
<faultType>Business Exception</faultType>
<faultCode>100</faultCode>
<message>some message</message>
<faultState>fault state</faultState>
</faultInfo>
</NS1:confirmIdentityErrorInfo>
</detail>
</soapenv:Fault>
Мне нужно было бы создать объект сбоя, как указано выше. Я могу генерировать 'confirmIdentityErrorInfo', но не могу добавить дочерние элементы. Я попробовал эту опцию, но я не мог создать структуру вложенных объектов.Как добавить сложную XML-детальную ошибку SOAP в веб-службу Spring?
public class WebServiceConfig extends WsConfigurerAdapter {
@Bean
public SoapFaultMappingExceptionResolver exceptionResolver(){
SoapFaultMappingExceptionResolver exceptionResolver = new DetailSoapFaultDefinitionExceptionResolver();
SoapFaultDefinition faultDefinition = new SoapFaultDefinition();
faultDefinition.setFaultCode(SoapFaultDefinition.SERVER);
exceptionResolver.setDefaultFault(faultDefinition);
Properties errorMappings = new Properties();
errorMappings.setProperty(Exception.class.getName(), SoapFaultDefinition.SERVER.toString());
errorMappings.setProperty(BusinessException.class.getName(), SoapFaultDefinition.SERVER.toString());
exceptionResolver.setExceptionMappings(errorMappings);
exceptionResolver.setOrder(1);
return exceptionResolver;
}
}
protected void customizeFault(Object endpoint, Exception ex, SoapFault fault) {
if (ex instanceof BusinessException) {
SoapFaultDetail detail = fault.addFaultDetail();
try
{
QName entryName = new QName("namespace", "confirmIdentityErrorInfo", "NS1");
detail.addFaultDetailElement(entryName);
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
Но я не уверен, как добавить дочерние элементы для QName. Может ли кто-нибудь помочь мне как обработать детали неисправности, как показано выше?