Name

Name

Synopsis

public interface Name {
// Public Instance Methods
    public abstract String getLocalName(  ); 
    public abstract String getPrefix(  ); 
    public abstract String getQualifiedName(  ); 
    public abstract String getURI(  ); 
}

Name is an interface that encapsulates the concept of an XML element name that may be namespace-qualified. It is used whenever such a name is required by the SAAJ API instead of the javax.xml.namespace.QName class, which is used by JAX-RPC. A Name has three attributes:

  • A local name, which all Name objects are required to have

  • A namespace URI, which uniquely identifies the namespace within which the local name is defined

  • The prefix that is used as a shorthand identifier for the namespace and that appears along with the local name in XML tags

Name objects can be obtained by calling one of the createName( ) methods of the SOAPFactory class or the SOAPEnvelope interface. These methods have two variants:

public Name createName(String localName) throws SOAPException;
public Name createName(String localName, String prefix, String uri) 
     throws SOAPException;

The first method creates a Name that is not explicitly associated with a namespace, as in the following example:

SOAPFactory factory = SOAPFactory.newInstance;
Name bookTitle = factory.createName("BookTitle");
SOAPElement bookTitleElement = factory.createElement(bookTitle);

If bookTitleElement is added to a SOAPMessage and serialized, it appears as BookTitle. The fact that the Name object does not have an explicit namespace ...

Get Java Web Services in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.