Search in sources :

Example 26 with SOAPEnvelope

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

the class TestClone method runTest.

@Override
protected void runTest() throws Throwable {
    SOAPMessage message = soapFactory.createSOAPMessage();
    message.addChild(soapFactory.getDefaultEnvelope());
    OMCloneOptions options = new OMCloneOptions();
    options.setPreserveModel(preserveModel);
    OMInformationItem clone = message.clone(options);
    if (preserveModel) {
        assertTrue(clone instanceof SOAPMessage);
    } else {
        assertTrue(clone instanceof OMDocument);
        assertFalse(clone instanceof SOAPMessage);
    }
    OMElement envelope = ((OMDocument) clone).getOMDocumentElement();
    if (preserveModel) {
        assertTrue(envelope instanceof SOAPEnvelope);
    } else {
        assertFalse(envelope instanceof SOAPEnvelope);
    }
    assertEquals("Envelope", envelope.getLocalName());
    assertEquals(spec.getEnvelopeNamespaceURI(), envelope.getNamespaceURI());
}
Also used : OMInformationItem(org.apache.axiom.om.OMInformationItem) OMCloneOptions(org.apache.axiom.om.OMCloneOptions) OMElement(org.apache.axiom.om.OMElement) SOAPEnvelope(org.apache.axiom.soap.SOAPEnvelope) SOAPMessage(org.apache.axiom.soap.SOAPMessage) OMDocument(org.apache.axiom.om.OMDocument)

Example 27 with SOAPEnvelope

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

the class TestGetCharsetEncodingWithParser method runTest.

@Override
protected void runTest() throws Throwable {
    String encoding = "iso-8859-15";
    SOAPEnvelope orgEnvelope = soapFactory.getDefaultEnvelope();
    soapFactory.createOMElement("echo", soapFactory.createOMNamespace("urn:test", null)).setText("test");
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    OMOutputFormat format = new OMOutputFormat();
    format.setCharSetEncoding(encoding);
    orgEnvelope.serialize(baos, format);
    SOAPMessage message = OMXMLBuilderFactory.createSOAPModelBuilder(metaFactory, new ByteArrayInputStream(baos.toByteArray()), encoding).getSOAPMessage();
    assertEquals(encoding, message.getCharsetEncoding());
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) SOAPEnvelope(org.apache.axiom.soap.SOAPEnvelope) ByteArrayOutputStream(java.io.ByteArrayOutputStream) OMOutputFormat(org.apache.axiom.om.OMOutputFormat) SOAPMessage(org.apache.axiom.soap.SOAPMessage)

Example 28 with SOAPEnvelope

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

the class TestExamineMustUnderstandHeaderBlocks method runTest.

@Override
protected void runTest() throws Throwable {
    SOAPEnvelope soapEnvelope = soapFactory.createSOAPEnvelope();
    SOAPHeader soapHeader = soapFactory.createSOAPHeader(soapEnvelope);
    OMNamespace namespace = soapFactory.createOMNamespace("http://www.example.org", "test");
    soapHeader.addHeaderBlock("echoOk1", namespace).setRole("http://www.w3.org/2003/05/soap-envelope/role/ultimateReceiver");
    SOAPHeaderBlock headerBlock1 = soapHeader.addHeaderBlock("echoOk2", namespace);
    headerBlock1.setRole("http://www.w3.org/2003/05/soap-envelope/role/ultimateReceiver");
    headerBlock1.setMustUnderstand(true);
    soapHeader.addHeaderBlock("echoOk3", namespace).setMustUnderstand(true);
    Iterator iterator = soapHeader.examineMustUnderstandHeaderBlocks("http://www.w3.org/2003/05/soap-envelope/role/ultimateReceiver");
    iterator.hasNext();
    SOAPHeaderBlock headerBlock = (SOAPHeaderBlock) iterator.next();
    assertFalse("SOAP Header Test : - examineMustUnderstandHeaderBlocks method returns empty iterator", headerBlock == null);
    assertTrue("SOAP Header Test : - HeaderBlock local name mismatch", headerBlock.getLocalName().equals("echoOk2"));
    assertTrue("SOAP Header Test : - HeaderBlock role value mismatch", headerBlock.getRole().equals("http://www.w3.org/2003/05/soap-envelope/role/ultimateReceiver"));
    assertFalse("SOAP Header Test : - examineMustUnderstandHeaderBlocks method returns an iterator with more than one object", iterator.hasNext());
}
Also used : OMNamespace(org.apache.axiom.om.OMNamespace) Iterator(java.util.Iterator) SOAPHeaderBlock(org.apache.axiom.soap.SOAPHeaderBlock) SOAPEnvelope(org.apache.axiom.soap.SOAPEnvelope) SOAPHeader(org.apache.axiom.soap.SOAPHeader)

Example 29 with SOAPEnvelope

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

the class TestGetValue method runTest.

@Override
protected void runTest() throws Throwable {
    SOAPEnvelope env = soapFactory.getDefaultEnvelope();
    SOAPFault fault = soapFactory.createSOAPFault(env.getBody());
    SOAPFaultCode code = soapFactory.createSOAPFaultCode(fault);
    code.setText(new QName("urn:test", "test"));
    assertNull(code.getValue());
}
Also used : SOAPFaultCode(org.apache.axiom.soap.SOAPFaultCode) QName(javax.xml.namespace.QName) SOAPFault(org.apache.axiom.soap.SOAPFault) SOAPEnvelope(org.apache.axiom.soap.SOAPEnvelope)

Example 30 with SOAPEnvelope

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

the class TestMoreChildrenAddition method runTest.

@Override
protected void runTest() throws Throwable {
    SOAPEnvelope envelope = soapFactory.getDefaultFaultEnvelope();
    SOAPEnvelope soapEnvelope = soapFactory.getDefaultFaultEnvelope();
    String errorCodeString = "Some Error occurred !!";
    soapEnvelope.getBody().getFault().getCode().getValue().setText(errorCodeString);
    SOAPFaultCode code = soapEnvelope.getBody().getFault().getCode();
    envelope.getBody().getFault().setCode(code);
    assertTrue("Parent Value of Code has not been set to new fault", code.getParent() == envelope.getBody().getFault());
    assertTrue("Parent Value of Code is still pointing to old fault", code.getParent() != soapEnvelope.getBody().getFault());
    assertNull("Old fault must not have a fault code", soapEnvelope.getBody().getFault().getCode());
    assertEquals("The SOAP Code value must be " + errorCodeString, errorCodeString, envelope.getBody().getFault().getCode().getValue().getText());
}
Also used : SOAPFaultCode(org.apache.axiom.soap.SOAPFaultCode) SOAPEnvelope(org.apache.axiom.soap.SOAPEnvelope)

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