我已经使用 cxf-codegen-plugin
生成了一个 Web 服务。
我总是得到一个带有消息检查服务器日志以查找更多详细信息
的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;
}
}
最佳答案
简单的解决方案...添加必要的依赖项。
<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>
关于java - 从 ServerSOAPFaultException 读取 CXF 异常消息详细信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58471440/