Search in sources :

Example 11 with SOAPProcessingException

use of org.apache.axiom.soap.SOAPProcessingException in project webservices-axiom by apache.

the class TestWrongParent3 method runTest.

@Override
protected void runTest() throws Throwable {
    SOAPHeader parent = soapFactory.createSOAPHeader();
    OMElement child1 = soapFactory.createSOAPHeaderBlock("child1", soapFactory.createOMNamespace("urn:test", "p"), parent);
    SOAPFault fault = soapFactory.createSOAPFault();
    try {
        child1.insertSiblingBefore(fault);
        fail("Expected SOAPProcessingException");
    } catch (SOAPProcessingException ex) {
    // Expected
    }
}
Also used : SOAPProcessingException(org.apache.axiom.soap.SOAPProcessingException) OMElement(org.apache.axiom.om.OMElement) SOAPFault(org.apache.axiom.soap.SOAPFault) SOAPHeader(org.apache.axiom.soap.SOAPHeader)

Example 12 with SOAPProcessingException

use of org.apache.axiom.soap.SOAPProcessingException in project webservices-axiom by apache.

the class TestWrongParent2 method runTest.

@Override
protected void runTest() throws Throwable {
    SOAPFault parent = soapFactory.createSOAPFault();
    OMElement child1 = soapFactory.createSOAPFaultCode(parent);
    SOAPHeaderBlock hb = soapFactory.createSOAPHeaderBlock("MyHeader", soapFactory.createOMNamespace("urn:test", "p"));
    try {
        child1.insertSiblingAfter(hb);
        fail("Expected SOAPProcessingException");
    } catch (SOAPProcessingException ex) {
    // Expected
    }
}
Also used : SOAPProcessingException(org.apache.axiom.soap.SOAPProcessingException) SOAPFault(org.apache.axiom.soap.SOAPFault) OMElement(org.apache.axiom.om.OMElement) SOAPHeaderBlock(org.apache.axiom.soap.SOAPHeaderBlock)

Example 13 with SOAPProcessingException

use of org.apache.axiom.soap.SOAPProcessingException in project webservices-axiom by apache.

the class TestWrongParent1 method runTest.

@Override
protected void runTest() throws Throwable {
    SOAPBody parent = soapFactory.createSOAPBody();
    SOAPHeaderBlock hb = soapFactory.createSOAPHeaderBlock("MyHeader", soapFactory.createOMNamespace("urn:test", "p"));
    try {
        parent.addChild(hb);
        fail("Expected SOAPProcessingException");
    } catch (SOAPProcessingException ex) {
    // Expected
    }
}
Also used : SOAPBody(org.apache.axiom.soap.SOAPBody) SOAPProcessingException(org.apache.axiom.soap.SOAPProcessingException) SOAPHeaderBlock(org.apache.axiom.soap.SOAPHeaderBlock)

Example 14 with SOAPProcessingException

use of org.apache.axiom.soap.SOAPProcessingException in project webservices-axiom by apache.

the class TestSetChildVersionMismatch method runTest.

@Override
protected void runTest(OMElement parent, SOAPElementTypeAdapter adapter) {
    OMElement child = adapter.create(altSoapFactory);
    try {
        adapter.getSetter().invoke(parent, child);
        fail("Expected SOAPProcessingException");
    } catch (SOAPProcessingException ex) {
    // Expected
    }
}
Also used : SOAPProcessingException(org.apache.axiom.soap.SOAPProcessingException) OMElement(org.apache.axiom.om.OMElement)

Example 15 with SOAPProcessingException

use of org.apache.axiom.soap.SOAPProcessingException in project webservices-axiom by apache.

the class SOAP12BuilderHelper method handleEvent.

@Override
public Class<? extends AxiomElement> handleEvent(OMElement parent, int elementLevel, String namespaceURI, String localName) throws SOAPProcessingException {
    Class<? extends AxiomElement> elementType = null;
    if (elementLevel == 4) {
        if (localName.equals(SOAP12Constants.SOAP_FAULT_CODE_LOCAL_NAME)) {
            if (codePresent) {
                throw new SOAPProcessingException("Multiple Code element encountered");
            } else {
                elementType = AxiomSOAP12FaultCode.class;
                codePresent = true;
                codeprocessing = true;
            }
        } else if (localName.equals(SOAP12Constants.SOAP_FAULT_REASON_LOCAL_NAME)) {
            if (!codeprocessing && !subCodeProcessing) {
                if (codePresent) {
                    if (reasonPresent) {
                        throw new SOAPProcessingException("Multiple Reason Element encountered");
                    } else {
                        elementType = AxiomSOAP12FaultReason.class;
                        reasonPresent = true;
                        reasonProcessing = true;
                    }
                } else {
                    throw new SOAPProcessingException("Wrong element order encountred at " + localName);
                }
            } else {
                if (codeprocessing) {
                    throw new SOAPProcessingException("Code doesn't have a value");
                } else {
                    throw new SOAPProcessingException("A subcode doesn't have a Value");
                }
            }
        } else if (localName.equals(SOAP12Constants.SOAP_FAULT_NODE_LOCAL_NAME)) {
            if (!reasonProcessing) {
                if (reasonPresent && !rolePresent && !detailPresent) {
                    if (nodePresent) {
                        throw new SOAPProcessingException("Multiple Node element encountered");
                    } else {
                        elementType = AxiomSOAP12FaultNode.class;
                        nodePresent = true;
                    }
                } else {
                    throw new SOAPProcessingException("wrong element order encountered at " + localName);
                }
            } else {
                throw new SOAPProcessingException("Reason element Should have a text");
            }
        } else if (localName.equals(SOAP12Constants.SOAP_FAULT_ROLE_LOCAL_NAME)) {
            if (!reasonProcessing) {
                if (reasonPresent && !detailPresent) {
                    if (rolePresent) {
                        throw new SOAPProcessingException("Multiple Role element encountered");
                    } else {
                        elementType = AxiomSOAP12FaultRole.class;
                        rolePresent = true;
                    }
                } else {
                    throw new SOAPProcessingException("Wrong element order encountered at " + localName);
                }
            } else {
                throw new SOAPProcessingException("Reason element should have a text");
            }
        } else if (localName.equals(SOAP12Constants.SOAP_FAULT_DETAIL_LOCAL_NAME)) {
            if (!reasonProcessing) {
                if (reasonPresent) {
                    if (detailPresent) {
                        throw new SOAPProcessingException("Multiple detail element encountered");
                    } else {
                        elementType = AxiomSOAP12FaultDetail.class;
                        detailPresent = true;
                    }
                } else {
                    throw new SOAPProcessingException("wrong element order encountered at " + localName);
                }
            } else {
                throw new SOAPProcessingException("Reason element should have a text");
            }
        } else {
            throw new SOAPProcessingException(localName + " unsupported element in SOAPFault element");
        }
    } else if (elementLevel == 5) {
        if (parent.getLocalName().equals(SOAP12Constants.SOAP_FAULT_CODE_LOCAL_NAME)) {
            if (localName.equals(SOAP12Constants.SOAP_FAULT_VALUE_LOCAL_NAME)) {
                if (!valuePresent) {
                    elementType = AxiomSOAP12FaultValue.class;
                    valuePresent = true;
                    codeprocessing = false;
                } else {
                    throw new SOAPProcessingException("Multiple value Encountered in code element");
                }
            } else if (localName.equals(SOAP12Constants.SOAP_FAULT_SUB_CODE_LOCAL_NAME)) {
                if (!subcodePresent) {
                    if (valuePresent) {
                        elementType = AxiomSOAP12FaultSubCode.class;
                        subcodePresent = true;
                        subCodeProcessing = true;
                    } else {
                        throw new SOAPProcessingException("Value should present before the subcode");
                    }
                } else {
                    throw new SOAPProcessingException("multiple subcode Encountered in code element");
                }
            } else {
                throw new SOAPProcessingException(localName + " is not supported inside the code element");
            }
        } else if (parent.getLocalName().equals(SOAP12Constants.SOAP_FAULT_REASON_LOCAL_NAME)) {
            if (localName.equals(SOAP12Constants.SOAP_FAULT_TEXT_LOCAL_NAME)) {
                elementType = AxiomSOAP12FaultText.class;
                reasonProcessing = false;
            } else {
                throw new SOAPProcessingException(localName + " is not supported inside the reason");
            }
        } else if (parent.getLocalName().equals(SOAP12Constants.SOAP_FAULT_DETAIL_LOCAL_NAME)) {
            elementType = AxiomElement.class;
            processingDetailElements = true;
            detailElementNames = new Vector<String>();
            detailElementNames.add(localName);
        } else {
            throw new SOAPProcessingException(parent.getLocalName() + " should not have child element");
        }
    } else if (elementLevel > 5) {
        if (parent.getLocalName().equals(SOAP12Constants.SOAP_FAULT_SUB_CODE_LOCAL_NAME)) {
            if (localName.equals(SOAP12Constants.SOAP_FAULT_VALUE_LOCAL_NAME)) {
                if (subcodeValuePresent) {
                    throw new SOAPProcessingException("multiple subCode value encountered");
                } else {
                    elementType = AxiomSOAP12FaultValue.class;
                    subcodeValuePresent = true;
                    subSubcodePresent = false;
                    subCodeProcessing = false;
                }
            } else if (localName.equals(SOAP12Constants.SOAP_FAULT_SUB_CODE_LOCAL_NAME)) {
                if (subcodeValuePresent) {
                    if (!subSubcodePresent) {
                        elementType = AxiomSOAP12FaultSubCode.class;
                        subcodeValuePresent = false;
                        subSubcodePresent = true;
                        subCodeProcessing = true;
                    } else {
                        throw new SOAPProcessingException("multiple subcode encountered");
                    }
                } else {
                    throw new SOAPProcessingException("Value should present before the subcode");
                }
            } else {
                throw new SOAPProcessingException(localName + " is not supported inside the subCode element");
            }
        } else if (processingDetailElements) {
            int detailElementLevel = 0;
            boolean localNameExist = false;
            for (int i = 0; i < detailElementNames.size(); i++) {
                if (parent.getLocalName().equals(detailElementNames.get(i))) {
                    localNameExist = true;
                    detailElementLevel = i + 1;
                }
            }
            if (localNameExist) {
                detailElementNames.setSize(detailElementLevel);
                elementType = AxiomElement.class;
                detailElementNames.add(localName);
            }
        } else {
            throw new SOAPProcessingException(parent.getLocalName() + " should not have child at element level " + elementLevel);
        }
    }
    return elementType;
}
Also used : AxiomSOAP12FaultRole(org.apache.axiom.soap.impl.intf.AxiomSOAP12FaultRole) SOAPProcessingException(org.apache.axiom.soap.SOAPProcessingException) AxiomSOAP12FaultValue(org.apache.axiom.soap.impl.intf.AxiomSOAP12FaultValue) AxiomElement(org.apache.axiom.om.impl.intf.AxiomElement) AxiomSOAP12FaultSubCode(org.apache.axiom.soap.impl.intf.AxiomSOAP12FaultSubCode) AxiomSOAP12FaultReason(org.apache.axiom.soap.impl.intf.AxiomSOAP12FaultReason) Vector(java.util.Vector)

Aggregations

SOAPProcessingException (org.apache.axiom.soap.SOAPProcessingException)16 OMElement (org.apache.axiom.om.OMElement)8 SOAPFault (org.apache.axiom.soap.SOAPFault)4 SOAPHeaderBlock (org.apache.axiom.soap.SOAPHeaderBlock)4 SOAPEnvelope (org.apache.axiom.soap.SOAPEnvelope)3 QName (javax.xml.namespace.QName)2 AxiomElement (org.apache.axiom.om.impl.intf.AxiomElement)2 SOAPHeader (org.apache.axiom.soap.SOAPHeader)2 SOAPModelBuilder (org.apache.axiom.soap.SOAPModelBuilder)2 OutputStream (java.io.OutputStream)1 StringReader (java.io.StringReader)1 Vector (java.util.Vector)1 DataHandler (javax.activation.DataHandler)1 DataSource (javax.activation.DataSource)1 MimeBodyPart (javax.mail.internet.MimeBodyPart)1 MimeMessage (javax.mail.internet.MimeMessage)1 MimeMultipart (javax.mail.internet.MimeMultipart)1 XMLStreamReader (javax.xml.stream.XMLStreamReader)1 MemoryBlob (org.apache.axiom.blob.MemoryBlob)1 ContentType (org.apache.axiom.mime.ContentType)1