Package org.apache.axiom.om

Examples of org.apache.axiom.om.OMElement


  // gets a indication of the payload type. Default is XML
  // You cannot set the payload type. Instead, it is set automatically when
  // the payload is set
  public static int getPayloadType(SOAPEnvelope envelope) {
    OMElement el = getXMLPayload(envelope);
    if (el.getQName().equals(BINARYELT)) {
      return BINARYPAYLOADTYPE;
        } else if (el.getQName().equals(TEXTELT)) {
      return TEXTPAYLOADTYPE;
        } else if (el.getQName().equals(MAPELT)) {
      return MAPPAYLOADTYPE;
        } else {
      return XMLPAYLOADTYPE; // default XML
        }
  }
View Full Code Here


    SOAPBody body = envelope.getBody();
    if (body == null) {
      log.error("No body found");
      return null;
    }
    OMElement bodyEl = body.getFirstElement();
    if (bodyEl == null) {
      log.error("No body child found");
      return null;
    }
    return bodyEl;
View Full Code Here

    setXMLPayload(mc.getEnvelope(), element);
  }

  // Binary Payload is carried in a wrapper element with QName BINARYELT
  public static DataHandler getBinaryPayload(SOAPEnvelope envelope) {
    OMElement el = getXMLPayload(envelope);
    if (el == null)
      return null;
    if (!el.getQName().equals(BINARYELT)) {
      log.error("Wrong QName" + el.getQName());
      return null;
    }
    OMNode textNode = el.getFirstOMChild();
    if (textNode.getType() != OMNode.TEXT_NODE) {
      log.error("Text Node not found");
      return null;
    }
    OMText text = (OMText) textNode;
View Full Code Here

                in = content.getInputStream();
                dataSource = null;
            }
           
            try {
                OMElement documentElement;
                if (in != null) {
                    documentElement = builder.processDocument(in, contentType, msgContext);
                } else {
                    documentElement = ((DataSourceMessageBuilder)builder).processDocument(
                            dataSource, contentType, msgContext);
View Full Code Here

    return getBinaryPayload(mc.getEnvelope());
  }

  public static void setBinaryPayload(SOAPEnvelope envelope, DataHandler dh) {
    OMFactory fac = envelope.getOMFactory();
    OMElement binaryElt = envelope.getOMFactory()
        .createOMElement(BINARYELT);
    OMText text = fac.createOMText(dh, true);
    binaryElt.addChild(text);
    setXMLPayload(envelope, binaryElt);
  }
View Full Code Here

  }

  // Text payload is carried in a wrapper element with QName TEXTELT
  public static String getTextPayload(SOAPEnvelope envelope) {
    OMElement el = getXMLPayload(envelope);
    if (el == null)
      return null;
    if (!el.getQName().equals(TEXTELT)) {
      log.error("Wrong QName " + el.getQName());
      return null;
    }
    OMNode textNode = el.getFirstOMChild();
    if (textNode.getType() != OMNode.TEXT_NODE) {
      log.error("Text Node not found");
      return null;
    }
    OMText text = (OMText) textNode;
View Full Code Here

    return getTextPayload(mc.getEnvelope());
  }

  public static void setTextPayload(SOAPEnvelope envelope, String text) {
    OMFactory fac = envelope.getOMFactory();
    OMElement textElt = envelope.getOMFactory().createOMElement(TEXTELT);
    OMText textNode = fac.createOMText(text);
    textElt.addChild(textNode);
    setXMLPayload(envelope, textElt);
  }
View Full Code Here

  }

  // Map payload must be a Map of String->int, boolean, float, double, char,
  // short, byte, byte[], long, String
  public static SimpleMap getMapPayload(SOAPEnvelope envelope) {
    OMElement el = getXMLPayload(envelope);
    if (el == null)
      return null;
    if (!el.getQName().equals(MAPELT)) {
      log.error("Wrong QName" + el.getQName());
      return null;
    }
        return new SimpleMapImpl(el);
  }
View Full Code Here

  public static void setMapPayload(SOAPEnvelope envelope, SimpleMap map) {

    if (map instanceof SimpleMapImpl) {
      SimpleMapImpl impl = (SimpleMapImpl) map;
      OMElement mapElt = impl.getOMElement(envelope.getOMFactory());
      if (mapElt == null) {
        log.debug("null map element returned");
        return;
      }
      setXMLPayload(envelope, mapElt);
View Full Code Here

    setMapPayload(mc.getEnvelope(), map);
  }
 
  public static XMLStreamReader getStAXPayload(SOAPEnvelope envelope) {
    
    OMElement el = getXMLPayload(envelope);
    if (el==null) {
      return null;
    }
    return el.getXMLStreamReader();
  }
View Full Code Here

TOP

Related Classes of org.apache.axiom.om.OMElement

Copyright © 2015 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.