Skip to content

Commit e5f7871

Browse files
committed
Merge branch '4.0.x'
Closes gh-1514
2 parents 5b401a6 + b78b151 commit e5f7871

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

spring-ws-docs/src/docs/asciidoc/server.adoc

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1190,7 +1190,40 @@ Rather than expose the innards of your application by giving an exception and st
11901190
Endpoint exception resolvers are automatically picked up by the `MessageDispatcher`, so no explicit configuration is necessary.
11911191

11921192
Besides implementing the `EndpointExceptionResolver` interface, which is only a matter of implementing the `resolveException(MessageContext, endpoint, Exception)` method, you may also use one of the provided implementations.
1193+
11931194
The simplest implementation is the `SimpleSoapExceptionResolver`, which creates a SOAP 1.1 Server or SOAP 1.2 Receiver fault and uses the exception message as the fault string.
1195+
You can subclass it to customize the fault, as shown in the following example:
1196+
1197+
[source,java]
1198+
----
1199+
public class CustomSoapExceptionResolver extends SimpleSoapExceptionResolver {
1200+
1201+
private final Transformer transformer;
1202+
1203+
public CustomSoapExceptionResolver(Transformer transformer) {
1204+
this.transformer = transformer;
1205+
}
1206+
1207+
@Override
1208+
protected void customizeFault(MessageContext messageContext, Object endpoint, Exception exception,
1209+
SoapFault fault) {
1210+
SoapFaultDetail faultDetail = fault.addFaultDetail();
1211+
try {
1212+
this.transformer.transform(new StringSource("""
1213+
<ns2:YourCustomException xmlns:ns2="http://serviceendpoint/">
1214+
<errorCode>Your custom error code</exName>
1215+
<systemMessage>A system message</exMessage>
1216+
</ns2:YourCustomException >
1217+
"""), faultDetail.getResult());
1218+
}
1219+
catch (TransformerException ex) {
1220+
throw new IllegalArgumentException("Failed to write detail", ex);
1221+
}
1222+
1223+
}
1224+
}
1225+
----
1226+
11941227
The `SimpleSoapExceptionResolver` is the default, but it can be overridden by explicitly adding another resolver.
11951228

11961229
=== `SoapFaultMappingExceptionResolver`

0 commit comments

Comments
 (0)