Package javax.xml.soap

Examples of javax.xml.soap.SOAPBody


    String getFaultString(MessageContext msgContext) {
      String stRetval = null;
      Message message = msgContext.getResponseMessage();
      try {
          if (message != null) {
            SOAPBody oBody  = message.getSOAPEnvelope().getBody();
            stRetval = oBody.getFault().getFaultString();
          }
      }
      catch (javax.xml.soap.SOAPException e) {
          assertTrue("Unforseen soap exception", false);
      }
View Full Code Here


    public void testSOAPEnvelope() throws Exception {
        // Create an example SOAP envelope
        SOAPEnvelope env = new org.apache.axis.message.SOAPEnvelope();
        SOAPHeader h = env.getHeader();
        SOAPBody b = env.getBody();
        Name heName = env.createName("localName", "prefix", "http://uri");
        SOAPHeaderElement he = h.addHeaderElement(heName);
        he.setActor("actor");

        // Serialize the SOAP envelope
View Full Code Here

        System.out.println(this + " handleMessage()");
        boolean outbound = (Boolean)ctx.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
        if (!outbound) {
            SOAPMessage message = ctx.getMessage();
            try {
                SOAPBody body = message.getSOAPBody();
                SOAPElement responseElem = CalculatorHandler.findElement(body, "multiply");
                if (responseElem != null) {
                    CalculatorHandler.verifyReferenceParameter(ctx);
                }
            } catch (SOAPException e) {
View Full Code Here

        SOAPHeader header = message.getSOAPHeader();
        SOAPElement action = TestUtils.findElement(header, "Action");
        Assert.assertNotNull(action);
        Assert.assertEquals(responseAction, action.getValue());
       
        SOAPBody body = message.getSOAPBody();
        SOAPElement responseElem = TestUtils.findElement(body, responseElement);
        Assert.assertNotNull(responseElem);
        SOAPElement returnElem = TestUtils.findElement(responseElem, "return");
        Assert.assertNotNull(returnElem);
        Assert.assertEquals(String.valueOf(result), returnElem.getValue());           
View Full Code Here

    @Test
    public void testLangAttributeOnSoap11FaultString() throws Exception {
        MessageFactory messageFactory = MessageFactory.newInstance(SOAPConstants.SOAP_1_1_PROTOCOL);
        SOAPMessage saajMessage = messageFactory.createMessage();

        SOAPBody saajSoapBody = saajMessage.getSOAPPart().getEnvelope().getBody();
        SaajSoap11Body soapBody = new SaajSoap11Body(saajSoapBody, true);

        soapBody.addClientOrSenderFault("Foo", Locale.ENGLISH);
        assertNotNull("No Language set", saajSoapBody.getFault().getFaultStringLocale());

        saajSoapBody = saajMessage.getSOAPPart().getEnvelope().getBody();
        soapBody = new SaajSoap11Body(saajSoapBody, false);

        soapBody.addClientOrSenderFault("Foo", Locale.ENGLISH);
        assertNull("Language set", saajSoapBody.getFault().getFaultStringLocale());
    }
View Full Code Here

        assertXMLEqual("Invalid source", "<child/>", result.toString());
    }

    @Test
    public void testGetPayloadSourceText() throws Exception {
        SOAPBody body = saajMessage.getSOAPPart().getEnvelope().getBody();
        body.addTextNode(" ");
        body.addChildElement("child");
        Source source = soapMessage.getPayloadSource();
        StringResult result = new StringResult();
        transformer.transform(source, result);
        assertXMLEqual("Invalid source", "<child/>", result.toString());
    }
View Full Code Here

    @Test
    public void testGetPayloadResult() throws Exception {
        StringSource source = new StringSource("<child/>");
        Result result = soapMessage.getPayloadResult();
        transformer.transform(source, result);
        SOAPBody body = saajMessage.getSOAPPart().getEnvelope().getBody();
        Iterator<?> iterator = body.getChildElements();
        assertTrue("No child nodes created", iterator.hasNext());
        SOAPBodyElement bodyElement = (SOAPBodyElement) iterator.next();
        assertEquals("Invalid child node created", "child", bodyElement.getElementName().getLocalName());
    }
View Full Code Here

        verify(strategyMock, connectionMock);
    }

    private SaajSoapMessage createDeleteMessage() throws SOAPException {
        SOAPMessage saajMessage = messageFactory.createMessage();
        SOAPBody saajBody = saajMessage.getSOAPBody();
        SOAPBodyElement delete = saajBody.addBodyElement(new QName("http://example.com/fabrikam", "Delete"));
        SOAPElement maxCount = delete.addChildElement(new QName("maxCount"));
        maxCount.setTextContent("42");
        return new SaajSoapMessage(saajMessage);
    }
View Full Code Here

            ex.printStackTrace();
        }
    }
   
    public SOAPMessage invoke(SOAPMessage request) {
        SOAPBody body = null;
        try {
            body = request.getSOAPBody();
        } catch (SOAPException e) {
            throw new RuntimeException("soap body expected");
        }
        if (body.getFirstChild() != null) {
            throw new RuntimeException("no body expected");
        }
        return sayHiResponse;
    }
View Full Code Here

        }
    }

    public SOAPMessage generateResponse(Operation op, EclipseLinkException ele) throws SOAPException {
        SOAPMessage message = messageFactory.createMessage();
        SOAPBody body = message.getSOAPPart().getEnvelope().getBody();
        body.addFault(new QName(URI_NS_SOAP_1_1_ENVELOPE, "Server"),
            op.getName() + " failed: " + ele.getMessage());
        return message;
    }
View Full Code Here

TOP

Related Classes of javax.xml.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.