List of usage examples for javax.xml.soap Name getURI
String getURI();
From source file:com.googlecode.ddom.frontend.saaj.SOAPElementTest.java
@Validated @Test/* ww w. j a v a 2 s . com*/ 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
/** * Test that {@link SOAPElement#getAllAttributes()} returns the correct {@link Name} for an * attribute with a namespace./*from ww w .j a v a2s. c om*/ */ @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
@Validated @Test/* w ww . j a v a2 s .co 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:com.googlecode.ddom.frontend.saaj.SOAPElementTest.java
@Validated @Test/* w w w. j a va 2 s . c om*/ 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
/** * Test that {@link SOAPElement#getAllAttributes()} returns the correct {@link Name} for an * attribute without namespace./*from w ww . ja v a2s. c om*/ */ @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:it.cnr.icar.eric.server.interfaces.soap.RegistryBSTServlet.java
private SOAPMessage createFaultSOAPMessage(java.lang.Throwable e, SOAPHeader sh) { SOAPMessage msg = null;/* w w w .ja v a 2 s.c o m*/ if (log.isDebugEnabled()) { log.debug("Creating Fault SOAP Message with Throwable:", e); } try { // Will this method be "legacy" ebRS 3.0 spec-compliant and // return a URN as the <faultcode/> value? Default expectation // is of a an older client. Overridden to instead be SOAP // 1.1-compliant and return a QName as the faultcode value when // we know (for sure) client supports new approach. boolean legacyFaultCode = true; // get SOAPHeaderElement list from the received message // TODO: if additional capabilities are needed, move code to // elsewhere if (null != sh) { Iterator<?> headers = sh.examineAllHeaderElements(); while (headers.hasNext()) { Object obj = headers.next(); // confirm expected Iterator content if (obj instanceof SOAPHeaderElement) { SOAPHeaderElement header = (SOAPHeaderElement) obj; Name headerName = header.getElementName(); // check this SOAP header for relevant capability // signature if (headerName.getLocalName().equals(BindingUtility.SOAP_CAPABILITY_HEADER_LocalName) && headerName.getURI().equals(BindingUtility.SOAP_CAPABILITY_HEADER_Namespace) && header.getValue().equals(BindingUtility.SOAP_CAPABILITY_ModernFaultCodes)) { legacyFaultCode = false; // only interested in one client capability break; } } } } msg = MessageFactory.newInstance().createMessage(); SOAPEnvelope env = msg.getSOAPPart().getEnvelope(); SOAPFault fault = msg.getSOAPBody().addFault(); // set faultCode String exceptionName = e.getClass().getName(); // TODO: SAAJ 1.3 has introduced preferred QName interfaces Name name = env.createName(exceptionName, "ns1", BindingUtility.SOAP_FAULT_PREFIX); fault.setFaultCode(name); if (legacyFaultCode) { // we now have an element child, munge its text (hack alert) Node faultCode = fault.getElementsByTagName("faultcode").item(0); // Using Utility.setTextContent() implementation since Java // WSDP 1.5 (containing an earlier DOM API) does not // support Node.setTextContent(). Utility.setTextContent(faultCode, BindingUtility.SOAP_FAULT_PREFIX + ":" + exceptionName); } // set faultString String errorMsg = e.getMessage(); if (errorMsg == null) { errorMsg = "NULL"; } fault.setFaultString(errorMsg); // create faultDetail with one entry Detail det = fault.addDetail(); StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); e.printStackTrace(pw); String str = sw.toString(); name = env.createName("StackTrace", "rs", "urn:oasis:names:tc:ebxml-regrep:xsd:rs:3.0"); DetailEntry de = det.addDetailEntry(name); de.setValue(str); // de.addTextNode(str); // TODO: Need to put baseURL for this registry here msg.saveChanges(); } catch (SOAPException ex) { log.warn(ex, ex); // otherwise ignore the problem updating part of the message } return msg; }
From source file:it.cnr.icar.eric.server.interfaces.soap.RegistrySAMLServlet.java
/** * This method is a copy of the respective method from RegistrySOAPServlet. * The SAML-based Servlet returns X.509 certificate base SOAP messages. * // w w w .ja va 2 s .c om */ private SOAPMessage createFaultSOAPMessage(java.lang.Throwable e, SOAPHeader sh) { SOAPMessage msg = null; if (log.isDebugEnabled()) { log.debug("Creating Fault SOAP Message with Throwable:", e); } try { // Will this method be "legacy" ebRS 3.0 spec-compliant and // return a URN as the <faultcode/> value? Default expectation // is of a an older client. Overridden to instead be SOAP // 1.1-compliant and return a QName as the faultcode value when // we know (for sure) client supports new approach. boolean legacyFaultCode = true; // get SOAPHeaderElement list from the received message // TODO: if additional capabilities are needed, move code to // elsewhere if (null != sh) { Iterator<?> headers = sh.examineAllHeaderElements(); while (headers.hasNext()) { Object obj = headers.next(); // confirm expected Iterator content if (obj instanceof SOAPHeaderElement) { SOAPHeaderElement header = (SOAPHeaderElement) obj; Name headerName = header.getElementName(); // check this SOAP header for relevant capability // signature if (headerName.getLocalName().equals(BindingUtility.SOAP_CAPABILITY_HEADER_LocalName) && headerName.getURI().equals(BindingUtility.SOAP_CAPABILITY_HEADER_Namespace) && header.getValue().equals(BindingUtility.SOAP_CAPABILITY_ModernFaultCodes)) { legacyFaultCode = false; // only interested in one client capability break; } } } } msg = MessageFactory.newInstance().createMessage(); SOAPEnvelope env = msg.getSOAPPart().getEnvelope(); SOAPFault fault = msg.getSOAPBody().addFault(); // set faultCode String exceptionName = e.getClass().getName(); // TODO: SAAJ 1.3 has introduced preferred QName interfaces Name name = env.createName(exceptionName, "ns1", BindingUtility.SOAP_FAULT_PREFIX); fault.setFaultCode(name); if (legacyFaultCode) { // we now have an element child, munge its text (hack alert) Node faultCode = fault.getElementsByTagName("faultcode").item(0); // Using Utility.setTextContent() implementation since Java // WSDP 1.5 (containing an earlier DOM API) does not // support Node.setTextContent(). Utility.setTextContent(faultCode, BindingUtility.SOAP_FAULT_PREFIX + ":" + exceptionName); } // set faultString String errorMsg = e.getMessage(); if (errorMsg == null) { errorMsg = "NULL"; } fault.setFaultString(errorMsg); // create faultDetail with one entry Detail det = fault.addDetail(); StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); e.printStackTrace(pw); String str = sw.toString(); name = env.createName("StackTrace", "rs", "urn:oasis:names:tc:ebxml-regrep:xsd:rs:3.0"); DetailEntry de = det.addDetailEntry(name); de.setValue(str); // de.addTextNode(str); // TODO: Need to put baseURL for this registry here msg.saveChanges(); } catch (SOAPException ex) { log.warn(ex, ex); // otherwise ignore the problem updating part of the message } return msg; }
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 a 2 s .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/*from ww w.j a v a2s . c om*/ * @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 ww w .j ava2 s . co m * @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; }