Package org.apache.ws.commons.soap

Examples of org.apache.ws.commons.soap.SOAPProcessingException


     * @param fault
     * @param e
     */
    private void extractFaultInformationFromMessageContext(MessageContext context, SOAPFault fault,
                                                           Throwable e) {
        SOAPProcessingException soapException = null;
//        String soapNamespaceURI;
//
//        // get the current SOAP version
//        if (!context.isSOAP11()) {
//
//            // defaulting to SOAP 1.2
//            soapNamespaceURI = SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI;
//        } else {
//            soapNamespaceURI = SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI;
//        }

        if (e instanceof SOAPProcessingException) {
            soapException = (SOAPProcessingException) e;
        } else if (e instanceof AxisFault) {
            if (e.getCause() instanceof SOAPProcessingException) {
                soapException = (SOAPProcessingException) e.getCause();
            }
        } else {
            // we have recd an instance of just the Exception class
        }

        Object faultCode = context.getProperty(SOAP12Constants.SOAP_FAULT_CODE_LOCAL_NAME);
        String soapFaultCode = "";

        Throwable exception;
        if (faultCode != null) {
            fault.setCode((SOAPFaultCode) faultCode);
        } else if (soapException != null) {
            soapFaultCode = soapException.getFaultCode();
        } else
        if (((exception = e) instanceof AxisFault || (exception = e.getCause()) instanceof AxisFault))
        {
            QName faultCodeQName = ((AxisFault) exception).getFaultCode();
            if (faultCodeQName != null) {
                if (faultCodeQName.getLocalPart().indexOf(":") == -1) {
                    String prefix = faultCodeQName.getPrefix();
                    String uri = faultCodeQName.getNamespaceURI();
                    prefix = prefix == null || "".equals(prefix) ? Constants.AXIS2_NAMESPACE_PREFIX : prefix;
                    uri = uri == null || "".equals(uri) ? Constants.AXIS2_NAMESPACE_URI : uri;
                    soapFaultCode = prefix + ":" + faultCodeQName.getLocalPart();
                    fault.declareNamespace(uri, prefix);
                } else {
                    soapFaultCode = faultCodeQName.getLocalPart();
                }
            }
        }

        // defaulting to fault code Sender, if no message is available
        if (faultCode == null) {
            soapFaultCode = ("".equals(soapFaultCode) || (soapFaultCode == null))
                    ? getSenderFaultCode(context.getEnvelope().getNamespace())
                    : soapFaultCode;
            fault.getCode().getValue().setText(soapFaultCode);
        }

        Object faultReason = context.getProperty(SOAP12Constants.SOAP_FAULT_REASON_LOCAL_NAME);
        String message = "";

        if (faultReason != null) {
            fault.setReason((SOAPFaultReason) faultReason);
            message = fault.getReason().getSOAPText().getText();
        } else if (soapException != null) {
            message = soapException.getMessage();
        } else
        if (((exception = e) instanceof AxisFault || (exception = e.getCause()) instanceof AxisFault))
        {
            message = ((AxisFault) exception).getReason();
            message = message != null && "".equals(message) ? message : e.getMessage();
View Full Code Here


            while (token != XMLStreamReader.END_ELEMENT) {
                if (token == XMLStreamReader.CHARACTERS) {
                    OMText text = factory.createText(value, parser.getText());
                    value.addChild(text);
                } else {
                    throw new SOAPProcessingException(
                            "Only Characters are allowed here");
                }
                token = parser.next();
            }


        } catch (XMLStreamException e) {
            throw new SOAPProcessingException(e);
        }
    }
View Full Code Here

                          String localName,
                          boolean extractNamespaceFromParent,
                          SOAPFactory factory) throws SOAPProcessingException {
        super(localName, null, parent, factory);
        if (parent == null) {
            throw new SOAPProcessingException(
                    " Can not create " + localName +
                            " element without a parent !!");
        }
        checkParent(parent);
View Full Code Here

    }

    protected void checkParent(OMElement parent) throws SOAPProcessingException {
        if (!(parent instanceof SOAPEnvelopeImpl)) {
            throw new SOAPProcessingException(
                    "Expecting an implementation of SOAP Envelope as the parent. But received some other implementation");
        }
    }
View Full Code Here

        hasSOAPFault = true;
    }

    protected void checkParent(OMElement parent) throws SOAPProcessingException {
        if (!(parent instanceof SOAPEnvelopeImpl)) {
            throw new SOAPProcessingException(
                    "Expecting an implementation of SOAP Envelope as the parent. But received some other implementation");
        }
    }
View Full Code Here

                    "Expecting an implementation of SOAP Envelope as the parent. But received some other implementation");
        }
    }

    public OMNode detach() throws OMException {
        throw new SOAPProcessingException("Can not detach SOAP Body, SOAP Envelope must have a Body !!");
    }
View Full Code Here


    protected void checkParent(OMElement parent) throws SOAPProcessingException {
        if (!((parent instanceof SOAP11FaultSubCodeImpl) ||
                (parent instanceof SOAP11FaultCodeImpl))) {
            throw new SOAPProcessingException(
                    "Expecting SOAP 1.1 implementation of SOAP FaultSubCode or SOAP FaultCode as the parent. But received some other implementation." +
                            parent.getClass());
        }
    }
View Full Code Here

                factory);
    }

    protected void checkParent(OMElement parent) throws SOAPProcessingException {
        if (!((parent instanceof SOAP11FaultSubCodeImpl) ||  (parent instanceof SOAP11FaultCodeImpl))) {
            throw new SOAPProcessingException("Expecting SOAP 1.1 implementation of SOAP FaultSubCode or SOAP FaultCode as the parent. But received some other implementation");
        }
    }
View Full Code Here

        }
    }

    public void setSubCode(SOAPFaultSubCode subCode) throws SOAPProcessingException {
        if (!((parent instanceof SOAP11FaultSubCodeImpl) || (parent instanceof SOAP11FaultCodeImpl))) {
            throw new SOAPProcessingException("Expecting SOAP 1.1 implementation of SOAP Fault Sub Code. But received some other implementation");
        }
        super.setSubCode(subCode);
    }
View Full Code Here

        super.setSubCode(subCode);
    }

    public void setValue(SOAPFaultValue soapFaultSubCodeValue) throws SOAPProcessingException {
        if (!(soapFaultSubCodeValue instanceof SOAP11FaultValueImpl)) {
            throw new SOAPProcessingException("Expecting SOAP 1.1 implementation of SOAP Fault Value. But received some other implementation");
        }
        super.setValue(soapFaultSubCodeValue);
    }
View Full Code Here

TOP

Related Classes of org.apache.ws.commons.soap.SOAPProcessingException

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.