Jim
Jim

Reputation: 16022

reading CXF exception message detail from ServerSOAPFaultException

I have generated a web service using cxf-codegen-plugin. Instead of obtaining the returned exception detail, I always get a ServerSOAPFaultException with the message check the server log to find more detail.

I know that the web service I am calling is returning detailed error information, but it seems inaccessible.

I am using spring-boot.

How do I read the full error information?

I am calling the generated code as follows in spring boot.

public LogonResponse loginLoadBearerToken(LogonRequest lr) throws LogonFault {
    try {
        SecurityService_Service factory = createSecurityService();
        SecurityService securityService = factory.getSecurityServiceSoap11();
        BindingProvider bp = (BindingProvider) securityService;
        String url = String.format("%s/SecurityService-v4_x/securityService/", clientUrl);
        bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, url);

        LogonResponse response = securityService.logon(lr);
        return response;
    } catch (Exception ex) {
        // THIS IS ALWAYS A ServerClientSOAPException
        logger.error("login error connecting to ... {}", ex.getMessage());
        throw ex;
    }
}

Upvotes: 0

Views: 75

Answers (1)

Jim
Jim

Reputation: 16022

Simple solution... add the necessary dependencies.

<dependency>
    <groupId>org.apache.cxf</groupId>
    <artifactId>cxf-rt-frontend-jaxws</artifactId>
    <version>${cxf.version}</version>
</dependency>
<dependency>
    <groupId>org.apache.cxf</groupId>
    <artifactId>cxf-rt-transports-http</artifactId>
    <version>${cxf.version}</version>
</dependency>

Upvotes: 1

Related Questions