Package javax.xml.soap

Examples of javax.xml.soap.SOAPEnvelope


     * @see #SAAJ_12
     * @see #SAAJ_13
     */
    public static int getSaajVersion(SOAPMessage soapMessage) throws SOAPException {
        Assert.notNull(soapMessage, "'soapMessage' must not be null");
        SOAPEnvelope soapEnvelope = soapMessage.getSOAPPart().getEnvelope();
        return getSaajVersion(soapEnvelope);
    }
View Full Code Here


     * @throws SOAPException            if conversion is unsuccessful
     * @throws IllegalArgumentException if {@code qName} is not fully qualified
     */
    public static Name toName(QName qName, SOAPElement resolveElement) throws SOAPException {
      String qNamePrefix = qName.getPrefix();
        SOAPEnvelope envelope = getEnvelope(resolveElement);
        if (StringUtils.hasLength(qName.getNamespaceURI()) && StringUtils.hasLength(qNamePrefix)) {
            return envelope.createName(qName.getLocalPart(), qNamePrefix, qName.getNamespaceURI());
        }
        else if (StringUtils.hasLength(qName.getNamespaceURI())) {
            Iterator<?> prefixes;
            if (getSaajVersion(resolveElement) == SAAJ_11) {
                prefixes = resolveElement.getNamespacePrefixes();
            }
            else {
                prefixes = resolveElement.getVisibleNamespacePrefixes();
            }
            while (prefixes.hasNext()) {
                String prefix = (String) prefixes.next();
                if (qName.getNamespaceURI().equals(resolveElement.getNamespaceURI(prefix))) {
                    return envelope.createName(qName.getLocalPart(), prefix, qName.getNamespaceURI());
                }
            }
            return envelope.createName(qName.getLocalPart(), "", qName.getNamespaceURI());
        }
        else {
            return envelope.createName(qName.getLocalPart());
        }
    }
View Full Code Here

            javax.xml.soap.MessageFactory.newInstance();
        final SOAPMessage soapMessage = messageFactory.createMessage();

        // Object for message parts
        final SOAPPart soapPart = soapMessage.getSOAPPart();
        final SOAPEnvelope envelope = soapPart.getEnvelope();

        envelope.addNamespaceDeclaration("xsd",
            "http://www.w3.org/2001/XMLSchema");
        envelope.addNamespaceDeclaration("xsd",
            "http://basic.beans.data.app.openmeetings.org/xsd");
        envelope.addNamespaceDeclaration("xsd",
            "http://basic.beans.persistence.app.openmeetings.org/xsd");
        envelope.addNamespaceDeclaration("xsi",
            "http://www.w3.org/2001/XMLSchema-instance");
        envelope.addNamespaceDeclaration("enc",
            "http://schemas.xmlsoap.org/soap/encoding/");
        envelope.addNamespaceDeclaration("env",
            "http://schemas.xmlsoap.org/soap/envelop/");

        envelope.addNamespaceDeclaration(NAMESPACE_PREFIX,
            "http://services.axis.openmeetings.org");
        envelope.addNamespaceDeclaration("rooms",
            "http://rooms.beans.persistence.app.openmeetings.org/xsd");

        envelope.setEncodingStyle("http://schemas.xmlsoap.org/soap/encoding/");

        return soapMessage;
    }
View Full Code Here

   private SOAPMessage buildSOAPMessage( Document              fullMsgBodyElem,
                                         EndpointReferenceType consumerEPR )
   throws Exception
   {
      SOAPMessage  msg      = MessageFactory.newInstance(  ).createMessage(  );
      SOAPEnvelope envelope = msg.getSOAPPart(  ).getEnvelope(  );
      SOAPBody     body     = envelope.getBody(  );
      body.addDocument( fullMsgBodyElem );
      SOAPHeader header = msg.getSOAPHeader(  );
      addWSAHeaders( header, consumerEPR );
      return msg;
   }
View Full Code Here

      if (log.isDebugEnabled()) {
          log.debug("Converting OM SOAPEnvelope to SAAJ SOAPEnvelope");
          log.debug("The conversion occurs due to " + JavaUtils.stackToString());
      }
     
        SOAPEnvelope soapEnvelope = null;
        try {
            // Build the default envelope
            OMNamespace ns = omEnvelope.getNamespace();
            MessageFactory mf = createMessageFactory(ns.getNamespaceURI());
            SOAPMessage sm = mf.createMessage();
            SOAPPart sp = sm.getSOAPPart();
            soapEnvelope = sp.getEnvelope();

            // The getSOAPEnvelope() call creates a default SOAPEnvelope with a SOAPHeader and SOAPBody.
            // The SOAPHeader and SOAPBody are removed (they will be added back in if they are present in the
            // OMEnvelope).
            SOAPBody soapBody = soapEnvelope.getBody();
            if (soapBody != null) {
                soapBody.detachNode();
            }
            SOAPHeader soapHeader = soapEnvelope.getHeader();
            if (soapHeader != null) {
                soapHeader.detachNode();
            }

            // We don't know if there is a real OM tree or just a backing XMLStreamReader.
View Full Code Here

        if (log.isDebugEnabled()) {
            log.debug("checkSOAPMessageInfo with " + JavaUtils.getObjectIdentity(sm));
        }
        // Check SOAPPart and SOAPEnvelope identity
        SOAPPart currentSoapPart = null;
        SOAPEnvelope currentSoapEnvelope = null;
       
        try {
            currentSoapPart = sm.getSOAPPart();
            if (currentSoapPart != null) {
                currentSoapEnvelope = cachedSoapPart.getEnvelope();
View Full Code Here

        }
       
        Element documentElement = null;
        try {
            SOAPMessage saajDoc = message.getContent(SOAPMessage.class);
            SOAPEnvelope envelope = saajDoc.getSOAPPart().getEnvelope();
            if (!checkFaults && envelope.getBody().hasFault()) {
                return;
            }
            documentElement = envelope;
        } catch (SOAPException e) {
            throw new SoapFault("Error obtaining SOAP document", Fault.FAULT_CODE_CLIENT);
View Full Code Here

    public int saveMsgWithAttachments(String filename) throws Exception {
        MessageFactory mf = MessageFactory.newInstance();
        SOAPMessage msg = mf.createMessage();

        SOAPPart sp = msg.getSOAPPart();
        SOAPEnvelope envelope = sp.getEnvelope();
        SOAPHeader header = envelope.getHeader();
        SOAPBody body = envelope.getBody();

        SOAPElement el = header.addHeaderElement(envelope.createName("field4", NS_PREFIX, NS_URI));
        SOAPElement el2 = el.addChildElement("field4b", NS_PREFIX);
        SOAPElement el3 = el2.addTextNode("field4value");

        el = body.addBodyElement(envelope.createName("bodyfield3", NS_PREFIX, NS_URI));
        el2 = el.addChildElement("bodyfield3a", NS_PREFIX);
        el2.addTextNode("bodyvalue3a");
        el2 = el.addChildElement("bodyfield3b", NS_PREFIX);
        el2.addTextNode("bodyvalue3b");
        el2 = el.addChildElement("datefield", NS_PREFIX);
View Full Code Here

    }

    // Test JAXM methods...

    public void testName() throws Exception {
        SOAPEnvelope env = new org.apache.axis.message.SOAPEnvelope();
        Name n = env.createName("local", "pref", "urn:blah");
        assertEquals("local part of name did not match", "local",
                     n.getLocalName());
        assertEquals("qname of name did not match", "pref:local",
                     n.getQualifiedName());
        assertEquals("prefix of name did not match", "pref",
                     n.getPrefix());
        assertEquals("uri of name did not match", "urn:blah",
                     n.getURI());
        Name n2 = env.createName("loc");
        assertEquals("local part of name2 did not match", "loc",
                     n2.getLocalName());
    }
View Full Code Here

        assertEquals("local part of name2 did not match", "loc",
                     n2.getLocalName());
    }

    public void testHeader() throws Exception {
        SOAPEnvelope env = new org.apache.axis.message.SOAPEnvelope();
        SOAPHeader h1 = env.getHeader();
        assertTrue("null initial header", h1 != null);
        h1.detachNode();
        assertTrue("header not freed", env.getHeader() == null);
        SOAPHeader h2 = env.addHeader();
        assertTrue("null created header", h2 != null);
        assertEquals("wrong header retrieved", h2, env.getHeader());
        assertEquals("header parent incorrect", env,
                     (SOAPEnvelope)h2.getParentElement());
        try {
            env.addHeader();
            assertTrue("second header added", false);
        } catch (SOAPException e) {
        }
    }
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.