List of usage examples for javax.xml.soap SOAPElement getAttributeNS
public String getAttributeNS(String namespaceURI, String localName) throws DOMException;
From source file:com.googlecode.ddom.frontend.saaj.SOAPElementTest.java
@Validated @Test//w w w.ja v a2 s. c o m public void testAddNamespaceDeclarationDefaultNamespace() throws SOAPException { SOAPElement element = saajUtil.createSOAPElement("urn:test", "test", "p"); element.addNamespaceDeclaration("", "urn:ns"); assertEquals("urn:ns", element.getAttributeNS(XMLConstants.XMLNS_ATTRIBUTE_NS_URI, "xmlns")); }
From source file:com.googlecode.ddom.frontend.saaj.SOAPElementTest.java
/** * Test that a namespace declaration added using * {@link SOAPElement#addNamespaceDeclaration(String, String)} can be retrieved using * {@link Element#getAttributeNS(String, String)}. * //from ww w.j a v a2s .c om * @throws SOAPException */ @Validated @Test public void testAddNamespaceDeclarationNonDefaultNamespace() throws SOAPException { SOAPElement element = saajUtil.createSOAPElement("urn:test", "test", "p"); element.addNamespaceDeclaration("ns", "urn:ns"); assertEquals("urn:ns", element.getAttributeNS(XMLConstants.XMLNS_ATTRIBUTE_NS_URI, "ns")); }
From source file:org.jbpm.bpel.integration.soap.SoapUtilTest.java
public void testRemoveNamespaces_soap() throws Exception { String xml = "<soap:Envelope xmlns:soap='" + SOAPConstants.URI_NS_SOAP_ENVELOPE + "'>" + " <soap:Body xmlns:fish='urn:example:fish'>" + " <lunch time='1200' produce:lettuce='0.1lb' fish:fillet='0.25lb' " + " xmlns:produce='urn:example:produce' />" + " </soap:Body>" + "</soap:Envelope>"; ByteArrayInputStream sourceStream = new ByteArrayInputStream(xml.getBytes()); SOAPMessage soapMessage = MessageFactory.newInstance().createMessage(null, sourceStream); SOAPElement element = SoapUtil.getElement(soapMessage.getSOAPBody(), "lunch"); // remove namespaces SoapUtil.removeNamespaces(element);//from ww w . j av a2 s . c o m // verify remotion assertFalse(element.getNamespacePrefixes().hasNext()); // attributes should still be there // qualified attributes assertEquals("0.1lb", element.getAttributeNS("urn:example:produce", "lettuce")); assertEquals("0.25lb", element.getAttributeNS("urn:example:fish", "fillet")); // local attribute assertEquals("1200", element.getAttribute("time")); }