Search in sources :

Example 91 with SOAPEnvelope

use of org.apache.axiom.soap.SOAPEnvelope in project webservices-axiom by apache.

the class TestCommentInEpilog method runTest.

@Override
protected void runTest() throws Throwable {
    SOAPEnvelope envelope = OMXMLBuilderFactory.createSOAPModelBuilder(metaFactory, new StringReader(soapFactory.getDefaultEnvelope() + "<!--comment-->")).getSOAPEnvelope();
    OMNode sibling = envelope.getNextOMSibling();
    assertTrue(sibling instanceof OMComment);
}
Also used : OMNode(org.apache.axiom.om.OMNode) OMComment(org.apache.axiom.om.OMComment) StringReader(java.io.StringReader) SOAPEnvelope(org.apache.axiom.soap.SOAPEnvelope)

Example 92 with SOAPEnvelope

use of org.apache.axiom.soap.SOAPEnvelope in project webservices-axiom by apache.

the class TestGetFault method runTest.

@Override
protected void runTest() throws Throwable {
    SOAPEnvelope envelope = soapFactory.createSOAPEnvelope();
    SOAPBody body = soapFactory.createSOAPBody(envelope);
    assertNull("Body Test:- After creating a soap body it has a fault", body.getFault());
    body.addFault(new Exception("This an exception for testing"));
    assertNotNull("Body Test:- After calling addFault method, getFault method returns null", body.getFault());
}
Also used : SOAPBody(org.apache.axiom.soap.SOAPBody) SOAPEnvelope(org.apache.axiom.soap.SOAPEnvelope)

Example 93 with SOAPEnvelope

use of org.apache.axiom.soap.SOAPEnvelope in project webservices-axiom by apache.

the class TestGetFirstElementLocalNameEmptyBody method runTest.

@Override
protected void runTest() throws Throwable {
    SOAPEnvelope envelope = soapFactory.getDefaultEnvelope();
    assertNull(envelope.getBody().getFirstElementLocalName());
}
Also used : SOAPEnvelope(org.apache.axiom.soap.SOAPEnvelope)

Example 94 with SOAPEnvelope

use of org.apache.axiom.soap.SOAPEnvelope in project webservices-axiom by apache.

the class TestGetFirstElementLocalNameWithParserNoLookahead method runTest.

@Override
protected void runTest() throws Throwable {
    SOAPEnvelope orgEnvelope = soapFactory.getDefaultEnvelope();
    OMElement payload = soapFactory.createOMElement("payload", soapFactory.createOMNamespace("urn:test", "p"), orgEnvelope.getBody());
    OMElement child = soapFactory.createOMElement("child", null, payload);
    soapFactory.createOMElement("grandchild", null, child);
    SOAPModelBuilder builder = OMXMLBuilderFactory.createSOAPModelBuilder(metaFactory, new StringReader(orgEnvelope.toString()));
    SOAPBody body = builder.getSOAPEnvelope().getBody();
    body.getFirstElement().getFirstElement();
    assertThat(body.getFirstElementLocalName()).isEqualTo("payload");
}
Also used : SOAPBody(org.apache.axiom.soap.SOAPBody) StringReader(java.io.StringReader) OMElement(org.apache.axiom.om.OMElement) SOAPEnvelope(org.apache.axiom.soap.SOAPEnvelope) SOAPModelBuilder(org.apache.axiom.soap.SOAPModelBuilder)

Example 95 with SOAPEnvelope

use of org.apache.axiom.soap.SOAPEnvelope in project wso2-axis2-transports by wso2.

the class PlainTextFormatterTest method createMessageContext.

private MessageContext createMessageContext(String textPayload) throws AxisFault {
    MessageContext messageContext = new MessageContext();
    SOAPFactory factory = OMAbstractFactory.getSOAP11Factory();
    SOAPEnvelope envelope = factory.getDefaultEnvelope();
    OMElement textWrapper = factory.createOMElement(BaseConstants.DEFAULT_TEXT_WRAPPER);
    textWrapper.setText(textPayload);
    envelope.getBody().addChild(textWrapper);
    messageContext.setEnvelope(envelope);
    return messageContext;
}
Also used : OMElement(org.apache.axiom.om.OMElement) MessageContext(org.apache.axis2.context.MessageContext) SOAPEnvelope(org.apache.axiom.soap.SOAPEnvelope) SOAPFactory(org.apache.axiom.soap.SOAPFactory)

Aggregations

SOAPEnvelope (org.apache.axiom.soap.SOAPEnvelope)105 OMElement (org.apache.axiom.om.OMElement)32 SOAPBody (org.apache.axiom.soap.SOAPBody)24 OMNamespace (org.apache.axiom.om.OMNamespace)22 SOAPHeader (org.apache.axiom.soap.SOAPHeader)20 SOAPFactory (org.apache.axiom.soap.SOAPFactory)18 QName (javax.xml.namespace.QName)16 SOAPFault (org.apache.axiom.soap.SOAPFault)14 ByteArrayInputStream (java.io.ByteArrayInputStream)12 SOAPHeaderBlock (org.apache.axiom.soap.SOAPHeaderBlock)12 OMNode (org.apache.axiom.om.OMNode)11 SOAPModelBuilder (org.apache.axiom.soap.SOAPModelBuilder)11 MessageContext (org.apache.axis2.context.MessageContext)10 SOAPFaultCode (org.apache.axiom.soap.SOAPFaultCode)8 InputStream (java.io.InputStream)7 XMLStreamException (javax.xml.stream.XMLStreamException)7 ByteArrayOutputStream (java.io.ByteArrayOutputStream)6 StringReader (java.io.StringReader)6 DataHandler (javax.activation.DataHandler)6 OMException (org.apache.axiom.om.OMException)6