List of usage examples for javax.xml.soap Name getPrefix
String getPrefix();
From source file:com.googlecode.ddom.frontend.saaj.SOAPElementTest.java
/** * Test that {@link SOAPElement#getAllAttributes()} returns the correct {@link Name} for an * attribute with a namespace./*from ww w . j a va 2s . c o m*/ */ @Validated @Test public void testGetAllAttributesWithNamespace() { SOAPElement element = saajUtil.createSOAPElement(null, "test", null); element.setAttributeNS("urn:ns", "p:test", "value"); Iterator<?> it = element.getAllAttributes(); assertTrue(it.hasNext()); Name name = (Name) it.next(); assertEquals("urn:ns", name.getURI()); assertEquals("p", name.getPrefix()); assertEquals("test", name.getLocalName()); assertEquals("p:test", name.getQualifiedName()); }
From source file:com.googlecode.ddom.frontend.saaj.SOAPElementTest.java
/** * Test that {@link SOAPElement#getAllAttributes()} returns the correct {@link Name} for an * attribute without namespace./* ww w . j a v a 2 s.c o m*/ */ @Validated @Test public void testGetAllAttributesWithoutNamespace() { SOAPElement element = saajUtil.createSOAPElement(null, "test", null); element.setAttributeNS(null, "test", "value"); Iterator<?> it = element.getAllAttributes(); assertTrue(it.hasNext()); Name name = (Name) it.next(); assertTrue(StringUtils.isEmpty(name.getURI())); assertTrue(StringUtils.isEmpty(name.getPrefix())); assertEquals("test", name.getLocalName()); assertEquals("test", name.getQualifiedName()); }
From source file:com.googlecode.ddom.frontend.saaj.SOAPElementTest.java
@Validated @Test//from w w w.jav a 2 s. co m public void testGetElementNameWithoutNamespace() { SOAPElement element = saajUtil.createSOAPElement(null, "test", null); Name name = element.getElementName(); assertEquals("", name.getURI()); assertEquals("test", name.getLocalName()); assertEquals("", name.getPrefix()); }
From source file:com.googlecode.ddom.frontend.saaj.SOAPElementTest.java
@Validated @Test//www .ja va2 s. com public void testGetElementNameWithDefaultNamespace() { SOAPElement element = saajUtil.createSOAPElement("urn:test", "test", null); Name name = element.getElementName(); assertEquals("urn:test", name.getURI()); assertEquals("test", name.getLocalName()); assertEquals("", name.getPrefix()); }
From source file:com.googlecode.ddom.frontend.saaj.SOAPElementTest.java
@Validated @Test// w w w. ja va 2 s . c o m public void testGetElementNameWithNamespace() { SOAPElement element = saajUtil.createSOAPElement("urn:test", "test", "p"); Name name = element.getElementName(); assertEquals("urn:test", name.getURI()); assertEquals("test", name.getLocalName()); assertEquals("p", name.getPrefix()); }
From source file:org.apache.axis.message.MessageElement.java
/** * construct using a {@link javax.xml.soap.Name} implementation, * @see #MessageElement(String, String, String) * @param eltName/*from www. j a v a2s . co m*/ */ public MessageElement(Name eltName) { this(eltName.getLocalName(), eltName.getPrefix(), eltName.getURI()); }
From source file:org.apache.axis.message.MessageElement.java
/** * add the child element//w w w. j a va2 s.com * @param childName uri, prefix and local name of the element to add * @return the child element * @throws SOAPException * @see javax.xml.soap.SOAPElement#addChildElement(javax.xml.soap.Name) */ public SOAPElement addChildElement(Name childName) throws SOAPException { MessageElement child = new MessageElement(childName.getLocalName(), childName.getPrefix(), childName.getURI()); addChild(child); return child; }
From source file:org.apache.axis.message.MessageElement.java
/** * add a new attribute/*from w w w. ja va 2s . c om*/ * @param attrName name of the attribute * @param value a string value * @return ourselves * @throws SOAPException * @see javax.xml.soap.SOAPElement#addAttribute(javax.xml.soap.Name, String) */ public SOAPElement addAttribute(Name attrName, String value) throws SOAPException { try { addAttribute(attrName.getPrefix(), attrName.getURI(), attrName.getLocalName(), value); } catch (RuntimeException t) { throw new SOAPException(t); } return this; }
From source file:org.apache.axis2.jaxws.message.impl.XMLPartBase.java
public QName getOperationElement() throws WebServiceException { try {//from w w w.ja v a2s . c o m if (style != Style.RPC) { return null; } switch (contentType) { case OM: return ((org.apache.axiom.soap.SOAPEnvelope) content).getBody().getFirstElement().getQName(); case SPINE: return ((XMLSpine) content).getOperationElement(); case SOAPENVELOPE: Iterator it = ((SOAPEnvelope) content).getBody().getChildElements(); while (it.hasNext()) { Node node = (Node) it.next(); if (node instanceof SOAPElement) { Name name = ((SOAPElement) node).getElementName(); return new QName(name.getURI(), name.getLocalName(), name.getPrefix()); } } } return null; } catch (SOAPException se) { throw ExceptionFactory.makeWebServiceException(se); } }
From source file:org.jbpm.bpel.integration.soap.SoapUtil.java
public static void copyAttributes(Element target, SOAPElement source) { // easy way out: no attributes to copy if (!source.hasAttributes()) return;//from w w w . j av a 2 s . c om // traverse attributes Iterator attrNameIt = source.getAllAttributes(); while (attrNameIt.hasNext()) { Name attrName = (Name) attrNameIt.next(); String namespaceURI = attrName.getURI(); // isn't the attribute a namespace declaration? if (BpelConstants.NS_XMLNS.equals(namespaceURI)) continue; // unqualified? if (namespaceURI == null || namespaceURI.length() == 0) { String localName = attrName.getLocalName(); target.setAttribute(localName, source.getAttributeValue(attrName)); if (traceEnabled) log.trace("set attribute: " + localName); } // qualified else { Attr attr = target.getOwnerDocument().createAttributeNS(namespaceURI, attrName.getQualifiedName()); attr.setValue(source.getAttributeValue(attrName)); target.setAttributeNodeNS(attr); XmlUtil.ensureNamespaceDeclared(attr, namespaceURI, attrName.getPrefix()); if (traceEnabled) log.trace("set attribute: {" + namespaceURI + '}' + attrName.getQualifiedName()); } } }