Results 1 to 2 of 2

Thread: Custom FaultResolver

  1. #1

    Default Custom FaultResolver

    Again...continuing work on my Spring-WS client...

    Is there a way to combine a custom FaultResolver with Spring-WS's built-in OXM capabilities? (e.g. automatically map a fault to an exception)

    I mean I know I can utilize the OXM Frameworks' native API to accomplish this, but is there a mechanism to use the marshaller/unmarshaller that Spring-WS is already using for non-fault responses.

  2. #2
    Join Date
    Jul 2005
    Location
    Rotterdam, the Netherlands
    Posts
    1,562

    Default

    Not yet, though it would probably be easy:

    Code:
    public class UnmarshallingFaultResolver implements FaultResolver {
        private Unmarshaller unmarshaller;
    
        public void setUnmarshaller(Unmarshaller unmarshaller) {
            this.unmarshaller = unmarshaller;
        }
    
        public void resolveFault(WebServiceMessage message) throws IOException {
            SoapMessage soapMessage = (SoapMessage) message;
            SoapFaultDetail detail = soapMessage.getSoapBody().getFault().getFaultDetail();
            for (Iterator iterator = detail.getDetailEntries(); iterator.hasNext();) {
                SoapFaultDetailElement detailElement = (SoapFaultDetailElement) iterator.next();
                Object unmarshalled = unmarshaller.unmarshal(detailElement.getSource());
                if (unmarshalled instanceof RuntimeException) {
                    throw (RuntimeException) unmarshalled;
                }
            }
        }
    }
    Or something similar.
    Arjen Poutsma

    Spring Web Services Dev Lead
    Please read the FAQ

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •