[英]Return SOAP fault object with custom faultcode and message in Spring WS
I have a Spring webservice which throws a custom exception for any error scenerio. 我有一个Spring网络服务,它会为任何错误场景抛出自定义异常。 I have configured the exception class like this:
我已经这样配置了异常类:
@SoapFault(faultCode = FaultCode.CUSTOM, customFaultCode="{http://com/examples/webservice/utils/AppConstants}"+AppConstants.FAULT_CODE)
public class ConfigurationException extends Exception {/**Codes**/}
Throwing exception as below: 抛出异常如下:
throw new ConfigurationException("Validation exception");
and in Spring config xml I have added this: 在Spring config xml中,我添加了以下内容:
<bean class="org.springframework.ws.soap.server.endpoint.SoapFaultAnnotationExceptionResolver"/>
It is working fine if I call this service from SOAPUI. 如果我从SOAPUI调用此服务,则工作正常。 I'm getting proper SOAP fault with faultcode and faultString .
我正在使用faultcode和faultString得到正确的SOAP错误。
But, when I'm invoking the service from java spring client. 但是,当我从java spring客户端调用服务时。 I'm getting SOAP fault as exception.My requirement is to get SOAP fault message object so that I can get the faultCode and faultString .
我将SOAP错误作为异常。我的要求是获取SOAP错误消息对象,以便可以获取faultCode和faultString 。
Thanks in advance for any help in this regard. 在此先感谢您的帮助。
您可以在客户端代码中捕获故障,并在catch块中使用exception.getFaultCode()和exception.getFaultString()检索故障代码和字符串,请查看j avadoc以获取更多详细信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.