Package javax.xml.soap

Examples of javax.xml.soap.SOAPEnvelope


        } catch (SOAPException e) {
        }
    }

    public void testBody() throws Exception {
        SOAPEnvelope env = new org.apache.axis.message.SOAPEnvelope();
        SOAPBody b1 = env.getBody();
        assertTrue("null initial body", b1 != null);
        b1.detachNode();
        assertTrue("body not freed", env.getBody() == null);
        SOAPBody b2 = env.addBody();
        assertTrue("null created body", b2 != null);
        assertEquals("wrong body retrieved", b2, env.getBody());
        assertEquals("body parent incorrect", env,
                     (SOAPEnvelope)b2.getParentElement());
        try {
            env.addBody();
            assertTrue("second body added", false);
        } catch (SOAPException e) {
        }
    }
View Full Code Here


        try {
            MessageFactory mf = MessageFactory.newInstance();

            soapFault = mf.createMessage();

            SOAPEnvelope env =
            soapFault.getSOAPPart().getEnvelope();

            SOAPBody body = env.getBody();
            SOAPFault faultElement = body.addFault();

            String soapNs = env.getElementName().getPrefix();
            String fcode = soapNs + ":" + faultCode;

            faultElement.setFaultCode( fcode );

            faultElement.setFaultString( faultString );
View Full Code Here

             */
            SOAPPart soapPart = soapMessage.getSOAPPart();
            /**
             * Get SOAP envelope.
             */
            SOAPEnvelope soapEnvelope = soapPart.getEnvelope();

            /**
             * Get SOAP body.
             */
            SOAPBody soapBody = soapEnvelope.getBody();

            /**
             * Add child element with the specified name.
             */
            SOAPElement element = soapBody.addChildElement("HelloWorld");
View Full Code Here

     */
    public SOAPMessage generateResponseMessage(SOAPMessage soapMessage) {

        try {
            SOAPPart soapPart = soapMessage.getSOAPPart();
            SOAPEnvelope envelope = soapPart.getEnvelope();
            SOAPBody soapBody = envelope.getBody();

            soapBody.addChildElement("MessageStatus").addTextNode("published");
            soapMessage.saveChanges();
        } catch (SOAPException soape) {
            soape.printStackTrace();
View Full Code Here

         */
        SOAPPart soapPart = soapMessage.getSOAPPart();
        /**
         * Get SOAP envelope.
         */
        SOAPEnvelope soapEnvelope = soapPart.getEnvelope();

        /**
         * Get SOAP body.
         */
        SOAPBody soapBody = soapEnvelope.getBody();
        /**
         * Create a name object. with name space http://www.sun.com/imq.
         */
        Name name = soapEnvelope.createName("HelloWorld", "hw", "http://www.sun.com/imq");
        /**
         * Add child element with the above name.
         */
        SOAPElement element = soapBody.addChildElement(name);

View Full Code Here

        SOAPEnvelope envelope = message.getSOAPPart().getEnvelope();
        return envelope;
    }

    public void testAttributes() throws Exception {
        SOAPEnvelope envelope = getSOAPEnvelope();
        SOAPBody body = envelope.getBody();

        Name name1 = envelope.createName("MyAttr1");
        String value1 = "MyValue1";
        Name name2 = envelope.createName("MyAttr2");
        String value2 = "MyValue2";
        Name name3 = envelope.createName("MyAttr3");
        String value3 = "MyValue3";
        body.addAttribute(name1, value1);
        body.addAttribute(name2, value2);
        body.addAttribute(name3, value3);
        java.util.Iterator iterator = body.getAllAttributes();
View Full Code Here

        }
        assertTrue(foundName1 && foundName2 && foundName3);
    }

    public void testFaults() throws Exception {
        SOAPEnvelope envelope = getSOAPEnvelope();
        SOAPBody body = envelope.getBody();
        SOAPFault sf = body.addFault();
        sf.setFaultCode("myFault");
        String fc = sf.getFaultCode();
        assertTrue(fc.equals("myFault"));
    }
View Full Code Here

        String fc = sf.getFaultCode();
        assertTrue(fc.equals("myFault"));
    }

    public void testHeaderElements() throws Exception {
        SOAPEnvelope envelope = getSOAPEnvelope();
        SOAPBody body = envelope.getBody();
        SOAPHeader hdr = envelope.getHeader();

        SOAPHeaderElement she1 = hdr.addHeaderElement(envelope.createName("foo1", "f1", "foo1-URI"));
        she1.setActor("actor-URI");
        java.util.Iterator iterator = hdr.extractHeaderElements("actor-URI");
        int cnt = 0;
        while (iterator.hasNext()) {
            cnt++;
View Full Code Here

        iterator = hdr.extractHeaderElements("actor-URI");
        assertTrue(!iterator.hasNext());
    }

    public void testText1() throws Exception {
        SOAPEnvelope envelope = getSOAPEnvelope();
        Iterator iStart = envelope.getChildElements();
        int countStart = getIteratorCount(iStart);
        SOAPElement se = envelope.addTextNode("<txt>This is text</txt>");
        assertTrue(se != null);
        assertTrue(envelope.getValue().equals("<txt>This is text</txt>"));
        Iterator i = envelope.getChildElements();
        int count = getIteratorCount(i);
        assertTrue(count == countStart + 1);
    }
View Full Code Here

        int count = getIteratorCount(i);
        assertTrue(count == countStart + 1);
    }

    public void testText2() throws Exception {
        SOAPEnvelope envelope = getSOAPEnvelope();
      SOAPElement se = envelope.addTextNode("This is text");
      Iterator iterator = se.getChildElements();
      Node n = null;
      while (iterator.hasNext()) {
            n = (Node)iterator.next();
            if (n instanceof Text)
View Full Code Here

TOP

Related Classes of javax.xml.soap.SOAPEnvelope

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.