Search in sources :

Example 76 with SOAPEnvelope

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

the class TestGetTextWithCDATA method runTest.

@Override
protected void runTest() throws Throwable {
    String soap11Fault = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\">" + "<SOAP-ENV:Body>" + "<SOAP-ENV:Fault>" + "<faultcode>SOAP-ENV:Server</faultcode>" + "<faultstring xml:lang=\"en\"><![CDATA[handleMessage throws SOAPFaultException for ThrowsSOAPFaultToClientHandlersTest]]></faultstring>" + "<detail>" + "<somefaultentry/>" + "</detail>" + "<faultactor>faultActor</faultactor>" + "</SOAP-ENV:Fault>" + "</SOAP-ENV:Body>" + "</SOAP-ENV:Envelope>";
    XMLStreamReader soap11Parser = StAXUtils.createXMLStreamReader(TEST_PARSER_CONFIGURATION, new StringReader(soap11Fault));
    SOAPModelBuilder soap11Builder = OMXMLBuilderFactory.createStAXSOAPModelBuilder(metaFactory, soap11Parser);
    OMElement element = soap11Builder.getDocumentElement();
    element.build();
    assertTrue(element instanceof SOAPEnvelope);
    SOAPEnvelope se = (SOAPEnvelope) element;
    SOAPFault fault = se.getBody().getFault();
    SOAPFaultReason reason = fault.getReason();
    assertTrue(reason.getText().equals("handleMessage throws SOAPFaultException for ThrowsSOAPFaultToClientHandlersTest"));
    soap11Parser.close();
}
Also used : XMLStreamReader(javax.xml.stream.XMLStreamReader) SOAPFaultReason(org.apache.axiom.soap.SOAPFaultReason) StringReader(java.io.StringReader) OMElement(org.apache.axiom.om.OMElement) SOAPFault(org.apache.axiom.soap.SOAPFault) SOAPModelBuilder(org.apache.axiom.soap.SOAPModelBuilder) SOAPEnvelope(org.apache.axiom.soap.SOAPEnvelope)

Example 77 with SOAPEnvelope

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

the class TestAddHeaderBlockWithoutNamespace2 method runTest.

@Override
protected void runTest() throws Throwable {
    SOAPEnvelope envelope = soapFactory.createSOAPEnvelope();
    SOAPHeader header = soapFactory.createSOAPHeader(envelope);
    OMNamespace ns = soapFactory.createOMNamespace("", "");
    try {
        header.addHeaderBlock("test", ns);
        fail("Expected OMException");
    } catch (OMException ex) {
    // Expected
    }
}
Also used : OMNamespace(org.apache.axiom.om.OMNamespace) SOAPEnvelope(org.apache.axiom.soap.SOAPEnvelope) OMException(org.apache.axiom.om.OMException) SOAPHeader(org.apache.axiom.soap.SOAPHeader)

Example 78 with SOAPEnvelope

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

the class TestExamineAllHeaderBlocks 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);
    soapHeader.addHeaderBlock("echoOk2", namespace);
    Iterator<SOAPHeaderBlock> iterator = soapHeader.examineAllHeaderBlocks();
    iterator.hasNext();
    SOAPHeaderBlock headerBlock1 = iterator.next();
    assertNotNull("SOAP Header Test : - After calling addHeaderBlock method twice, examineAllHeaderBlocks method returns empty iterator", headerBlock1);
    assertEquals("SOAP Header Test : - HeaderBlock1 local name mismatch", "echoOk1", headerBlock1.getLocalName());
    assertEquals("SOAP Header Test : - HeaderBlock1 namespace uri mismatch", "http://www.example.org", headerBlock1.getNamespace().getNamespaceURI());
    assertTrue(iterator.hasNext());
    SOAPHeaderBlock headerBlock2 = iterator.next();
    assertNotNull("SOAP Header Test : - After calling addHeaderBlock method twice, examineAllHeaderBlocks method returns an iterator with only one object", headerBlock2);
    assertEquals("SOAP Header Test : - HeaderBlock2 local name mismatch", "echoOk2", headerBlock2.getLocalName());
    assertEquals("SOAP Header Test : - HeaderBlock2 namespace uri mismatch", "http://www.example.org", headerBlock2.getNamespace().getNamespaceURI());
    assertFalse("SOAP Header Test : - After calling addHeaderBlock method twice, examineAllHeaderBlocks method returns an iterator with more than two object", iterator.hasNext());
}
Also used : OMNamespace(org.apache.axiom.om.OMNamespace) SOAPHeaderBlock(org.apache.axiom.soap.SOAPHeaderBlock) SOAPEnvelope(org.apache.axiom.soap.SOAPEnvelope) SOAPHeader(org.apache.axiom.soap.SOAPHeader)

Example 79 with SOAPEnvelope

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

the class TestExamineHeaderBlocks method runTest.

@Override
protected void runTest() throws Throwable {
    String roleNextURI = spec.getNextRoleURI();
    SOAPEnvelope soapEnvelope = soapFactory.createSOAPEnvelope();
    SOAPHeader soapHeader = soapFactory.createSOAPHeader(soapEnvelope);
    OMNamespace namespace = soapFactory.createOMNamespace("http://www.example.org", "test");
    soapHeader.addHeaderBlock("echoOk1", namespace).setRole("urn:test-role");
    soapHeader.addHeaderBlock("echoOk2", namespace).setRole(roleNextURI);
    Iterator<SOAPHeaderBlock> iterator = soapHeader.examineHeaderBlocks(roleNextURI);
    iterator.hasNext();
    SOAPHeaderBlock headerBlockWithRole = iterator.next();
    assertEquals("SOAP Header Test : - headerBlockWithRole local name mismatch", "echoOk2", headerBlockWithRole.getLocalName());
    assertEquals("SOAP Header Test : - headerBlockWithRole role value mismatch", roleNextURI, headerBlockWithRole.getRole());
    assertFalse("SOAP Header Test : - header has one headerBlock with role, but examineHeaderBlocks(String role) method returns an iterator with more than one object", iterator.hasNext());
}
Also used : OMNamespace(org.apache.axiom.om.OMNamespace) SOAPHeaderBlock(org.apache.axiom.soap.SOAPHeaderBlock) SOAPEnvelope(org.apache.axiom.soap.SOAPEnvelope) SOAPHeader(org.apache.axiom.soap.SOAPHeader)

Example 80 with SOAPEnvelope

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

the class TestXPathAppliedToSOAPEnvelope method runTest.

@Override
protected void runTest() throws Throwable {
    OMElement elem1 = soapFactory.createOMElement("elem1", null);
    OMElement elem2 = soapFactory.createOMElement("elem2", null);
    OMElement elem3 = soapFactory.createOMElement("elem3", null);
    elem2.addChild(elem3);
    elem1.addChild(elem2);
    SOAPEnvelope envelope = soapFactory.getDefaultEnvelope();
    envelope.getBody().addChild(elem1);
    if (createDocument) {
        soapFactory.createOMDocument().addChild(envelope);
    }
    String XPathString = "//elem1";
    AXIOMXPath XPath = new AXIOMXPath(XPathString);
    OMNode node = (OMNode) XPath.selectSingleNode(envelope);
    assertNotNull(node);
}
Also used : OMNode(org.apache.axiom.om.OMNode) OMElement(org.apache.axiom.om.OMElement) SOAPEnvelope(org.apache.axiom.soap.SOAPEnvelope) AXIOMXPath(org.apache.axiom.om.xpath.AXIOMXPath)

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