从ServerSOAPFaultException读取CXF异常消息详细信息

时间:2019-10-20 09:01:29

标签: java spring spring-boot cxf

我已经使用cxf-codegen-plugin生成了一个Web服务。 我始终没有获得带有消息check the server log to find more detail ServerSOAPFaultException

我知道我正在调用的Web服务正在返回详细的错误信息,但是似乎无法访问。

我正在使用 spring-boot

如何读取完整的错误信息?

我在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;
    }
}

1 个答案:

答案 0 :(得分:0)

简单的解决方案...添加必要的依赖项。

<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>