Package javax.xml.soap

Examples of javax.xml.soap.SOAPBodyElement


    @Validated @Test
    public void testAddRemoveTextNode() throws Exception {
        MessageFactory mf = MessageFactory.newInstance();
        SOAPMessage msg = mf.createMessage();
        SOAPBody body = msg.getSOAPBody();
        SOAPBodyElement bodyChild = body.addBodyElement(new QName("TestChild"));
        bodyChild.addTextNode("aaaaa");
        bodyChild.removeChild(bodyChild.getFirstChild());
    }
View Full Code Here


            // required part of the message as per the SOAP 1.1 spec.
            SOAPPart sp = msg.getSOAPPart();
            SOAPEnvelope envelope = sp.getEnvelope();
            SOAPHeader hdr = envelope.getHeader();
            SOAPBody bdy = envelope.getBody();
            SOAPBodyElement sbe1 = bdy.addBodyElement(
                    envelope.createName("Body1", NS_PREFIX, NS_URI));
            sbe1.addChildElement(envelope.createName(
                    "TheGifAttachment", NS_PREFIX, NS_URI));
            sbe1.setAttribute("href", "cid:THEGIF");
            SOAPBodyElement sbe2 = bdy.addBodyElement(
                    envelope.createName("Body2", NS_PREFIX, NS_URI));
            sbe2.addChildElement(envelope.createName(
                    "TheXmlAttachment", NS_PREFIX, NS_URI));
            sbe2.setAttribute("href", "cid:THEXML");

            URL url1 = new URL("http://localhost:8080/SOAPMessage/attach.xml");
            URL url2 = new URL("http://localhost:8080/SOAPMessage/attach.gif");
            URL url3 = new URL("http://localhost:8080/SOAPMessage/attach.txt");
            URL url4 = new URL("http://localhost:8080/SOAPMessage/attach.html");
View Full Code Here

            SOAPPart sp = msg.getSOAPPart();
            SOAPEnvelope envelope = sp.getEnvelope();
            SOAPHeader hdr = envelope.getHeader();

            SOAPBody bdy = envelope.getBody();
            SOAPBodyElement sbe1 = bdy.addBodyElement(
                    envelope.createName("Body1", NS_PREFIX, NS_URI));
            sbe1.addChildElement(envelope.createName(
                    "TheGifAttachment", NS_PREFIX, NS_URI));

            SOAPBodyElement sbe2 = bdy.addBodyElement(
                    envelope.createName("Body2", NS_PREFIX, NS_URI));

            sbe2.addChildElement(envelope.createName(
                    "TheXmlAttachment", NS_PREFIX, NS_URI));

            URL url1 = new URL("http://localhost:8080/SOAPMessage/attach.xml");
            URL url2 = new URL("http://localhost:8080/SOAPMessage/attach.gif");
            URL url3 = new URL("http://localhost:8080/SOAPMessage/attach.txt");
            URL url4 = new URL("http://localhost:8080/SOAPMessage/attach.html");
            URL url5 = new URL("http://localhost:8080/SOAPMessage/attach.jpeg");

            // Set href on body elements using Content-Location headers and relative URI's
            sbe1.setAttribute("href", url2.toString());
            sbe2.setAttribute("href", url1.toString());

            AttachmentPart ap1 = msg.createAttachmentPart(new DataHandler(url1));
            AttachmentPart ap2 = msg.createAttachmentPart(new DataHandler(url2));
            AttachmentPart ap3 = msg.createAttachmentPart(new DataHandler(url3));
            AttachmentPart ap4 = msg.createAttachmentPart(new DataHandler(url4));
View Full Code Here

                    envelope.createName("Header4", NS_PREFIX, NS_URI))
                    .addTextNode("This is Header4");
            she = (SOAPHeaderElement)se;
            she.setMustUnderstand(false);

            SOAPBodyElement sbe = bdy.addBodyElement(
                    envelope.createName("Body1", NS_PREFIX, NS_URI));

            sbe.addChildElement(envelope.createName(
                    "Child1", NS_PREFIX, NS_URI)).addTextNode("This is Child1");
            sbe.addChildElement(envelope.createName(
                    "Child2", NS_PREFIX, NS_URI)).addTextNode("This is Child2");


            URL url1 = new URL("http://localhost:8080/SOAPMessage/attach.xml");
            AttachmentPart ap = msg.createAttachmentPart(new DataHandler(url1));
View Full Code Here

            boolean foundChild1 = false;
            boolean foundChild2 = false;
            SOAPBody bdy = envelope.getBody();
            i = bdy.getChildElements();
            while (i.hasNext()) {
                SOAPBodyElement sbe = (SOAPBodyElement)i.next();
                Name name = sbe.getElementName();
                if (name.getLocalName().equals("Body1"))
                    foundBody1 = true;
                Iterator c = sbe.getChildElements();
                while (c.hasNext()) {
                    SOAPElement se = (SOAPElement)c.next();
                    name = se.getElementName();
                    String value = se.getValue();
                    if (value.equals("This is Child1")
View Full Code Here

                        SOAPFaultImpl saajSOAPFault = new SOAPFaultImpl(fault);
                        ((NodeImpl)omSOAPBody.getFault())
                                .setUserData(SAAJ_NODE, saajSOAPFault, null);
                        childElements.add(saajSOAPFault);
                    } else {
                        SOAPBodyElement saajBodyEle = new SOAPBodyElementImpl((ElementImpl)domNode);
                        ((NodeImpl)domNode).setUserData(SAAJ_NODE, saajBodyEle, null);
                        childElements.add(saajBodyEle);
                    }
                }
            } else {
View Full Code Here

                                                                   AddressingConstants.REFPROP_QNAME_ACTION ) );
      SOAPHeaderElement resourceIdHeader =
         soapHeader.addHeaderElement( NameUtils.toName( MuseAddressingConstants.REFERENCE_PROP_QNAME_RESOURCE_ID ) );
      SaajUtils.addTextNode( resourceIdHeader, m_resourceId );
      SOAPBody        soapBody    = soapRequestMsg.getSOAPPart(  ).getEnvelope(  ).getBody(  );
      SOAPBodyElement requestElem =
         soapBody.addBodyElement( SOAPFactory.newInstance(  ).createName( "GetResourcePropertyRequest",
                                                                          ResourceProperties11Constants.NSPREFIX_WSRP,
                                                                          ResourceProperties11Constants.NSURI_WSRP ) );
      requestElem.addNamespaceDeclaration( propQName.getPrefix(  ),
                                           propQName.getNamespaceURI(  ) );
      SaajUtils.addTextNode( requestElem, propQName.getPrefix(  ) + ":" + propQName.getLocalPart(  ) );
      SOAPConnection soapConn        = SOAPConnectionFactory.newInstance(  ).createConnection(  );
      SOAPMessage    soapResponseMsg = soapConn.call( soapRequestMsg,
                                                      m_endpointRef.getAddress(  ).toString(  ) );
View Full Code Here

        SOAPMessage resultedMessage = message.getContent(SOAPMessage.class);
        assertNotNull(resultedMessage);
        SOAPBody bodyNew = resultedMessage.getSOAPBody();
        Iterator itNew = bodyNew.getChildElements(new QName("http://apache.org/hello_world_rpclit",
                                                            "sendReceiveDataResponse"));
        SOAPBodyElement bodyElementNew = (SOAPBodyElement)itNew.next();
        Iterator outIt = bodyElementNew
            .getChildElements(new QName("http://apache.org/hello_world_rpclit/types", "out"));
        Element outElement = (SOAPElement)outIt.next();
        assertNotNull(outElement);       
        Element elem3Element =
            DOMUtils.findAllElementsByTagNameNS(outElement,
View Full Code Here

        // Verify SOAPMessage
        SOAPMessage soapMessageNew = message.getContent(SOAPMessage.class);
        SOAPBody bodyNew = soapMessageNew.getSOAPBody();
        Iterator itNew = bodyNew.getChildElements();
        SOAPBodyElement bodyElementNew = (SOAPBodyElement)itNew.next();
        assertEquals("sendReceiveData", bodyElementNew.getLocalName());

        // Verify the XMLStreamReader
        XMLStreamReader xmlReader = message.getContent(XMLStreamReader.class);
        QName qn = xmlReader.getName();
        assertEquals("sendReceiveData", qn.getLocalPart());
View Full Code Here

            SOAPHeader header = message.getSOAPHeader();
            header.detachNode();
           
            SOAPBody body = message.getSOAPBody();
            QName bodyName = new QName("http://www.lokasoft.nl/message/", "ProbePosition", "m");
            SOAPBodyElement bodyElement = body.addBodyElement(bodyName);
            QName name = new QName("fen");
            SOAPElement fenElement = bodyElement.addChildElement(name);
            fenElement.addTextNode(fen);
           
            URL endpoint = new URL("http://www.lokasoft.nl/tbweb/tbapi.asp");
            SOAPMessage response = connection.call(message, endpoint);
           
            connection.close();
           
            body = response.getSOAPBody();
           
            Iterator it = body.getChildElements();
            bodyElement = (SOAPBodyElement)it.next();
            it = bodyElement.getChildElements();
           
            bodyElement = (SOAPBodyElement)it.next();
            String value = bodyElement.getValue();
           
            return toInt(value);
           
        } catch(SOAPException | MalformedURLException e) {
            Main.LOG.log(Level.SEVERE, "Cannot retrieve SOAP response", e);
View Full Code Here

TOP

Related Classes of javax.xml.soap.SOAPBodyElement

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.