Example usage for javax.xml.soap SOAPBodyElement getNamespacePrefixes

List of usage examples for javax.xml.soap SOAPBodyElement getNamespacePrefixes

Introduction

In this page you can find the example usage for javax.xml.soap SOAPBodyElement getNamespacePrefixes.

Prototype

public Iterator<String> getNamespacePrefixes();

Source Link

Document

Returns an Iterator over the namespace prefix String s declared by this element.

Usage

From source file:Main.java

private static HashMap<String, String> getNamespaceDeclarations(SOAPEnvelope env, SOAPBodyElement body) {
    HashMap<String, String> namespaceDeclarations = new HashMap<String, String>();
    @SuppressWarnings("rawtypes")
    Iterator nss = env.getNamespacePrefixes();
    // Retrieve all namespace declarations from SOAP-ENV node
    while (nss.hasNext()) {
        String prefix = (String) nss.next();
        String uri = env.getNamespaceURI(prefix);
        // filter out SOAP-ENV namespace, since it is not interesting to us
        if (!uri.startsWith("http://schemas.xmlsoap.org/soap/envelope")) {
            namespaceDeclarations.put(prefix, uri);
        }/*from w ww.  j  a v a  2 s.  c o m*/
    }
    // Retrieve all namespace declarations from SOAP-BODY node
    nss = body.getNamespacePrefixes();
    while (nss.hasNext()) {
        String prefix = (String) nss.next();
        String uri = env.getNamespaceURI(prefix);
        namespaceDeclarations.put(prefix, uri);
    }
    return namespaceDeclarations;
}