Java 8 SOAPBody - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 SOAPBody class.

This code example shows how to use the following methods:getChildElements, appendChild, getChildNodes, getOwnerDocument
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getFault
public class SaajSoap11BodyTest extends AbstractSoap11BodyTestCase { 
 
    @Override 
    protected SoapBody createSoapBody() throws Exception {
        MessageFactory messageFactory = MessageFactory.newInstance(SOAPConstants.SOAP_1_1_PROTOCOL);
        SOAPMessage saajMessage = messageFactory.createMessage();
        return new SaajSoap11Body(saajMessage.getSOAPPart().getEnvelope().getBody(), true);
    } 
 
    @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());
 

5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:addBodyElement
        SOAPBody body = request.getSOAPBody();
 
        // Compose the soap:Body payload 
        QName payloadName = new QName("http://apache.org/hello_world_soap_http/types", "greetMe", "ns1");
 
        SOAPBodyElement payload = body.addBodyElement(payloadName);
 
        SOAPElement message = payload.addChildElement("requestType");
 
        message.addTextNode("Hello Camel!!");
         
        System.out.println("Send out the request: Hello Camel!!");
 
        // Invoke the endpoint synchronously 
        // Invoke endpoint operation and read response 
        SOAPMessage reply = dispatch.invoke(request);
         
        // process the reply 
        body = reply.getSOAPBody();
         
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:addAttribute, getAttributeValue, removeAttribute
        SOAPMessage msg = MessageFactory.newInstance().createMessage();
        SOAPEnvelope envelope = msg.getSOAPPart().getEnvelope();
        SOAPBody body = envelope.getBody();
        Name name = envelope.createName("MyAttr1");
        String value = "MyValue1";
        body.addAttribute(name, value);
        boolean b = body.removeAttribute(name);
        assertTrue("removeAttribute() did not return true", b);
        b = body.removeAttribute(name);
        assertFalse("removeAttribute() did not return false", b);
        assertNull(body.getAttributeValue(name));
    } 
 
    @Validated @Test
    public void testRemoveAttribute2() throws Exception {
        SOAPMessage msg = MessageFactory.newInstance().createMessage();
        SOAPEnvelope envelope = msg.getSOAPPart().getEnvelope();
        SOAPBody body = envelope.getBody();
 
        QName name = new QName("MyAttr1");
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getFirstChild
        try { 
            body = SAAJUtils.getBody(request);
        } catch (SOAPException e) {
            throw new RuntimeException("soap body expected");
        } 
        if (body.getFirstChild() != null) {
            throw new RuntimeException("no body expected");
        } 
        return sayHiResponse;
    } 
} 
4
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:addFault
    public void testCustomRoleNodeFault12() throws Exception {
        MessageFactory mf = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);
        SOAPMessage sm = mf.createMessage();
        SOAPBody body = sm.getSOAPBody();
         
        SOAPFault fault = body.addFault();
        fault.setFaultRole("TestRole");
        fault.setFaultNode("http://XMLFaultTest/testCustomRoleNodeFault/");
         
        XMLFault xmlFault = XMLFaultUtils.createXMLFault(fault);
         
        SOAPFault retFault = XMLFaultUtils.createSAAJFault(xmlFault, body);
         
        assertTrue(retFault != null);
         
        String role = retFault.getFaultRole();
        assertTrue(role != null);
        assertTrue(role.equals("TestRole"));
         
        // Actor and role should be the same 
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getChildElements, getChildNodes
This code example shows how to use the following methods:getFirstChild
    private SOAPElement assertRequestXML(SOAPMessage msg) throws Exception {
        assertTrue(msg != null);
        SOAPBody body = msg.getSOAPBody();
        assertTrue(body != null);
         
        Node invokeElement = (Node) body.getFirstChild();
        assertTrue(invokeElement instanceof SOAPElement);
        assertTrue(SoapMessageProvider.REQUEST_NAME.equals(invokeElement.getLocalName()));
         
        Node discElement = (Node) invokeElement.getFirstChild();
        assertTrue(discElement instanceof SOAPElement);
        assertTrue(SoapMessageProvider.REQUEST_DATA_NAME.equals(discElement.getLocalName()));
         
        String text = discElement.getValue();
        assertTrue(text != null);
        assertTrue(text.length() > 0);
        System.out.println("Request Message Type is:" + text);
         
        return (SOAPElement) discElement;
    } 
3
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:addBodyElement
        // Echo back 
        logger.debug("envelopeTest Called");
        SOAPBody body = resp.getBody();
        Name ns0 = resp.createName("TestNS0", "ns0", "http://example.com");
        Name ns1 = resp.createName("TestNS1", "ns1", "http://example.com");
        SOAPElement bodyElmnt = body.addBodyElement(ns0);
        SOAPElement el = bodyElmnt.addChildElement(ns1);
        el.addTextNode("TEST RESPONSE");
    } 
} 
4
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getFirstChild
    private SOAPElement assertRequestXML(SOAPMessage msg) throws Exception {
        assertTrue(msg != null);
        SOAPBody body = msg.getSOAPBody();
        assertTrue(body != null);
         
        Node invokeElement = (Node) body.getFirstChild();
        assertTrue(invokeElement instanceof SOAPElement);
        assertTrue(SoapMessageProvider.REQUEST_NAME.equals(invokeElement.getLocalName()));
         
        Node discElement = (Node) invokeElement.getFirstChild();
        assertTrue(discElement instanceof SOAPElement);
        assertTrue(SoapMessageProvider.REQUEST_DATA_NAME.equals(discElement.getLocalName()));
         
        String text = discElement.getValue();
        assertTrue(text != null);
        assertTrue(text.length() > 0);
        TestLogger.logger.debug("Request Message Type is:" + text);
         
        return (SOAPElement) discElement;
    } 
3
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
See Code Examples for Java 8 SOAPBody Methods: