Example usage for javax.xml.soap SOAPEnvelope getNamespaceURI

List of usage examples for javax.xml.soap SOAPEnvelope getNamespaceURI

Introduction

In this page you can find the example usage for javax.xml.soap SOAPEnvelope getNamespaceURI.

Prototype

public String getNamespaceURI();

Source Link

Document

The namespace URI of this node, or null if it is unspecified (see ).

Usage

From source file:org.apache.axis2.jaxws.message.impl.XMLPartBase.java

/**
 * XMLPart should be constructed via the XMLPartFactory. This constructor creates an XMLPart from
 * the specified root.//from  w w w . j a  v  a2 s. c o m
 *
 * @param root
 * @throws WebServiceException
 */
XMLPartBase(SOAPEnvelope root) throws WebServiceException {
    content = root;
    contentType = SOAPENVELOPE;
    String ns = root.getNamespaceURI();
    if (ns.equals(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI)) {
        protocol = Protocol.soap11;
    } else if (ns.equals(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI)) {
        protocol = Protocol.soap12;
    } else {
        throw ExceptionFactory.makeWebServiceException(Messages.getMessage("RESTIsNotSupported"));
    }
}

From source file:org.apache.axis2.jaxws.message.util.impl.SAAJConverterImpl.java

private void _fixFaultElements(SOAPEnvelope env) {
    try {//from w  w  w.  j a  va 2s  .c  om
        // If we have a SOAP 1.2 envelope, then there's nothing to do.
        if (env.getNamespaceURI().equals(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI)) {
            return;
        }

        SOAPBody body = env.getBody();
        if (body != null && !body.hasFault()) {
            if (log.isDebugEnabled()) {
                log.debug("No fault found.  No conversion necessary.");
            }
            return;
        } else if (body != null && body.hasFault()) {
            if (log.isDebugEnabled()) {
                log.debug("A fault was found.  Converting the fault child elements to SOAP 1.1 format");
            }

            SOAPFault fault = body.getFault();

            Iterator itr = fault.getChildElements();
            while (itr.hasNext()) {
                SOAPElement se = (SOAPElement) itr.next();
                if (se.getLocalName().equals(SOAP12Constants.SOAP_FAULT_CODE_LOCAL_NAME)) {
                    if (log.isDebugEnabled()) {
                        log.debug("Converting: faultcode");
                    }
                    // Axis2 SAAJ stores the acutal faultcode text under a SOAPFaultValue object, so we have to 
                    // get that and add it as a text node under the original element.
                    Node value = se.getFirstChild();
                    if (value != null && value instanceof org.apache.axis2.saaj.SOAPElementImpl) {
                        org.apache.axis2.saaj.SOAPElementImpl valueElement = (org.apache.axis2.saaj.SOAPElementImpl) value;
                        ElementImpl e = valueElement.getElement();
                        String content = e.getText();

                        SOAPElement child = fault.addChildElement(
                                new QName(se.getNamespaceURI(), SOAP11Constants.SOAP_FAULT_CODE_LOCAL_NAME));
                        child.addTextNode(content);

                        se.detachNode();
                    }
                } else if (se.getLocalName().equals(SOAP12Constants.SOAP_FAULT_DETAIL_LOCAL_NAME)) {
                    if (log.isDebugEnabled()) {
                        log.debug("Converting: detail");
                    }
                    se.setElementQName(
                            new QName(se.getNamespaceURI(), SOAP11Constants.SOAP_FAULT_DETAIL_LOCAL_NAME));
                } else if (se.getLocalName().equals(SOAP12Constants.SOAP_FAULT_REASON_LOCAL_NAME)) {
                    if (log.isDebugEnabled()) {
                        log.debug("Converting: faultstring");
                    }
                    se.setElementQName(
                            new QName(se.getNamespaceURI(), SOAP11Constants.SOAP_FAULT_STRING_LOCAL_NAME));
                    // Axis2 SAAJ stores the acutal faultstring text under a SOAPFaultValue object, so we have to 
                    // get that and add it as a text node under the original element.
                    Node value = se.getFirstChild();
                    if (value != null && value instanceof org.apache.axis2.saaj.SOAPElementImpl) {
                        org.apache.axis2.saaj.SOAPElementImpl valueElement = (org.apache.axis2.saaj.SOAPElementImpl) value;
                        ElementImpl e = valueElement.getElement();
                        String content = e.getText();

                        SOAPElement child = fault.addChildElement(
                                new QName(se.getNamespaceURI(), SOAP11Constants.SOAP_FAULT_STRING_LOCAL_NAME));
                        child.addTextNode(content);

                        se.detachNode();
                    }
                }
            }
        }
    } catch (SOAPException e) {
        if (log.isDebugEnabled()) {
            log.debug("An error occured while converting fault elements: " + e.getMessage());
        }
        throw ExceptionFactory.makeWebServiceException(e);
    }
}