Java SOAP Message getNamespaceDeclarations(SOAPEnvelope env, SOAPBodyElement body)

Here you can find the source of getNamespaceDeclarations(SOAPEnvelope env, SOAPBodyElement body)

Description

get Namespace Declarations

License

Open Source License

Declaration

private static HashMap<String, String> getNamespaceDeclarations(SOAPEnvelope env, SOAPBodyElement body) 

Method Source Code

//package com.java2s;
/*//from  ww  w .  j a  v a  2s .  com
 * Copyright (C) 2016 Inera AB (http://www.inera.se)
 *
 * This file is part of sklintyg (https://github.com/sklintyg).
 *
 * sklintyg is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * sklintyg is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

import java.util.HashMap;
import java.util.Iterator;

import javax.xml.soap.SOAPBodyElement;
import javax.xml.soap.SOAPEnvelope;

public class Main {
    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);
            }
        }
        // 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;
    }
}

Related

  1. getDeclaredNamespaces(SOAPElement aElement, Map aPrefixMap)
  2. getExcludedTypes()
  3. getFaultCodeAndString(SOAPMessage message)
  4. getHeaderValue(SOAPMessage message, String tagName)
  5. getJarredPluginPath(String bundleId)
  6. getNamespacePrefix(SOAPElement element, String nsURI)
  7. getNamespacePrefixes(SOAPElement element)
  8. getNamespaceURIs(SOAPMessage soap)
  9. getNode(Node node, String nodeName)