Example usage for javax.xml.soap SOAPFault getFaultReasonTexts

List of usage examples for javax.xml.soap SOAPFault getFaultReasonTexts

Introduction

In this page you can find the example usage for javax.xml.soap SOAPFault getFaultReasonTexts.

Prototype

public Iterator<String> getFaultReasonTexts() throws SOAPException;

Source Link

Document

Returns an Iterator over a sequence of String objects containing all of the Reason Text items for this SOAPFault .

Usage

From source file:org.apache.axis2.saaj.SOAPFactoryTest.java

@Validated
@Test/*  w  w w  .  j  a v  a 2  s  .  co m*/
public void testCreateFault() {
    try {
        SOAPFactory factory = SOAPFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);
        //SOAPFactory factory = SOAPFactory.newInstance();
        SOAPFault sf = factory.createFault("This is the fault reason.", SOAPConstants.SOAP_RECEIVER_FAULT);
        assertNotNull(sf);
        assertTrue(sf instanceof SOAPFault);
        QName fc = sf.getFaultCodeAsQName();
        //Expect FaultCode="+SOAPConstants.SOAP_RECEIVER_FAULT
        Iterator i = sf.getFaultReasonTexts();
        if (i == null) {
            log.info("Call to getFaultReasonTexts() returned null iterator");
        }
        String reason = "";
        while (i.hasNext()) {
            reason += (String) i.next();
        }
        assertNotNull(reason);
        assertTrue(reason.indexOf("This is the fault reason.") > -1);
        assertTrue(fc.equals(SOAPConstants.SOAP_RECEIVER_FAULT));
    } catch (SOAPException e) {
        fail("Caught unexpected SOAPException");
    }
}

From source file:org.apache.axis2.saaj.SOAPFactoryTest.java

@Test
public void testCreateFault1() {
    try {/*w w w . j av  a2s .  c  o m*/
        //SOAPFactory factory = SOAPFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);
        SOAPFactory factory = SOAPFactory.newInstance();
        SOAPFault sf = factory.createFault("This is the fault reason.", SOAPConstants.SOAP_RECEIVER_FAULT);
        assertNotNull(sf);
        QName fc = sf.getFaultCodeAsQName();
        Iterator i = sf.getFaultReasonTexts();

        String reason = "";
        while (i.hasNext()) {
            reason += (String) i.next();
        }
        log.info("Actual ReasonText=" + reason);
        assertNotNull(reason);
        assertTrue(reason.indexOf("This is the fault reason.") > -1);
        assertTrue(fc.equals(SOAPConstants.SOAP_RECEIVER_FAULT));
    } catch (SOAPException e) {
        //Caught expected SOAPException
    } catch (Exception e) {
        fail("Exception: " + e);
    }
}