Example usage for javax.xml.soap Name getURI

List of usage examples for javax.xml.soap Name getURI

Introduction

In this page you can find the example usage for javax.xml.soap Name getURI.

Prototype

String getURI();

Source Link

Document

Returns the URI of the namespace for the XML name that this Name object represents.

Usage

From source file:org.apache.axis.message.MessageElement.java

/**
 * Get the value of an attribute whose namespace and local name are described.
 * @param attrName qualified name of the attribute
 * @return the attribute or null if there was no match
 * @see SOAPElement#getAttributeValue(javax.xml.soap.Name)
 *//*from  w ww .  ja  v  a2 s. com*/
public String getAttributeValue(Name attrName) {
    return attributes.getValue(attrName.getURI(), attrName.getLocalName());
}

From source file:org.apache.axis.message.MessageElement.java

/**
 * remove an element//ww  w.j av a  2s.c  om
 * @param attrName name of the element
 * @return true if the attribute was found and removed.
 * @see javax.xml.soap.SOAPElement#removeAttribute(javax.xml.soap.Name)
 */
public boolean removeAttribute(Name attrName) {
    AttributesImpl attributes = makeAttributesEditable();
    boolean removed = false;

    for (int i = 0; i < attributes.getLength() && !removed; i++) {
        if (attributes.getURI(i).equals(attrName.getURI())
                && attributes.getLocalName(i).equals(attrName.getLocalName())) {
            attributes.removeAttribute(i);
            removed = true;
        }
    }
    return removed;
}

From source file:org.apache.axis.message.MessageElement.java

/**
 * get an iterator over child elements//from w  ww . j  a v a  2 s .  co  m
 * @param qname namespace/element name of parts to find.
 * This iterator is not (currently) susceptible to change in the element
 * list during its lifetime, though changes in the contents of the elements
 * are picked up.
 * @return an iterator.
 */
public Iterator getChildElements(QName qname) {
    initializeChildren();
    int num = children.size();
    Vector c = new Vector(num);
    for (int i = 0; i < num; i++) {
        MessageElement child = (MessageElement) children.get(i);
        Name cname = child.getElementName();
        if (cname.getURI().equals(qname.getNamespaceURI())
                && cname.getLocalName().equals(qname.getLocalPart())) {
            c.add(child);
        }
    }
    return c.iterator();
}

From source file:org.apache.axis.message.MessageElement.java

/**
 * get an iterator over child elements//from  ww w  .  j a va  2s.  c  o  m
 * @param childName namespace/element name of parts to find.
 * This iterator is not (currently) susceptible to change in the element
 * list during its lifetime, though changes in the contents of the elements
 * are picked up.
 * @return an iterator.
 * @see javax.xml.soap.SOAPElement#getChildElements(javax.xml.soap.Name)
 */
public Iterator getChildElements(Name childName) {
    return getChildElements(new QName(childName.getURI(), childName.getLocalName()));
}

From source file:org.apache.axis.message.SOAPBody.java

public javax.xml.soap.SOAPFault addFault(Name name, String s, Locale locale) throws SOAPException {
    AxisFault af = new AxisFault(new QName(name.getURI(), name.getLocalName()), s, "", new Element[0]);
    SOAPFault fault = new SOAPFault(af);
    addChildElement(fault);//w  ww. j  av  a2 s  . com
    return fault;
}

From source file:org.apache.axis.message.SOAPBody.java

public javax.xml.soap.SOAPFault addFault(Name name, String s) throws SOAPException {
    AxisFault af = new AxisFault(new QName(name.getURI(), name.getLocalName()), s, "", new Element[0]);
    SOAPFault fault = new SOAPFault(af);
    addChildElement(fault);/*from  w  w w  .j a  v  a  2 s.co  m*/
    return fault;
}

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

public QName getOperationElement() throws WebServiceException {
    try {//from ww  w . j  a v a  2 s.co m
        if (style != Style.RPC) {
            return null;
        }
        switch (contentType) {
        case OM:
            return ((org.apache.axiom.soap.SOAPEnvelope) content).getBody().getFirstElement().getQName();
        case SPINE:
            return ((XMLSpine) content).getOperationElement();
        case SOAPENVELOPE:
            Iterator it = ((SOAPEnvelope) content).getBody().getChildElements();
            while (it.hasNext()) {
                Node node = (Node) it.next();
                if (node instanceof SOAPElement) {
                    Name name = ((SOAPElement) node).getElementName();
                    return new QName(name.getURI(), name.getLocalName(), name.getPrefix());
                }
            }
        }
        return null;
    } catch (SOAPException se) {
        throw ExceptionFactory.makeWebServiceException(se);
    }
}

From source file:org.jbpm.bpel.integration.soap.SoapUtil.java

public static void copyAttributes(Element target, SOAPElement source) {
    // easy way out: no attributes to copy
    if (!source.hasAttributes())
        return;/*from  ww w . jav a2s.co  m*/
    // traverse attributes
    Iterator attrNameIt = source.getAllAttributes();
    while (attrNameIt.hasNext()) {
        Name attrName = (Name) attrNameIt.next();
        String namespaceURI = attrName.getURI();

        // isn't the attribute a namespace declaration?
        if (BpelConstants.NS_XMLNS.equals(namespaceURI))
            continue;

        // unqualified?
        if (namespaceURI == null || namespaceURI.length() == 0) {
            String localName = attrName.getLocalName();
            target.setAttribute(localName, source.getAttributeValue(attrName));
            if (traceEnabled)
                log.trace("set attribute: " + localName);
        }
        // qualified
        else {
            Attr attr = target.getOwnerDocument().createAttributeNS(namespaceURI, attrName.getQualifiedName());
            attr.setValue(source.getAttributeValue(attrName));
            target.setAttributeNodeNS(attr);
            XmlUtil.ensureNamespaceDeclared(attr, namespaceURI, attrName.getPrefix());
            if (traceEnabled)
                log.trace("set attribute: {" + namespaceURI + '}' + attrName.getQualifiedName());
        }
    }
}

From source file:org.springframework.ws.soap.saaj.support.SaajUtils.java

/**
 * Converts a <code>javax.xml.soap.Name</code> to a <code>javax.xml.namespace.QName</code>.
 *
 * @param name the <code>Name</code> to convert
 * @return the converted <code>QName</code>
 *//*w  w  w .  ja v a 2s  .  c o  m*/
public static QName toQName(Name name) {
    if (StringUtils.hasLength(name.getURI()) && StringUtils.hasLength(name.getPrefix())) {
        return QNameUtils.createQName(name.getURI(), name.getLocalName(), name.getPrefix());
    } else if (StringUtils.hasLength(name.getURI())) {
        return new QName(name.getURI(), name.getLocalName());
    } else {
        return new QName(name.getLocalName());
    }
}

From source file:xsul.dsig.globus.security.authentication.wssec.WSSecurityUtil.java

/**
 * Returns first WS-Security header for a given actor.
 * Only one WS-Security header is allowed for an actor.
 *///  w w w  . ja va 2s.  c o m
public static SOAPHeaderElement getSecurityHeader(SOAPEnvelope env, String actor) throws SOAPException {
    SOAPHeader header = env.getHeader();

    if (header == null) {
        return null;
    }

    Iterator headerElements = header.examineHeaderElements(actor);

    while (headerElements.hasNext()) {
        SOAPHeaderElement he = (SOAPHeaderElement) headerElements.next();
        Name nm = he.getElementName();

        // find ws-security header
        if (nm.getLocalName().equalsIgnoreCase(WSConstants.WS_SEC_LN)
                && nm.getURI().equalsIgnoreCase(WSConstants.WSSE_NS)) {
            return he;
        }
    }

    return null;
}