Package org.apache.axiom.soap

Examples of org.apache.axiom.soap.SOAPBody


    return getPayloadType(mc.getEnvelope());
  }

  // XML Payload is carried as the first (and only) child of the body
  public static OMElement getXMLPayload(SOAPEnvelope envelope) {
    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


    }
    return bodyEl;
  }

  public static void setXMLPayload(SOAPEnvelope envelope, OMElement element) {
    SOAPBody body = envelope.getBody();
    if (body == null) {

      SOAPVersion version = envelope.getVersion();
      if (version.getEnvelopeURI().equals(
          SOAP11Version.SOAP_ENVELOPE_NAMESPACE_URI)) {
        body = OMAbstractFactory.getSOAP11Factory().createSOAPBody();
      } else {
        body = OMAbstractFactory.getSOAP12Factory().createSOAPBody();
      }
      if (envelope.getHeader() != null) {
        envelope.getHeader().insertSiblingAfter(body);
      } else {
        envelope.addChild(body);
      }
    } else {
      for (Iterator it = body.getChildren(); it.hasNext();) {
        OMNode node = (OMNode) it.next();
        node.discard();
      }
    }
    body.addChild(element);
  }
View Full Code Here

               
                // TODO: don't know why this is here, but without it some unit tests fail...
                OMDocument omDoc = OMAbstractFactory.getSOAP11Factory().createOMDocument();
                omDoc.addChild(envelope);
               
                SOAPBody body = envelope.getBody();
                OMXMLParserWrapper builder = OMXMLBuilderFactory.createStAXOMBuilder(parser);
                OMElement bodyElement = builder.getDocumentElement();
                if (addTextAroundBody) {
                    OMFactory fac = OMAbstractFactory.getOMFactory();
                    body.addChild(fac.createOMText("\n"));
                    body.addChild(bodyElement);
                    body.addChild(fac.createOMText("\n"));
                } else {
                    body.addChild(bodyElement);
                }
            }
        } else {
            envelope = OMAbstractFactory.getSOAP11Factory().getDefaultEnvelope();
        }
View Full Code Here

     * @throws ScriptException For errors in converting xml To OM
     * @throws OMException     For errors in OM manipulation
     */

    public void setPayloadXML(Object payload) throws OMException, ScriptException {
        SOAPBody body = mc.getEnvelope().getBody();
        OMElement firstChild = body.getFirstElement();
        OMElement omElement = xmlHelper.toOMElement(payload);
        if (firstChild == null) {
            body.addChild(omElement);
        } else {
            firstChild.insertSiblingAfter(omElement);
            firstChild.detach();
        }
    }
View Full Code Here

               
                // TODO: don't know why this is here, but without it some unit tests fail...
                OMDocument omDoc = OMAbstractFactory.getSOAP11Factory().createOMDocument();
                omDoc.addChild(envelope);
               
                SOAPBody body = envelope.getBody();
                StAXOMBuilder builder = new StAXOMBuilder(parser);
                OMElement bodyElement = builder.getDocumentElement();
                if (addTextAroundBody) {
                    OMFactory fac = OMAbstractFactory.getOMFactory();
                    body.addChild(fac.createOMText("\n"));
                    body.addChild(bodyElement);
                    body.addChild(fac.createOMText("\n"));
                } else {
                    body.addChild(bodyElement);
                }
            }
        } else {
            envelope = OMAbstractFactory.getSOAP11Factory().getDefaultEnvelope();
        }
View Full Code Here

    return getPayloadType(mc.getEnvelope());
  }

  // XML Payload is carried as the first (and only) child of the body
  public static OMElement getXMLPayload(SOAPEnvelope envelope) {
    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

    }
    return bodyEl;
  }

  public static void setXMLPayload(SOAPEnvelope envelope, OMElement element) {
    SOAPBody body = envelope.getBody();
    if (body == null) {

      SOAPVersion version = envelope.getVersion();
      if (version.getEnvelopeURI().equals(
          SOAP11Version.SOAP_ENVELOPE_NAMESPACE_URI)) {
        body = OMAbstractFactory.getSOAP11Factory().createSOAPBody();
      } else {
        body = OMAbstractFactory.getSOAP12Factory().createSOAPBody();
      }
      if (envelope.getHeader() != null) {
        envelope.getHeader().insertSiblingAfter(body);
      } else {
        envelope.addChild(body);
      }
    } else {
      for (Iterator it = body.getChildren(); it.hasNext();) {
        OMNode node = (OMNode) it.next();
        node.discard();
      }
    }
    body.addChild(element);
  }
View Full Code Here

    }

    public void addBodyToMessageContext(MessageContext msgContext, OMElement element) throws AxisFault {
   
        SOAPEnvelope envelope = OMAbstractFactory.getSOAP11Factory().getDefaultEnvelope();
        SOAPBody body = envelope.getBody();
        body.addChild(element);
        msgContext.setEnvelope(envelope);
    }
View Full Code Here

    private static final Log log = LogFactory.getLog(POXUtils.class);

    public static void convertSOAPFaultToPOX(MessageContext msgCtx) {

        SOAPBody body = msgCtx.getEnvelope().getBody();
        SOAPFault fault = body.getFault();
        if (fault != null) {

            OMFactory fac = msgCtx.getEnvelope().getOMFactory();
            OMElement faultPayload = fac.createOMElement(new QName("Exception"));

            if (fault.getDetail() != null && !fault.getDetail().getText().equals("")) {

                String faultDetail = fault.getDetail().getText();

                if (log.isDebugEnabled()) {
                    log.debug("Setting the fault detail : " + faultDetail + " as athe POX Fault");
                }
                faultPayload.setText(faultDetail);

            } else if (fault.getReason() != null && !fault.getReason().getText().equals("")) {

                String faultReasonValue = fault.getReason().getText();

                if (log.isDebugEnabled()) {
                    log.debug("Setting the fault reason : "
                        + faultReasonValue + " as athe POX Fault");
                }
                faultPayload.setText(faultReasonValue);

            } else if (log.isDebugEnabled()) {
               
                log.debug("Couldn't find the fault detail or reason to compose POX Fault");
            }

            if (body.getFirstElement() != null) {
                body.getFirstElement().detach();
            }

            msgCtx.setProcessingFault(true);

            if (log.isDebugEnabled()) {

                String msg = "Original SOAP Message : " + msgCtx.getEnvelope().toString() +
                    "POXFault Message created : " + faultPayload.toString();
                log.debug(msg);
               
                if (log.isTraceEnabled()) {
                    log.trace(msg);
                }
            }

            body.addChild(faultPayload);
        }
    }
View Full Code Here

                        headerElem.getLocalName()).append(" : ").append(headerElem.getText());
                }
            }
        }

        SOAPBody soapBody = getEnvelope().getBody();
        if (soapBody != null) {
            sb.append(separator).append("Body : ").append(soapBody.toString());
        }

        return sb.toString();
    }  
View Full Code Here

TOP

Related Classes of org.apache.axiom.soap.SOAPBody

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.