Example usage for javax.xml.soap SOAPConstants URI_NS_SOAP_ENVELOPE

List of usage examples for javax.xml.soap SOAPConstants URI_NS_SOAP_ENVELOPE

Introduction

In this page you can find the example usage for javax.xml.soap SOAPConstants URI_NS_SOAP_ENVELOPE.

Prototype

String URI_NS_SOAP_ENVELOPE

To view the source code for javax.xml.soap SOAPConstants URI_NS_SOAP_ENVELOPE.

Click Source Link

Document

The namespace identifier for the SOAP 1.1 envelope, All SOAPElements in this namespace are defined by the SOAP 1.1 specification.

Usage

From source file:org.jbpm.bpel.integration.soap.SoapUtilTest.java

public void testCopyVisibleNamespaces_domSoap_targetMatch() throws Exception {
    String xml = "<soap:Envelope xmlns:soap='" + SOAPConstants.URI_NS_SOAP_ENVELOPE + "'>"
            + " <soap:Body xmlns:produce='urn:example:produce'>"
            + "  <meal:lunch produce:lettuce='0.1lb' fish:fillet='0.25lb' "
            + "   xmlns:fish='urn:example:fish' xmlns:meal='urn:example:meal'/>" + " </soap:Body>"
            + "</soap:Envelope>";
    SOAPMessage soapMessage = parseSoap(xml);
    SOAPElement source = SoapUtil.getElement(soapMessage.getSOAPBody(), "urn:example:meal", "lunch");

    String targetXml = "<detail xmlns:produce='urn:example:produce'>"
            + " <other:target xmlns:other='urn:example:other'/>" + "</detail>";
    Element target = XmlUtil.getElement(XmlUtil.parseText(targetXml), "urn:example:other", "target");

    // perform the copy
    SoapUtil.copyVisibleNamespaces(target, source);

    // prefixed declaration
    assertEquals("urn:example:fish", target.getAttributeNS(BpelConstants.NS_XMLNS, "fish"));
    assertEquals("urn:example:meal", target.getAttributeNS(BpelConstants.NS_XMLNS, "meal"));
    // parent prefixed declaration
    assertNull(target.getAttributeNodeNS(BpelConstants.NS_XMLNS, "produce"));
    assertEquals(SOAPConstants.URI_NS_SOAP_ENVELOPE, target.getAttributeNS(BpelConstants.NS_XMLNS, "soap"));
}

From source file:org.jbpm.bpel.integration.soap.SoapUtilTest.java

public void testCopyChildNodes_domSoap() throws Exception {
    String xml = "<soap:Envelope xmlns:soap='" + SOAPConstants.URI_NS_SOAP_ENVELOPE + "'>"
            + " <soap:Body xmlns:fish='urn:example:fish'>" + "  <meal:lunch xmlns:produce='urn:example:produce'"
            + "   xmlns:meal='urn:example:meal'>" + "   <time>1200</time>"
            + "   <produce:lettuce>0.1lb</produce:lettuce>"
            + "   <fish:fillet xmlns:fish='urn:example:fish'>0.25lb</fish:fillet>" + "  </meal:lunch>"
            + " </soap:Body>" + "</soap:Envelope>";
    SOAPMessage soapMessage = parseSoap(xml);
    SOAPElement source = SoapUtil.getElement(soapMessage.getSOAPBody(), "urn:example:meal", "lunch");
    Element target = XmlUtil.createElement("detail");
    // perform the copy
    SoapUtil.copyChildNodes(target, source);
    // local element
    Element time = XmlUtil.getElement(target, "time");
    assertNull(time.getPrefix());/*from  w ww  . j  a  v a  2  s. c  o  m*/
    // qualified, prefixed element
    Element lettuce = XmlUtil.getElement(target, "urn:example:produce", "lettuce");
    assertEquals("produce", lettuce.getPrefix());
    // parent qualified, prefixed element
    Element fillet = XmlUtil.getElement(target, "urn:example:fish", "fillet");
    assertEquals("fish", fillet.getPrefix());
}

From source file:org.jbpm.bpel.integration.soap.SoapUtilTest.java

public void testGetPrefix_soap() throws Exception {
    String xml = "<soap:Envelope xmlns:soap='" + SOAPConstants.URI_NS_SOAP_ENVELOPE + "'>"
            + " <soap:Body xmlns:produce='urn:example:produce'>"
            + "  <meal:lunch produce:lettuce='0.1lb' fish:fillet='0.25lb' xmlns=''"
            + "   xmlns:fish='urn:example:fish' xmlns:meal='urn:example:meal'/>" + " </soap:Body>"
            + "</soap:Envelope>";
    SOAPMessage soapMessage = parseSoap(xml);
    SOAPElement elem = SoapUtil.getElement(soapMessage.getSOAPBody(), "urn:example:meal", "lunch");

    // prefixed declaration
    assertEquals("fish", SoapUtil.getPrefix("urn:example:fish", elem));
    assertEquals("meal", SoapUtil.getPrefix("urn:example:meal", elem));
    // parent prefixed declaration
    assertEquals("produce", SoapUtil.getPrefix("urn:example:produce", elem));
    assertEquals("soap", SoapUtil.getPrefix(SOAPConstants.URI_NS_SOAP_ENVELOPE, elem));
}

From source file:org.jbpm.bpel.integration.soap.SoapUtilTest.java

public void testCopy_domSoap_qualifiedNoPrefix() throws Exception {
    String xml = "<soapenv:Envelope xmlns:soapenv='" + SOAPConstants.URI_NS_SOAP_ENVELOPE + "'>"
            + " <soapenv:Body>" + "  <response xmlns='" + BpelConstants.NS_EXAMPLES + "'>" + "   <return>"
            + "    <amount>0.0</amount>" + "    <branch>140</branch>" + "    <capital>10419.18</capital>"
            + "    <status>1</status>" + "    <transaction xmlns:xsi='" + BpelConstants.NS_XML_SCHEMA_INSTANCE
            + "' xsi:nil='true'/>" + "   </return>" + "  </response>" + " </soapenv:Body>"
            + "</soapenv:Envelope>";
    SOAPMessage soapMessage = parseSoap(xml);
    SOAPElement source = SoapUtil.getElement(soapMessage.getSOAPBody(), BpelConstants.NS_EXAMPLES, "response");
    Element target = XmlUtil.createElement("detail");

    // perform the copy
    SoapUtil.copy(target, source);/* ww w. j a  v  a  2  s.c om*/
    target = XmlUtilTest.writeAndRead(target);

    // namespaces
    assertEquals(SOAPConstants.URI_NS_SOAP_ENVELOPE, target.getAttributeNS(BpelConstants.NS_XMLNS, "soapenv"));

    // child elements
    Element returnElem = XmlUtil.getElement(target, BpelConstants.NS_EXAMPLES, "return");

    // namespaces
    assertEquals(BpelConstants.NS_EXAMPLES, returnElem.getAttributeNS(BpelConstants.NS_XMLNS, "xmlns"));

    // child elements
    assertEquals("0.0",
            DatatypeUtil.toString(XmlUtil.getElement(returnElem, BpelConstants.NS_EXAMPLES, "amount")));
    assertEquals("140",
            DatatypeUtil.toString(XmlUtil.getElement(returnElem, BpelConstants.NS_EXAMPLES, "branch")));
    assertEquals("10419.18",
            DatatypeUtil.toString(XmlUtil.getElement(returnElem, BpelConstants.NS_EXAMPLES, "capital")));
    assertEquals("1",
            DatatypeUtil.toString(XmlUtil.getElement(returnElem, BpelConstants.NS_EXAMPLES, "status")));

    Element transactionElem = XmlUtil.getElement(returnElem, BpelConstants.NS_EXAMPLES, "transaction");

    // namespaces
    assertEquals(BpelConstants.NS_XML_SCHEMA_INSTANCE,
            transactionElem.getAttributeNS(BpelConstants.NS_XMLNS, "xsi"));

    // attributes
    assertEquals("true", transactionElem.getAttributeNS(BpelConstants.NS_XML_SCHEMA_INSTANCE, "nil"));
}