I am working on project upgrading from JDK 11 to JDK 17 and spring boot 3.3 and to consume soap web services, started using below Apache cxf dependency however custom checked exceptions that are defined in the soap service method throws block is not returned back. Instead getting below soapFault exception. When Soap service returns below InputViolationException instead of this getting soapFaultException. I tried to debug CXF opensource code to understand the issue. looks like ClientFaultConverter is not converting to InputViolationException. There seems code related typeclass information to fetch and assign to checked exception however typeclass naming coming as null in partInfo.
Is there any particular setting need to be set to get checked exceptions instead of default soapFault exception.
Any help would be appreciated. Configuration
@WebFault(name = "InputViolationException", targetNamespace = ";)
public class InputViolationException extends Exception {
private com.hello.InputViolationException faultInfo;
public InputViolationException() {
super();
}
public InputViolationException(String message) {
super(message);
}
public InputViolationException(String message, java.lang.Throwable cause) {
super(message, cause);
}
public InputViolationException(String message, com.hello.InputViolationException inputViolationException) {
super(message);
this.faultInfo = inputViolationException;
}
public InputViolationException(String message, com.hello.InputViolationException inputViolationException, java.lang.Throwable cause) {
super(message, cause);
this.faultInfo = inputViolationException;
}
public com.hello.InputViolationException getFaultInfo() {
return this.faultInfo;
}
}
<dependency>
<groupId>.apache.cxf</groupId>
<artifactId>cxf-spring-boot-starter-jaxws</artifactId>
<version>4.1.0</version>
</dependency>
@Bean
public HelloService HelloPort() {
JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
factory.setWsdlURL(String.valueOf(WSDL_URL));
factory.setServiceClass(HelloService.class);
factory.setAddress(baseCcapsUrl);
SoapInitializer.configureFactory(factory,new
SoapInitializer.ConnectionParams(this.connectTimeout, this.requestTimeout), sanitizeXML);
return (HelloService)factory.create();
}
'''
<SOAP-ENV:Envelope xmlns:SOAP-ENV="/">
<SOAP-ENV:Header/>
<SOAP-ENV:Body>
<SOAP-ENV:Fault>
<faultcode>SOAP-ENV:Server</faultcode>
<faultstring>This is an operation implementation generated fault</faultstring>
<faultactor/>
<detail xmlns:ns="; xmlns:ns0="/" xmlns:xs="; xmlns:xsi=";>
<ns:InputViolationException>
<serviceExceptionId>*****</serviceExceptionId>
<exceptionName>***</exceptionName>
<originatingComponentName>***</originatingComponentName>
<detailedMessageText>Error occurred in a component</detailedMessageText>
<exceptionHandledIndicator>true</exceptionHandledIndicator>
<serviceExceptionSeverityType>Error</serviceExceptionSeverityType>
<serviceExceptionType>InputViolationException</serviceExceptionType>
</ns:InputViolationException>
</detail>
</SOAP-ENV:Fault>
</SOAP-ENV:Body></SOAP-ENV:Envelope>
Caused by: jakarta.xml.ws.soap.SOAPFaultException: This is an operation implementation generated fault at .apache.cxf.jaxws.JaxWsClientProxy.mapException(JaxWsClientProxy.java:195) at .apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:145) at jdk.proxy2/jdk.proxy2.$Proxy60.getEmployeeForADId(Unknown Source) at com.bmo.channels.docu.adapters.eice.EiceAdapter.getEmployee(EiceAdapter.java:50) at com.bmo.channels.docu.adapters.eice.EiceAdapterTest.getEmployeeFailure(EiceAdapterTest.java:76) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:568) at .junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59) at .junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at .junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56) at .junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at .springframework.test.context.junit4.statements.RunBeforeTestExecutionCallbacks.evaluate(RunBeforeTestExecutionCallbacks.java:76) at .springframework.test.context.junit4.statements.RunAfterTestExecutionCallbacks.evaluate(RunAfterTestExecutionCallbacks.java:84) at .junit.internal.runners.statements.ExpectException.evaluate(ExpectException.java:19) ... 25 more Caused by: .apache.cxf.binding.soap.SoapFault: This is an operation implementation generated fault at .apache.cxf.binding.soap.interceptor.Soap11FaultInInterceptor.unmarshalFault(Soap11FaultInInterceptor.java:87) at .apache.cxf.binding.soap.interceptor.Soap11FaultInInterceptor.handleMessage(Soap11FaultInInterceptor.java:53)