简体   繁体   中英

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

<bean class="org.springframework.ws.soap.server.endpoint.SoapFaultAnnotationExceptionResolver"/>

It is working fine if I call this service from SOAPUI. I'm getting proper SOAP fault with faultcode and faultString .

But, when I'm invoking the service from java spring client. 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 .

Thanks in advance for any help in this regard.

您可以在客户端代码中捕获故障,并在catch块中使用exception.getFaultCode()和exception.getFaultString()检索故障代码和字符串,请查看j avadoc以获取更多详细信息。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM