Example usage for javax.xml.soap SOAPElement lookupNamespaceURI

List of usage examples for javax.xml.soap SOAPElement lookupNamespaceURI

Introduction

In this page you can find the example usage for javax.xml.soap SOAPElement lookupNamespaceURI.

Prototype

public String lookupNamespaceURI(String prefix);

Source Link

Document

Look up the namespace URI associated to the given prefix, starting from this node.

Usage

From source file:com.googlecode.ddom.frontend.saaj.SOAPElementTest.java

/**
 * Test that a call do {@link SOAPElement#addNamespaceDeclaration(String, String)} for a prefix
 * that is already declared on the same element will replace the existing namespace declaration.
 * //from   www  .  ja v  a  2s  . c o  m
 * @throws SOAPException
 */
@Validated
@Test
public void testAddNamespaceDeclarationForExistingPrefix() throws SOAPException {
    SOAPElement element = saajUtil.createSOAPElement(null, "test", null);
    element.addNamespaceDeclaration("p", "urn:ns1");
    element.addNamespaceDeclaration("p", "urn:ns2");
    assertEquals("urn:ns2", element.lookupNamespaceURI("p"));
    assertNull(element.lookupPrefix("urn:ns1"));
    assertEquals("p", element.lookupPrefix("urn:ns2"));
}