Package org.apache.axiom.soap

Examples of org.apache.axiom.soap.SOAPFault


        super(metaFactory, spec);
    }

    protected void runTest() throws Throwable {
        SOAPBody body = soapFactory.getDefaultEnvelope().getBody();
        SOAPFault fault = soapFactory.createSOAPFault(body, new Exception("Testing soap fault"));
        assertTrue("SOAP body has no SOAP fault", body.hasFault());
        assertSame("SOAP body has no SOAP fault", fault, body.getFault());
        assertTrue("Programatically created SOAPFault should have done = true",
                fault.isComplete());
    }
View Full Code Here


        return xmlFault;
    }

    private int getNumDetailBlocks() throws WebServiceException {
        if (isFault()) {
            SOAPFault fault = root.getBody().getFault();
            return _getNumChildElements(fault.getDetail());
        }
        return 0;
    }
View Full Code Here

            child.detach();
            child = body.getFirstOMChild();
        }

        // Add a SOAPFault to the body.
        SOAPFault soapFault = XMLFaultUtils.createSOAPFault(xmlFault, body, false);
    }
View Full Code Here

       
        StAXSOAPModelBuilder builder = new StAXSOAPModelBuilder(dummyEnv.getXMLStreamReaderWithoutCaching());
        SOAPEnvelope newEnv = (SOAPEnvelope) builder.getDocumentElement();
       
        SOAPBody body = newEnv.getBody();
        SOAPFault fault = body.getFault();
       
        Block[] details = getDetailBlocks(fault);
       
        return XMLFaultUtils.createXMLFault(fault, details);
    }
View Full Code Here

                                            SOAPBody body,
                                            boolean ignoreDetailBlocks) throws WebServiceException {

        // Get the factory and create the soapFault
        SOAPFactory factory = (SOAPFactory)body.getOMFactory();
        SOAPFault soapFault = factory.createSOAPFault(body);
        OMNamespace ns = body.getNamespace();

        // The SOAPFault structure is modeled after SOAP 1.2. 
        // Here is a sample comprehensive SOAP 1.2 fault which will help you understand the
        // structure.
        // <env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope"
        //               xmlns:m="http://www.example.org/timeouts"
        //               xmlns:xml="http://www.w3.org/XML/1998/namespace">
        //   <env:Body>
        //      <env:Fault>
        //        <env:Code>
        //          <env:Value>env:Sender</env:Value>
        //          <env:Subcode>
        //            <env:Value>m:MessageTimeout</env:Value>
        //          </env:Subcode>
        //        </env:Code>
        //        <env:Reason>
        //          <env:Text xml:lang="en">Sender Timeout</env:Text>
        //          <env:Text xml:lang="de">Sender Timeout</env:Text>
        //        </env:Reason>
        //        <env:Node>http://my.example.org/Node</env:Node>
        //        <env:Role>http://my.example.org/Role</env:Role>
        //        <env:Detail>
        //          <m:MaxTime>P5M</m:MaxTime>
        //        </env:Detail>   
        //      </env:Fault>
        //   </env:Body>
        // </env:Envelope>

        boolean isSoap11 = soapFault.getNamespace().getNamespaceURI()
                .equals(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);

        // Set the primary Code Value
        SOAPFaultCode soapCode = factory.createSOAPFaultCode(soapFault);
        QName soapValueQName = xmlFault.getCode().toQName(ns.getNamespaceURI());
        if (isSoap11) {
            soapCode.setText(soapValueQName);
        } else {
            SOAPFaultValue soapValue = factory.createSOAPFaultValue(soapCode);
            soapValue.setText(soapValueQName);
        }

        // Set the primary Reason Text
        SOAPFaultReason soapReason = factory.createSOAPFaultReason(soapFault);
        if (isSoap11) {
            soapReason.setText(xmlFault.getReason().getText());
        } else {
            SOAPFaultText soapText = factory.createSOAPFaultText(soapReason);
            soapText.setText(xmlFault.getReason().getText());
            soapText.setLang(xmlFault.getReason().getLang());
        }

        // 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.
                    OMSourcedElement element =
                            factory.createOMElement(blocks[i], blocks[i].getQName());
                    detail.addChild(element);
                }
            }
        }

        // Now set all of the secondary fault information
        // Set the SubCodes
        QName[] subCodes = xmlFault.getSubCodes();
        if (subCodes != null && subCodes.length > 0) {
            OMElement curr = soapCode;
            for (int i = 0; i < subCodes.length; i++) {
                SOAPFaultSubCode subCode = (i == 0) ?
                        factory.createSOAPFaultSubCode((SOAPFaultCode)curr) :
                        factory.createSOAPFaultSubCode((SOAPFaultSubCode)curr);
                SOAPFaultValue soapSubCodeValue = factory.createSOAPFaultValue(subCode);
                soapSubCodeValue.setText(subCodes[i]);
                curr = subCode;
            }
        }

        // Set the secondary reasons and languages
        XMLFaultReason reasons[] = xmlFault.getSecondaryReasons();
        if (reasons != null && reasons.length > 0) {
            for (int i = 0; i < reasons.length; i++) {
                SOAPFaultText soapReasonText = factory.createSOAPFaultText(soapReason);
                soapReasonText.setText(reasons[i].getText());
                soapReasonText.setLang(reasons[i].getLang());
            }
        }

        // Set the Role
        if (xmlFault.getRole() != null) {
            SOAPFaultRole soapRole = factory.createSOAPFaultRole();
            soapRole.setText(xmlFault.getRole());
            soapFault.setRole(soapRole);
        }

        // Set the Node
        if (xmlFault.getNode() != null) {
            SOAPFaultNode soapNode = factory.createSOAPFaultNode();
            soapNode.setText(xmlFault.getNode());
            soapFault.setNode(soapNode);
        }

        return soapFault;

    }
View Full Code Here

          SandeshaMessageKeys.soapEnvNotSet));

    SOAPFactory factory = SOAPAbstractFactory.getSOAPFactory(SandeshaUtil
        .getSOAPVersion(faultMsgEnvelope));

    SOAPFault fault = faultMsgEnvelope.getBody().getFault();
    SOAPFaultCode faultCode = fault.getCode();

    if (isSequenceFault(data)) {
      faultCode.setText(data.getCode());
    } else {
      faultCode.setText(data.getSubcode());
    }

    SOAPFaultReason faultReason = fault.getReason();

    OMNamespace namespace = factory.createOMNamespace(
        OMConstants.XMLNS_URI, OMConstants.XMLNS_PREFIX);

    faultReason.setText(data.getReason());
View Full Code Here

          SandeshaMessageKeys.soapEnvNotSet));

    SOAPFactory factory = SOAPAbstractFactory.getSOAPFactory(SandeshaUtil
        .getSOAPVersion(faultEnvelope));

    SOAPFault fault = faultEnvelope.getBody().getFault();
    if (fault == null)
      throw new SandeshaException(SandeshaMessageHelper.getMessage(
          SandeshaMessageKeys.noFaultCode,
          faultEnvelope.toString()));

    SOAPFaultCode faultCode = fault.getCode();
    SOAPFaultValue codeValue = faultCode.getValue();
    codeValue.setText(data.getCode());

    SOAPFaultSubCode faultSubCode = factory
        .createSOAPFaultSubCode(faultCode);
    SOAPFaultValue subCodeValue = factory
        .createSOAPFaultValue(faultSubCode);
    subCodeValue.setText(data.getSubcode());

    SOAPFaultReason faultReason = fault.getReason();
    SOAPFaultText faultText = faultReason.getSOAPFaultText("en");
   
    if (faultText==null) {
      faultText = factory.createSOAPFaultText();
      faultReason.addSOAPText(faultText);
    }
   
    if (data!=null && data.getReason()!=null)
      faultText.setText(data.getReason());

    SOAPFaultDetail faultDetail = fault.getDetail();

    OMElement detailElement = data.getDetail();

    if (detailElement != null)
      faultDetail.addChild(detailElement);
View Full Code Here

            }
        }
        SOAPEnvelope resenvelope = responseMessageContext.getEnvelope();
        if (resenvelope != null) {
            if (resenvelope.getBody().hasFault()) {
                SOAPFault soapFault = resenvelope.getBody().getFault();
                //we need to call engine.receiveFault
                engine = new AxisEngine(msgctx.getConfigurationContext());
                engine.receiveFault(responseMessageContext);
                if (options.isExceptionToBeThrownOnSOAPFault()) {
                    // does the SOAPFault has a detail element for Excpetion
                    throw new AxisFault(soapFault.getCode(), soapFault.getReason(),
                            soapFault.getNode(), soapFault.getRole(), soapFault.getDetail());
                }
            } else {
                engine = new AxisEngine(msgctx.getConfigurationContext());
                engine.receive(responseMessageContext);
                if (responseMessageContext.getReplyTo() != null) {
View Full Code Here

                }

                // if we have a SOAP Fault, log it - irrespective of the mediation logic
                // http://issues.apache.org/jira/browse/SYNAPSE-42
                if (synapseOutMessageContext.getEnvelope().getBody().hasFault()) {
                    SOAPFault fault = synapseOutMessageContext.getEnvelope().getBody().getFault();
                    log.warn("Synapse received a SOAP fault from : " + synapseInMessageContext.getTo() +
                        (fault.getNode() != null ? " Node : " + fault.getNode().getNodeValue() : "") +
                        (fault.getReason() != null ? " Reason : " + fault.getReason().getFirstSOAPText() : "") +
                        (fault.getCode() != null ? " Code : " + fault.getCode().getValue() : ""));
                }

                log.debug("Processing incoming message");

                // sets the out sequence if present to the out MC to mediate the response
View Full Code Here

        // invoke transformation, with static enveope
        MessageContext synCtx = TestUtils.getTestContext("<empty/>");
        faultMediator.mediate(synCtx);

        SOAPEnvelope envelope = synCtx.getEnvelope();
        SOAPFault fault = envelope.getBody().getFault();
        assertTrue(F_CODE.equals(fault.getCode().getValue().getTextAsQName()));
        assertTrue(F_STRING.equals(fault.getReason().getFirstSOAPText().getText()));
        assertTrue(F_ACTOR_URI.equals(fault.getRole().getRoleValue()));
        assertTrue(F_DETAIL.equals(fault.getDetail().getText()));
    }
View Full Code Here

TOP

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

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.