Example usage for javax.xml.soap SOAPHeaderElement getActor

List of usage examples for javax.xml.soap SOAPHeaderElement getActor

Introduction

In this page you can find the example usage for javax.xml.soap SOAPHeaderElement getActor.

Prototype

public String getActor();

Source Link

Document

Returns the uri of the actor attribute of this SOAPHeaderElement .

Usage

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

public Iterator examineMustUnderstandHeaderElements(String actor) {
    if (actor == null)
        return null;

    Vector result = new Vector();
    List headers = getChildren();
    if (headers != null) {
        for (int i = 0; i < headers.size(); i++) {
            SOAPHeaderElement she = (SOAPHeaderElement) headers.get(i);
            if (she.getMustUnderstand()) {
                String candidate = she.getActor();
                if (actor.equals(candidate)) {
                    result.add(headers.get(i));
                }// w  ww  . j  a va  2s.  c o m
            }
        }
    }
    return result.iterator();
}

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

/**
 * Get all the headers targeted at a list of actors.
 *//*from  w w  w. j ava2s.c  o m*/
Vector getHeadersByActor(ArrayList actors) {
    Vector results = new Vector();
    List headers = getChildren();
    if (headers == null) {
        return results;
    }
    Iterator i = headers.iterator();
    SOAPConstants soapVer = getEnvelope().getSOAPConstants();
    boolean isSOAP12 = soapVer == SOAPConstants.SOAP12_CONSTANTS;
    String nextActor = soapVer.getNextRoleURI();
    while (i.hasNext()) {
        SOAPHeaderElement header = (SOAPHeaderElement) i.next();
        String actor = header.getActor();

        // Skip it if we're SOAP 1.2 and it's the "none" role.
        if (isSOAP12 && Constants.URI_SOAP12_NONE_ROLE.equals(actor)) {
            continue;
        }

        // Always process NEXT's, and then anything else in our list
        // For now, also always process ultimateReceiver role if SOAP 1.2
        if (actor == null || nextActor.equals(actor)
                || (isSOAP12 && Constants.URI_SOAP12_ULTIMATE_ROLE.equals(actor))
                || (actors != null && actors.contains(actor))) {
            results.add(header);
        }
    }
    return results;
}

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

/**
 * Get a header by name, filtering for headers targeted at this
 * engine depending on the accessAllHeaders parameter.
 *//*from  w  w w .j  a  va 2s.  c  o m*/
SOAPHeaderElement getHeaderByName(String namespace, String localPart, boolean accessAllHeaders) {
    QName name = new QName(namespace, localPart);
    SOAPHeaderElement header = (SOAPHeaderElement) getChildElement(name);

    // If we're operating within an AxisEngine, respect its actor list
    // unless told otherwise
    if (!accessAllHeaders) {
        MessageContext mc = MessageContext.getCurrentContext();
        if (mc != null) {
            if (header != null) {
                String actor = header.getActor();

                // Always respect "next" role
                String nextActor = getEnvelope().getSOAPConstants().getNextRoleURI();
                if (nextActor.equals(actor))
                    return header;

                SOAPService soapService = mc.getService();
                if (soapService != null) {
                    ArrayList actors = mc.getService().getActors();
                    if ((actor != null) && (actors == null || !actors.contains(actor))) {
                        header = null;
                    }
                }
            }
        }
    }

    return header;
}

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

/**
 * Return an Enumeration of headers which match the given namespace
 * and localPart.  Depending on the value of the accessAllHeaders
 * parameter, we will attempt to filter on the current engine's list
 * of actors.//from   w ww  .j av a 2 s.c o m
 * 
 * !!! NOTE THAT RIGHT NOW WE ALWAYS ASSUME WE'RE THE "ULTIMATE
 * DESTINATION" (i.e. we match on null actor).  IF WE WANT TO FULLY SUPPORT
 * INTERMEDIARIES WE'LL NEED TO FIX THIS.
 */
Enumeration getHeadersByName(String namespace, String localPart, boolean accessAllHeaders) {
    ArrayList actors = null;
    boolean firstTime = false;

    /** This might be optimizable by creating a custom Enumeration
     * which moves through the headers list (parsing on demand, again),
     * returning only the next one each time.... this is Q&D for now.
     */
    Vector v = new Vector();
    List headers = getChildren();
    if (headers == null) {
        return v.elements();
    }
    Iterator e = headers.iterator();
    SOAPHeaderElement header;
    String nextActor = getEnvelope().getSOAPConstants().getNextRoleURI();

    while (e.hasNext()) {
        header = (SOAPHeaderElement) e.next();
        if (header.getNamespaceURI().equals(namespace) && header.getName().equals(localPart)) {

            if (!accessAllHeaders) {
                if (firstTime) {
                    // Do one-time setup
                    MessageContext mc = MessageContext.getCurrentContext();
                    if (mc != null && mc.getAxisEngine() != null) {
                        actors = mc.getAxisEngine().getActorURIs();
                    }
                    firstTime = false;
                }

                String actor = header.getActor();
                if ((actor != null) && !nextActor.equals(actor)
                        && (actors == null || !actors.contains(actor))) {
                    continue;
                }
            }

            v.addElement(header);
        }
    }

    return v.elements();
}