Package org.apache.axiom.soap

Examples of org.apache.axiom.soap.SOAPFaultDetail


    protected void putExceptionToSOAPFault(Exception e) throws SOAPProcessingException {
        StringWriter sw = new StringWriter();
        e.printStackTrace(new PrintWriter(sw));
        sw.flush();
        SOAPFaultDetail detail = getDetail();
        if (getDetail() == null) {
            detail = getNewSOAPFaultDetail(this);
            setDetail(detail);
        }
        OMElement faultDetailEnty = new OMElementImpl(
View Full Code Here


        SOAPFaultRole faultRole = getRole();
        if (faultRole != null && faultRole.getText() != null && !"".equals(faultRole.getText())) {
            ((OMNodeEx) faultRole).internalSerialize(writer);
        }

        SOAPFaultDetail faultDetail = getDetail();
        if (faultDetail != null) {
            ((OMNodeEx) faultDetail).internalSerialize(writer);
        }

        OMSerializerUtil.serializeEndpart(writer);
View Full Code Here

                           SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI));
        assertTrue("SOAP 1.2 :- Role value mismatch",
                   role.getText().trim().equals("ultimateReceiver"));

        iteratorInFault.next();
        SOAPFaultDetail detail = (SOAPFaultDetail) iteratorInFault.next();
        assertTrue("SOAP 1.2 :- Fault detail local name mismatch",
                   detail.getLocalName().equals(
                           SOAP12Constants.SOAP_FAULT_DETAIL_LOCAL_NAME));
        assertTrue("SOAP 1.2 :- Fault detail namespace uri mismatch",
                   detail.getNamespace().getNamespaceURI().equals(
                           SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI));

        assertTrue("SOAP 1.2 :- Text in detail mismatch",
                   detail.getText().trim().equals("Details of error"));

        Iterator iteratorInDetail = detail.getChildren();

        iteratorInDetail.next();
        OMElement element1 = (OMElement) iteratorInDetail.next();
        assertTrue("SOAP 1.2 :- MaxTime element mismatch",
                   element1.getLocalName().equals("MaxTime"));
        assertTrue("SOAP 1.2 :- MaxTime element namespace mismatch",
                   element1.getNamespace().getNamespaceURI().equals(
                           "http:www.sample.org"));
        assertTrue("SOAP 1.2 :- Text value in MaxTime element mismatch",
                   element1.getText().trim().equals("P5M"));

        Iterator attributeIterator = element1.getAllAttributes();
        OMAttribute attributeInMaxTime = (OMAttribute) attributeIterator.next();
        assertTrue("SOAP 1.2 :- Attribute local name mismatch",
                   attributeInMaxTime.getLocalName().equals("detail"));
        assertTrue("SOAP 1.2 :- Attribute namespace mismatch",
                   attributeInMaxTime.getNamespace().getNamespaceURI().equals(
                           "http:www.sample.org"));
        assertTrue("SOAP 1.2 :- Attribute value mismatch",
                   attributeInMaxTime.getAttributeValue().trim().equals("This is only a test"));

        iteratorInDetail.next();
        OMElement element2 = (OMElement) iteratorInDetail.next();
        assertTrue("SOAP 1.2 :- AveTime element mismatch",
                   element2.getLocalName().equals("AveTime"));
        assertTrue("SOAP 1.2 :- AveTime element namespace mismatch",
                   element2.getNamespace().getNamespaceURI().equals(
                           "http:www.sample.org"));

        Iterator iteratorInAveTimeElement = element2.getChildren();

        iteratorInAveTimeElement.next();
        OMElement element21 = (OMElement) iteratorInAveTimeElement.next();
        assertTrue("SOAP 1.2 :- Time element mismatch",
                   element21.getLocalName().equals("Time"));
        assertTrue("SOAP 1.2 :- Time element namespace mismatch",
                   element21.getNamespace().getNamespaceURI().equals(
                           "http:www.sample.org"));
        assertTrue("SOAP 1.2 :- Text value in Time element mismatch",
                   element21.getText().trim().equals("P3M"));

        XMLStreamReader sopa11Parser = XMLInputFactory.newInstance()
                .createXMLStreamReader(new StringReader(soap11Message));
        OMXMLParserWrapper soap11Builder = new StAXSOAPModelBuilder(sopa11Parser, null);
        SOAPEnvelope soap11Envelope = (SOAPEnvelope) soap11Builder.getDocumentElement();
//            soap11Envelope.build();
//            writer = XMLOutputFactory.newInstance().createXMLStreamWriter(System.out);
//            soap11Envelope.internalSerializeAndConsume(writer);
//        writer.flush();

        assertTrue("SOAP 1.1 :- envelope local name mismatch",
                   soap11Envelope.getLocalName().equals(
                           SOAPConstants.SOAPENVELOPE_LOCAL_NAME));
        assertTrue("SOAP 1.1 :- envelope namespace uri mismatch",
                   soap11Envelope.getNamespace().getNamespaceURI().equals(
                           SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI));

        header = soap11Envelope.getHeader();
        assertTrue("SOAP 1.1 :- Header local name mismatch",
                   header.getLocalName().equals(
                           SOAPConstants.HEADER_LOCAL_NAME));
        assertTrue("SOAP 1.1 :- Header namespace uri mismatch",
                   header.getNamespace().getNamespaceURI().equals(
                           SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI));

        headerBlock = (SOAPHeaderBlock) header.getFirstElement();
        assertTrue("SOAP 1.1 :- Header block name mismatch",
                   headerBlock.getLocalName().equals("echoOk"));
        assertTrue("SOAP 1.1 :- Header block name space uri mismatch",
                   headerBlock.getNamespace().getNamespaceURI().equals(
                           "http://example.org/ts-tests"));
        assertTrue("SOAP 1.1 :- Headaer block text mismatch",
                   headerBlock.getText().trim().equals("foo"));

        // Attribute iteration is not in any guaranteed order.
        // Use QNames to get the OMAttributes.
        QName actorQName = new QName(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI,
                                     SOAP11Constants.ATTR_ACTOR);
        mustUnderstandQName = new QName(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI,
                                        SOAP11Constants.ATTR_MUSTUNDERSTAND);

        OMAttribute actorAttribute = headerBlock.getAttribute(actorQName);
        mustUnderstandAttribute = headerBlock.getAttribute(mustUnderstandQName);

        assertTrue("SOAP 1.1 :- Mustunderstand attribute not found",
                   mustUnderstandAttribute != null);
        assertTrue("SOAP 1.1 :- Mustunderstand value mismatch",
                   mustUnderstandAttribute.getAttributeValue().equals(
                           SOAPConstants.ATTR_MUSTUNDERSTAND_1));
        assertTrue(
                "SOAP 1.1 :- Mustunderstand attribute namespace uri mismatch",
                mustUnderstandAttribute.getNamespace().getNamespaceURI().equals(
                        SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI));

        assertTrue("SOAP 1.1 :- Actor attribute name not found",
                   actorAttribute != null);
        assertTrue("SOAP 1.1 :- Actor value mismatch",
                   actorAttribute.getAttributeValue().trim().equals(
                           "http://schemas.xmlsoap.org/soap/" +
                                   SOAP11Constants.ATTR_ACTOR +
                                   "/" +
                                   "next"));
        assertTrue("SOAP 1.1 :- Actor attribute namespace uri mismatch",
                   actorAttribute.getNamespace().getNamespaceURI().equals(
                           SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI));

        body = soap11Envelope.getBody();
        assertTrue("SOAP 1.1 :- Body local name mismatch",
                   body.getLocalName().equals(SOAPConstants.BODY_LOCAL_NAME));
        assertTrue("SOAP 1.1 :- Body namespace uri mismatch",
                   body.getNamespace().getNamespaceURI().equals(
                           SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI));

        fault = body.getFault();
        assertTrue("SOAP 1.1 :- Fault namespace uri mismatch",
                   fault.getNamespace().getNamespaceURI().equals(
                           SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI));

        iteratorInFault = fault.getChildren();

        iteratorInFault.next();
        code = (SOAPFaultCode) iteratorInFault.next();
        assertEquals("SOAP Fault code local name mismatch",
                     code.getLocalName(),
                     (SOAP11Constants.SOAP_FAULT_CODE_LOCAL_NAME));

        assertEquals("SOAP 1.1 :- Fault code value mismatch", code.getText().trim(),
                     "env:Sender");

        iteratorInFault.next();
        reason = (SOAPFaultReason) iteratorInFault.next();
        assertTrue("SOAP 1.1 :- Fault string local name mismatch",
                   reason.getLocalName().equals(
                           SOAP11Constants.SOAP_FAULT_STRING_LOCAL_NAME));
        assertTrue("SOAP 1.1 :- Fault string value mismatch",
                   reason.getText().trim().equals("Sender Timeout"));

        iteratorInFault.next();
        role = (SOAPFaultRole) iteratorInFault.next();
        assertTrue("SOAP 1.1 :- Fault actor local name mismatch",
                   role.getLocalName().equals(
                           SOAP11Constants.SOAP_FAULT_ACTOR_LOCAL_NAME));
        assertTrue("SOAP 1.1 :- Actor value mismatch",
                   role.getText().trim().equals(
                           "http://schemas.xmlsoap.org/soap/envelope/actor/ultimateReceiver"));

        iteratorInFault.next();
        detail = (SOAPFaultDetail) iteratorInFault.next();
        assertTrue("SOAP 1.1 :- Fault detail local name mismatch",
                   detail.getLocalName().equals(
                           SOAP11Constants.SOAP_FAULT_DETAIL_LOCAL_NAME));
        assertTrue("SOAP 1.2 :- Text in detail mismatch",
                   detail.getText().trim().equals("Details of error"));

        iteratorInDetail = detail.getChildren();

        iteratorInDetail.next();
        element1 = (OMElement) iteratorInDetail.next();
        assertTrue("SOAP 1.1 :- MaxTime element mismatch",
                   element1.getLocalName().equals("MaxTime"));
View Full Code Here

            if (fault == null) {
                throw new AxisFault("Problem");
            }

            SOAPFactory sf = ((SOAPFactory)envelope.getOMFactory());
            SOAPFaultDetail detail = null;

            if (msgContext.isSOAP11()) {
                SOAPHeader header = envelope.getHeader();
                OMElement element = header.getFirstChildWithName(Final.QNAME_WSA_HEADER_DETAIL);
                if (element != null) {
                    detail = sf.createSOAPFaultDetail(fault);
                    Iterator i = element.getChildElements();
                    while (i.hasNext()) {
                        OMElement detailElement = (OMElement)i.next();
                        detail.addDetailEntry(detailElement);
                    }
                }
            } else {
                detail = fault.getDetail();
            }

            String faultDetailString = null;
            if (detail != null) {
                OMElement element = detail.getFirstElement();
                if (element != null) {
                    faultDetailString = element.getText();
                }
            }
View Full Code Here

        try {
            OMElement omElement;

            if (messageContext.getFLOW() == MessageContext.OUT_FAULT_FLOW) {
                SOAPFault fault = messageContext.getEnvelope().getBody().getFault();
                SOAPFaultDetail soapFaultDetail = fault.getDetail();
                omElement = soapFaultDetail.getFirstElement();

                if (omElement == null) {
                    omElement = fault.getReason();
                }
View Full Code Here

        try {
            OMElement omElement = null;

            if (messageContext.getFLOW() == MessageContext.OUT_FAULT_FLOW) {
                SOAPFault fault = messageContext.getEnvelope().getBody().getFault();
                SOAPFaultDetail soapFaultDetail = fault.getDetail();
                if (soapFaultDetail != null) {
                    omElement = soapFaultDetail.getFirstElement();
                }
                if (omElement == null) {
                    omElement = fault.getReason();
                }
View Full Code Here

            throw new SOAPException("This SOAPFault already contains a Detail element. " +
                    "Please remove the existing Detail element before " +
                    "calling addDetail()");
        }

        SOAPFaultDetail omDetail;
        SOAPFactory factory = (SOAPFactory)this.element.getOMFactory();
        if (factory instanceof SOAP11Factory) {
            omDetail = new SOAP11FaultDetailImpl(this.fault,
                                                 factory);
        } else {
View Full Code Here

        int numDetailBlocks = getNumDetailBlocks();

        Block[] blocks = null;
        if (numDetailBlocks > 0) {
            blocks = new Block[numDetailBlocks];
            SOAPFaultDetail detail = root.getBody().getFault().getDetail();
            for (int i = 0; i < numDetailBlocks; i++) {
                OMElement om = this._getChildOMElement(detail, i);
                blocks[i] = this._getBlockFromOMElement(om, null, obf, false);

            }
View Full Code Here


    private static Block[] getDetailBlocks(SOAPFault soapFault) throws WebServiceException {
        try {
            Block[] blocks = null;
            SOAPFaultDetail detail = soapFault.getDetail();
            if (detail != null) {
                // Create a block for each element
                OMBlockFactory bf =
                        (OMBlockFactory)FactoryRegistry.getFactory(OMBlockFactory.class);
                ArrayList<Block> list = new ArrayList<Block>();
                Iterator it = detail.getChildElements();
                while (it.hasNext()) {
                    OMElement om = (OMElement)it.next();
                    Block b = bf.createFrom(om, null, om.getQName());
                    list.add(b);
                }
View Full Code Here

        }

        // Set the Detail and contents of Detail
        Block[] blocks = xmlFault.getDetailBlocks();
        if (blocks != null && blocks.length > 0) {
            SOAPFaultDetail detail = factory.createSOAPFaultDetail(soapFault);
            if (!ignoreDetailBlocks) {
                for (int i = 0; i < blocks.length; i++) {
                    // A Block implements OMDataSource.  So create OMSourcedElements
                    // for each of the Blocks.
                    OMSourcedElementImpl element =
                            new OMSourcedElementImpl(blocks[i].getQName(), factory, blocks[i]);
                    detail.addChild(element);
                }
            }
        }

        // Now set all of the secondary fault information
View Full Code Here

TOP

Related Classes of org.apache.axiom.soap.SOAPFaultDetail

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.