Professional Documents
Culture Documents
TM
(JAXM) v0.93
FT
RA
D
i
ii
TM
Java API for XML Messaging Specification (“Specification”)
Version: 0.93
Status: Public Review Draft 2
Release: August, 2001
NOTICE.
This Specification is protected by copyright and the information described herein may be protected by one or more
U.S. patents, foreign patents, or pending applications. Except as provided under the following license, no part of
this Specification may be reproduced in any form by any means without the prior written authorization of Sun
Microsystems, Inc. (“Sun”) and its licensors, if any. Any use of this Specification and the information described
herein will be governed by the terms and conditions of this license and the Export Control and General Terms as set
forth in Sun's website Legal Terms. By viewing, downloading or otherwise copying this Specification, you agree that
you have read, understood, and will comply with all of the terms and conditions set forth herein.
Subject to the terms and conditions of this license, Sun hereby grants you a fully-paid, non-exclusive, non-
transferable, worldwide, limited license (without the right to sublicense) under Sun’s intellectual property rights to
review the Specification internally for the purposes of evaluation only. Other than this limited license, you acquire
no right, title or interest in or to the Specification or any other Sun intellectual property. The Specification contains
the proprietary and confidential information of Sun and may only be used in accordance with the license terms set
forth herein. This license will expire ninety (90) days from the date of Release listed above and will terminate
immediately without notice from Sun if you fail to comply with any provision of this license. Upon termination, you
must cease use of or destroy the Specification.
TRADEMARKS.
No right, title, or interest in or to any trademarks, service marks, or trade names of Sun or Sun's licensors is granted
hereunder. Sun, Sun Microsystems, the Sun logo, Java, the Java Coffee Cup Logo, Java Naming and Directory
Interface, and Java Community Process are trademarks or registered trademarks or service marks of Sun
Microsystems, Inc. in the U.S. and other countries.
DISCLAIMER OF WARRANTIES.
THIS SPECIFICATION IS PROVIDED "AS IS" AND IS EXPERIMENTAL AND MAY CONTAIN DEFECTS OR
DEFICIENCIES WHICH CANNOT OR WILL NOT BE CORRECTED BY SUN. SUN MAKES NO
REPRESENTATIONS OR WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO,
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT
THAT THE CONTENTS OF THE SPECIFICATION ARE SUITABLE FOR ANY PURPOSE OR THAT ANY
PRACTICE OR IMPLEMENTATION OF SUCH CONTENTS WILL NOT INFRINGE ANY THIRD PARTY
PATENTS, COPYRIGHTS, TRADE SECRETS OR OTHER RIGHTS. This document does not represent any
commitment to release or implement any portion of this Specification in any product.
LIMITATION OF LIABILITY.
TO THE EXTENT NOT PROHIBITED BY LAW, IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR
ANY DAMAGES, INCLUDING WITHOUT LIMITATION, LOST REVENUE, PROFITS OR DATA, OR FOR
SPECIAL, INDIRECT, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND
REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF OR RELATED TO ANY FURNISHING,
PRACTICING, MODIFYING OR ANY USE OF THE SPECIFICATION, EVEN IF SUN AND/OR ITS LICENSORS
HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
You will indemnify, hold harmless, and defend Sun and its licensors from any claims based on your use of the
Specification for any purposes other than those of internal evaluation, and from any claims that later versions or
releases of any Specification furnished to you are incompatible with the Specification provided to you under this
license.
If this Software is being acquired by or on behalf of the U.S. Government or by a U.S. Government prime contractor
or subcontractor (at any tier), then the Government’s rights in the Software and accompanying documentation shall
be only as set forth in this license; this is in accordance with 48 C.F.R. 227.7201 through 227.7202-4 (for Department
of Defense (DoD) acquisitions) and with 48 C.F.R. 2.101 and 12.212 (for non-DoD acquisitions).
REPORT.
You may wish to report any ambiguities, inconsistencies, or inaccuracies you may find in connection with your
evaluation of the Specification (“Feedback”). To the extent that you provide Sun with any Feedback, you hereby: (i)
agree that such Feedback is provided on a non-proprietary and non-confidential basis and (ii) grant Sun a perpetual,
non-exclusive, worldwide, fully paid-up, irrevocable license, with the right to sublicense through multiple levels of
sublicensees, to incorporate, disclose, and use without limitation the Feedback for any purpose related to the
Specification and future versions, implementations, and test suites thereof.
iv
v
vi
SOAPEnvelope ..................................................................96
SOAPException .................................................................99
SOAPFault .........................................................................103
SOAPHeader ......................................................................105
SOAPHeaderElement ........................................................108
SOAPMessage ...................................................................110
SOAPPart ...........................................................................116
Text ....................................................................................122
References .............................................................................123
viii
This document is the JAXM Specification, version 0.93. The main goal of this
draft is to enable the developer community to review and comment on the work of
the JSR067 Expert Group (EG).
JAXM.S.2 Acknowledgements
gdaniels@macromedia.com
simeons@allaire.com
peter.eberlein@sapmarkets.com
meera_bavadekar@hp.com
BJones@Bluestone.com
jags.ramnarayan@bea.com
pal.takacsi@bea.com
jcrump@exceloncorp.com
jjdubray@exceloncorp.com
Jean.Choi@sybase.com
himagiri@sybase.com
ix
x
Markus.Breilmann@tamgroup.com
francis.ho@webMethods.com
pyendluri@webmethods.com
ksankar@cisco.com
david.clay@oracle.com
neal.wyse@oracle.com
srh@us.ibm.com
chappell@sonicsoftware.com
cevans@progress.com
james_strachan@yahoo.co.uk
nazrul.islam@commerceone.com
richard.denoix@commerceone.com
seumas.soltysik@iona.com
JAXM.S.3 Terminology
MUST NOT: This phrase, or the phrase “SHALL NOT”, mean that
the definition is an absolute prohibition of the specification.
JAXM.P.1 Audience
This document is intended for developers using the Java programming language, e-
commerce architects, and application developers focused on the development of
business-to-business messaging applications. Many of the concepts mentioned in
this document are being discussed by participants within the ebXML (http://
www.ebxml.org) community and the W3C XML Protocol working group.
JAXM.P.2 Abstract
The JavaTM API for XML Messaging (JAXM v0.93) enables developers to write
business applications that support emerging industry messaging standards based on
the SOAP1.1 and SOAP with Attachments specifications. Because the XML mes-
saging standards are being developed outside of the JavaTM Community Process and
are evolving at different rates (driven by a diverse set of business and technical
requirements), the JAXM 0.93 specification does not mandate the use of any spe-
cific XML messaging standard. The term standard is being used here to denote a
specific usage of SOAP messaging. Within the context of this document, the term
Profile is used to refer to a specific protocol based on SOAP1.1 (with Attachments).
xiii
xiv
The following figure presents a conceptual relationship between JAXM and other
architectural elements required in web-based, business-to-business messaging.
Organization ‘B’
Organization ‘A’
JAXM Provider
SOAP Provider
SMTP/
HTTP HTTP POP
IMAP
1
2 BACKGROUND
JAXM.1.2 Scope
that in this case, the reply message is typically purely informational in nature, that
is, it does not necessarily relate to the request that was sent.
The case shown in Figure 6. implies that the sender is not expecting a
response to the request message being sent.
JAXM.1.3 Interoperability
Although JAXM is heavily biased towards using industry standards, the only
requirement placed on JAXM 0.93 providers is that they must support SOAP1.1
and SOAP with Attachments. In addition, JAXM providers may optionally choose
to support higher level industry messaging protocols built on top of the SOAP
standard. As stated earlier, a specific industry usage of SOAP is referred to here as
6 BACKGROUND
There are two packaging models for SOAP messages, one that includes attachments
and one that does not. JAXM provides a standard way of both producing and con-
suming SOAP messages with or without attachments.
SOAP Part
SOAP-ENV:Envelope
SOAP-ENV:Header
SOAP-ENV:Body
Attachment Part
SOAP Attachment
(XML or non-XML)
Figure 7. depicts the conceptual model of a JAXM message that includes one
or more attachments. This message is aligned with the SOAP1.1 and SOAP with
Attachments specifications, which all JAXM implementations must support.
A JAXM client may choose whether to create and/or consume SOAP attach-
ments based on application-specific requirements. For instance, an acknowledge-
ment does not require an attachment, whereas content that is not in XML format
does require an attachment. The attachment part of a message can contain any
kind of content, from image files to plain text.
8 BACKGROUND
SOAP-ENV:Header
SOAP-ENV:Body
The JavaTM2 Platforms currently provide APIs for three distinct messaging infra-
structures namely; Web Services (SOAP1.1 based messaging), Message Oriented
Middleware (MOM), and Mail. Although these infrastructures share similarities at
the conceptual level, in reality they are sufficiently different that Java developers
have required and have gravitated towards APIs optimized for each infrastructure.
Application developers are likely to choose JAXM in cases where they wish to
communicate over SOAP infrastructures. The fact that SOAP has specified more
than one transport binding (and indeed has not precluded bindings for MOM
infrastructures) does not undermine the notion that the conceptual model for
JAXM developers is one in which the application endpoints are in fact SOAP end-
points. Having said this, a given JAXM Provider may choose to transport SOAP
10 BACKGROUND
The term client as used here is essentially synonymous with the term application,
that is, a collection of application-level functionality that is typically deployed either
in a J2EE Web Container or J2EE EJB Container. In addition, a standalone J2SE
application may implement only the client view of the JAXM API. Such an applica-
tion is considered to be a special-case, since for whatever reason, it has no need to
utilize the services of a provider. This application is assumed to be a client of a
point-to-point synchronous messaging service offering only a request-response style
of interaction. An implementation of the JAXM API must support both one-way and
request-response style messaging.
In general, JAXM clients will be consumers of services offered by providers.
The capabilities of providers may vary widely, and their specific capabilities, for
example, in the area of Quality of Service, fall outside the scope of this document.
In principle, JAXM providers are considered to be part of the communications
infrastructure as opposed to being application specific. Message routing or reli-
able messaging are examples of the functionality that a JAXM provider may
choose to implement.
JAXM clients (implementing a service) must be capable of consuming
SOAP1.1 (with attachments) messages. In addition, when a JAXM client is
deployed in a J2EE Web Container, the SOAP1.1 protocol must be bound to
HTTP. However, the way in which JAXM clients communicate with JAXM pro-
viders is considered to be a private implementation detail. A JAXM client is not
11
12 INFRASTRUCTURE
JAXM implementations must adopt a best effort strategy for ensuring the validity of
messages produced and sent to peer entities. JAXM providers, on receiving a mal-
formed message, are responsible for producing an appropriate error message and
sending it to the offending peer entity. The structure and addressing of inter-provider
error messages is Profile-specific. JAXM does not make a distinction between error
messages and any other Profile-specific message. Given that Providers are “Profile-
aware”, they may choose to map an error condition onto a Profile-specific error mes-
sage. Such messages would be delivered to a client in the same manner as any other
message. It is the responsibility of the JAXM client to consume error messages and
take application-specific corrective action.
JAXM implementations must support the SOAP1.1 and SOAP Messages with
Attachments specifications. However, these specifications provide a very basic
packaging model and offer no specific addressing scheme or message structure for
the routing of messages between peer entities.
By way of example, a specific Profile may stipulate a specific usage of a
SOAP header. JAXM does not specify what specific XML content must be placed
in the SOAP header, body or attachments. Most enterprise-grade usages of SOAP
messaging will typically specify critical information regarding the sender, recipi-
ent, message ID, and correlation information. The latter is needed to relate
response messages to previous requests.
JAXM implementations may choose to support a number of industry standard
messaging Profiles. Profiles are identified by a name that uniquely identifies a par-
ticular industry/standards body’s usage of SOAP messaging. A JAXM client must
use the URI of the schema associated with a given Profile as the Profile name. For
Example the Profile for ebXML TR&P 1.0 could be identified by the following
URI:
http://www.ebxml.org/project_teams/transport/messageHeader.xsd
JAXM.2.5 AsyncListener
JAXM.2.6 SyncListener
JAXM introduces no new security requirements. Messages are assumed to have both
a transitory as well as a persistent confidentiality requirement. Support of security
features and capabilities assuring confidentiality while messages are in transit are an
implementation detail of the JAXM Provider. Although HTTP is the transport of
choice, support for protocols such as SSL may be appropriate and adequate. In the
case of SMTP infrastructures, JAXM providers may choose to use PGP and or S/
MIME.
JAXM provides no specific interfaces to digital signatures that span an entire
message. The assumption is that developers will have access to “user” level por-
tions of a message—where “user” level is defined as the application-specific parts
of a message. Note that the signing or encrypting of the SOAP header in a manner
that would prevent the message from being interpreted and therefore correctly
routed will raise a JAXM exception. A developer may require some application-
specific (and therefore potentially nonstandard) encryption algorithms and/or
security functions to be applied to predefined portions of a message. In such cir-
cumstances, developers must select an appropriate Profile known to the JAXM
provider.
Developers may choose to use digital signature technologies to sign applica-
tion-level XML fragments as they see fit. As mentioned earlier, the application of
specific signing technology must not interfere with the routing of messages by the
JAXM infrastructure.
The authentication of JAXM clients to JAXM providers is considered to be an
implementation detail and beyond the scope of this specification.
16 INFRASTRUCTURE
The messaging package provides a higher level abstraction than the SOAP package
offers on its own. JAXM clients intending to support asynchronous one-way mes-
saging must do so by using an implementation of the messaging package. The pack-
age includes connection, listener, and endpoint objects.
17
18 PACKAGE OVERVIEW
JAXM therefore relies on Profiles, that is, industry standard usages of SOAP for
interoperable addressing conventions. Given that JAXM supports both one-way
and request-response forms of messaging, the Endpoint object has been modeled
such that it must be specified explicitly on the call method of the SOAPCon-
nection class. By contrast, the send method of the ProviderConnection
class does not allow for the specification of an Endpoint object since there is an
assumption that one-way messaging is inherently asynchronous thus requiring self
dressed (that is, Profiled) messages.
A JAXMException
object is a subclass of
SOAPException
and may contain a
String denoting the
reason for the exception
and/or an embedded
Throwable object.
20 PACKAGE OVERVIEW
The SOAP Package provides the primary abstraction for SOAP Messages
with MIME attachments. Attachments may be entire XML documents, XML frag-
ments, or any other content with a valid MIME type. In addition, this package pro-
vides a simple client side view of a request-response style of interaction with a
SOAP service.
22 PACKAGE OVERVIEW
The SOAPMessage class is the root class for all SOAP messages. Such
messages must contain a SOAPPart and may contain one or more Attach-
The SOAPElement object is the base class for all of the classes that model
the SOAP objects defined by the SOAP1.1 specification. The SOAPElement
object may be used to model the following:
A SOAPHeader
object is an abstrac-
tion of the SOAP
header element. A
SOAPHeader
object can be created
using the getEnve-
lope method of the SOAPPart object. SOAPHeader objects can have only
SOAPHeaderElement objects as their immediate children. The addHead-
erElement method creates a new HeaderElement object and adds it to the
SOAPHeader object.
SOAPHeader and
SOAPHeaderEle-
ment objects both
extend the SOAPEle-
ment object. A SOAP-
HeaderElement
object models the contents
of the SOAP header of a
SOAP envelope.
JAXM.3.2.7 SOAPConnection
The SOAPException
object extends
java.lang.Excep-
tion and is used to sig-
nal SOAP level
exceptions.
JAXMException fur-
ther extends SOAPEx-
ception.
/*
* $Id: SendingServlet.java,v 1.5 2001/08/04 01:58:19 mode Exp $
* $Revision: 1.5 $
* $Date: 2001/08/04 01:58:19 $
*
* Copyright 2000-2001 by Sun Microsystems, Inc.,
* 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
* All rights reserved.
32 PACKAGE OVERVIEW
*
* This software is the confidential and proprietary information
* of Sun Microsystems, Inc. ("Confidential Information"). You
* shall not disclose such Confidential Information and shall use
* it only in accordance with the terms of the license agreement
* you entered into with Sun.
*/
package simple.sender;
import java.net.*;
import java.io.*;
import java.util.*;
import javax.servlet.http.*;
import javax.servlet.*;
import javax.xml.messaging.*;
import javax.xml.soap.*;
import javax.activation.*;
import javax.naming.*;
import org.apache.log4j.*;
/**
* Sample servlet that is used for sending the message.
*
* @author Rajiv Mordani (rajiv.mordani@sun.com)
* @author Anil Vijendran (anil@sun.com)
*/
public class SendingServlet extends HttpServlet {
static Category
logger = Category.getInstance("Samples/Simple");
String to = "http://127.0.0.1:8080/simple/receiver";
String data = "http://127.0.0.1:8080/simple/index.html";
ServletContext servletContext;
ServletException
{
super.init( servletConfig );
servletContext = servletConfig.getServletContext();
try {
con = SOAPConnection.newInstance();
} catch(Exception e) {
logger.error("Unable to open a SOAPConnection", e);
}
InputStream in
= servletContext.getResourceAsStream(
"/WEB-INF/address.properties");
if (in != null) {
Properties props = new Properties();
try {
props.load(in);
String to = props.getProperty("to");
String data = props.getProperty("data");
if (to != null)
this.to = to;
if (data != null)
this.data = data;
} catch (IOException ex) {
// Ignore
}
}
}
{
try {
// Create a message factory.
MessageFactory mf = MessageFactory.newInstance();
gltp.addChildElement(envelope.createName("symbol",
"ztrade",
"http://wombat.ztrade.com")).addTextNode("SUNW");
AttachmentPart ap =
msg.createAttachmentPart(new DataHandler(url));
ap.setContentType("text/html");
System.err.println("<html>");
if (reply != null) {
FileOutputStream replyFile = new
FileOutputStream("reply.msg");
reply.writeTo(replyFile);
replyFile.close();
System.err.println("Reply logged in \"reply.msg\"");
} else
System.err.println("No reply");
String retval =
"<html><H4>Sent Message (check \"sent.msg\" and \"reply.msg\""+
" files for the sent and received messages)</H4></html>";
OutputStream os = resp.getOutputStream();
os.write(retval.getBytes());
os.flush();
os.close();
} catch(Throwable e) {
logger.error("Error in constructing or sending message "
+e.getMessage());
}
}
}
36 PACKAGE OVERVIEW
/*
* $Id: ReceivingServlet.java,v 1.2 2001/08/02 09:24:19 akv Exp $
* $Revision: 1.2 $
* $Date: 2001/08/02 09:24:19 $
*
* Copyright 2000-2001 by Sun Microsystems, Inc.,
* 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
* All rights reserved.
*
* This software is the confidential and proprietary information
* of Sun Microsystems, Inc. ("Confidential Information"). You
* shall not disclose such Confidential Information and shall use
* it only in accordance with the terms of the license agreement
* you entered into with Sun.
*/
package simple.receiver;
import javax.xml.messaging.*;
import javax.xml.soap.*;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.xml.transform.*;
import javax.naming.*;
import org.apache.log4j.*;
/**
* Sample servlet that receives messages.
*
* @author Rajiv Mordani (mode@eng.sun.com)
* @author Anil Vijendran (anil@sun.com)
*/
public class ReceivingServlet extends JAXMServlet {
static Category
logger = Category.getInstance("Samples/Simple");
{
super.init(servletConfig);
// Not much there to do here.
}
/*
This is the application code for handling the message..
Once the message is received the application can retrieve
the soap part, the attachment parts if there are any, or any
other information from the message.
*/
msg = msgFactory.createMessage();
SOAPEnvelope envelope =
msg.getSOAPPart().getEnvelope(true);
body.addBodyElement(envelope.createName(
"GetLastTradePriceResponse",
"ztrade", "http://wombat.ztrade.com"))
.addChildElement("Price")
.addTextNode("95.12");
} catch(Exception e) {
logger.error(
"Error in processing or replying to a message", e);
}
return msg;
}
}
38 PACKAGE OVERVIEW
Class Summary
Interfaces
AsyncListener40 A marker interface for components (for example, servlets) that are intended to be con-
sumers of JAXM messages.
ProviderConnection49 A client’s active connection to its messaging provider.
ProviderConnectionFac A factory for creating connections to a particular messaging provider.
tory52
ProviderMetaData53 Information about the messaging provider to which a client has a connection.
SyncListener55 A marker interface for components (for example, servlets) that are intended to be con-
sumers of JAXM messages.
Classes
Endpoint41 An opaque representation of an application endpoint.
JAXMServlet45 The superclass for components that live in a servlet container that receives JAXM mes-
sages.
URLEndpoint56 A special case of the Endpoint class used for simple applications that want to com-
municate directly with another SOAP-based application instead of going through a
provider.
Exceptions
JAXMException43 An exception that signals that a JAXM exception has occurred.
39
AsyncListener javax.xml.messaging
onMessage(SOAPMessage)
javax.xml.messaging
AsyncListener
Declaration
Description
A marker interface for components (for example, servlets) that are intended to be consumers of JAXM mes-
sages. Components that implement this interface are intended just for message receives.
Member Summary
Methods
public void onMessage(SOAPMessage)40
Passes the given SOAPMessage object to this AsyncListener object.
Methods
onMessage(SOAPMessage)
40
javax.xml.messaging Endpoint
onMessage(SOAPMessage)
javax.xml.messaging
Endpoint
Declaration
Description
An opaque representation of an application endpoint. Typically, an Endpoint object represents a business
entity, but it may represent a party of any sort. Conceptually, an Endpoint object is the mapping of a logical
name (example, a URI) to a physical location, such as a URL.
For messaging using a provider that supports profiles, an application does not need to specify an endpoint when
it sends a message because destination information will be contained in the profile-specific header. However, for
point-to-point plain SOAP messaging, an application must supply an Endpoint object to the SOAPConnec-
tion method call to indicate the intended destination for the message. The subclass URLEndpoint56 can
be used when an application wants to send a message directly to a remote party without using a messaging pro-
vider.
The default identification for an Endpoint object is a URI. This defines what JAXM messaging providers
need to support at minimum for identification of destinations. A messaging provider needs to be configured
using a deployment-specific mechanism with mappings from an endpoint to the physical details of that end-
point.
Endpoint objects can be created using the constructor, or they can be looked up in a naming service. The lat-
ter is more flexible because logical identifiers or even other naming schemes (such as DUNS numbers) can be
bound and rebound to specific URIs.
Member Summary
Fields
protected id42
A string that identifies the party that this Endpoint object represents; a URI is the
default.
Constructors
public Endpoint(String)42
Constructs an Endpoint object using the given string identifier.
Methods
public String toString()42
Retrieves a string representation of this Endpoint object.
41
Endpoint javax.xml.messaging
id
Fields
id
protected java.lang.String id
A string that identifies the party that this Endpoint object represents; a URI is the default.
Constructors
Endpoint(String)
Methods
toString()
42
javax.xml.messaging JAXMException
toString()
javax.xml.messaging
JAXMException
Declaration
java.lang.Object
|
+--java.lang.Throwable
|
+--java.lang.Exception
|
+--javax.xml.soap.SOAPException99
|
+--javax.xml.messaging.JAXMException
Description
An exception that signals that a JAXM exception has occurred. A JAXMException object may contain a
String that gives the reason for the exception, an embedded Throwable object, or both. This class provides
methods for retrieving reason messages and for retrieving the embedded Throwable object.
Typical reasons for throwing a JAXMException object are problems such as, not being able to send a mes-
sage, and not being able to get a connection with the provider. Reasons for embedding a Throwable object
include problems such as an input/output errors or a parsing problem, such as an error parsing a header.
Member Summary
Constructors
public JAXMException()44
Constructs a JAXMException object with no reason or embedded Throwable
object.
public JAXMException(String)44
Constructs a JAXMException object with the given String as the reason for the
exception being thrown.
public JAXMException(String, Throwable)44
Constructs a JAXMException object with the given String as the reason for the
exception being thrown and the given Throwable object as an embedded exception.
public JAXMException(Throwable)44
Constructs a JAXMException object initialized with the given Throwable object.
43
JAXMException javax.xml.messaging
JAXMException()
Constructors
JAXMException()
public JAXMException()
Constructs a JAXMException object with no reason or embedded Throwable object.
JAXMException(String)
JAXMException(String, Throwable)
JAXMException(Throwable)
44
javax.xml.messaging JAXMServlet
JAXMException(Throwable)
javax.xml.messaging
JAXMServlet
Declaration
Description
The superclass for components that live in a servlet container that receives JAXM messages. A JAXMServlet
object is notified of a message’s arrival using the HTTP-SOAP binding.
The JAXMServlet class is a support/utility class and is provided purely as a convenience. It is not a manda-
tory component, and there is no requirement that it be implemented or extended.
Note that when a component that receives messages extends JAXMServlet, it also needs to implement either
a SyncListener or an AsyncListener depending on whether the component is written for request-
response style interaction or just asynchronous receives.
Member Summary
Fields
protected msgFactory46
The MessageFactory object that will be used internally to create the SOAPMes-
sage object to be passed to the method onMessage.
Constructors
public JAXMServlet()47
Methods
public void doPost(HttpServletRequest, HttpServletResponse)47
Internalizes the given HttpServletRequest object and writes the reply to the
given HttpServletResponse object.
protected static Mime- getHeaders(HttpServletRequest)47
Headers Returns a MimeHeaders object that contains the headers in the given Http-
ServletRequest object.
public void init(ServletConfig)47
Initializes this JAXMServlet object using the given ServletConfig object and
initializing the msgFactory field with a default MessageFactory object.
protected static void putHeaders(MimeHeaders, HttpServletResponse)48
Sets the given HttpServletResponse object with the headers in the given
MimeHeaders object.
45
JAXMServlet javax.xml.messaging
msgFactory
Member Summary
public void setMessageFactory(MessageFactory)48
Sets this JAXMServlet object’s msgFactory field with the given Message-
Factory object.
Fields
msgFactory
46
javax.xml.messaging JAXMServlet
JAXMServlet()
Constructors
JAXMServlet()
public JAXMServlet()
Methods
doPost(HttpServletRequest, HttpServletResponse)
getHeaders(HttpServletRequest)
init(ServletConfig)
47
JAXMServlet javax.xml.messaging
putHeaders(MimeHeaders, HttpServletResponse)
putHeaders(MimeHeaders, HttpServletResponse)
setMessageFactory(MessageFactory)
48
javax.xml.messaging ProviderConnection
setMessageFactory(MessageFactory)
javax.xml.messaging
ProviderConnection
Declaration
Description
A client’s active connection to its messaging provider.
A ProviderConnection object is created using a ProviderConnectionFactory object, which is
configured so that the connections it creates will be to a particular messaging provider. To create a connection, a
client first needs to obtain an instance of the ProviderConnectionFactory class that creates connections
to the desired messaging provider. The client then calls the createConnection method on it to get a
ProviderConnection object that connects the client with its messaging provider.
The information necessary to set up a ProviderConnectionFactory that creates connections to a partic-
ular messaging provider is provided at deployment time. Typically an instance of ProviderConnection-
Factory will be bound to a logical name in a naming service. Later the client can do a lookup on the logical
name to retrieve an instance of the ProviderConnectionFactory class that produces connections to its
messaging provider.
The following code fragment is an example of a client doing a lookup of a ProviderConnectionFactory
object and then using it to create a connection. The first two lines in this example use the JavaTM Naming and
Directory Interface (JNDI) to create a context, which is then used to do the lookup. The argument provided to
the lookup method is the logical name that was previously associated with the desired messaging provider.
The lookup method returns a Java Object, which needs to be cast to a ProviderConnectionFactory
object before it can be used to create a connection. In the following code fragment, the resulting Provider-
Connection object is a connection to the messaging provider that is associated with the logical name
“ProviderXYZ”.
Context ctx = new InitialContext();
ProviderConnectionFactory pcf = (ProviderConnectionFactory)ctx.lookup(“ProviderXYZ”);
ProviderConnection con = pcf.createConnection();
After the client has obtained a connection to its messaging provider, it can use that connection to create one or
more MessageFactory objects, which can then be used to create SOAPMessage objects. Messages are
delivered to an endpoint using the ProviderConnection method send.
The messaging provider maintains a list of Endpoint objects, which is established at deployment time as part
of configuring the messaging provider. When a client uses a messaging provider to send messages, it can send
messages only to those parties represented by Endpoint objects in its messaging provider’s list. This is true
because the messaging provider maps the URI for each Endpoint object to a URL.
Note that it is possible for a client to send a message without using a messaging provider. In this case, the client
uses a SOAPConnection object and sends the message directly to its destination using a URL. See
SOAPConnection87 and URLEndpoint56 for more information.
Typically, because clients have one messaging provider, they will do all their messaging with a single
ProviderConnection object. It is possible, however, for a sophisticated application to use multiple con-
nections.
49
ProviderConnection javax.xml.messaging
close()
Generally, a container is configured with a Listener component at deployment time using an implementation-
specific mechanism. A client running in such a container will use a listener object to receive messages, which
means that the client can receive messages asynchronously. In this scenario, the ProviderConnection
method send is used to send a message.
By contrast, a client that is running as a standalone application, and therefore has no Listener object, is unable to
send and receive messages asynchronously. If a client wants a response to a message, it must send the message
using the ProviderConnection method call. This method will send the message and block until it gets a
response, which it then returns to the client that sent the original message. In this synchronous messaging sce-
nario, the client cannot send another message until after the response is returned.
Due to the authentication and communication setup done when a ProviderConnection object is created, it
is a relatively heavy-weight object. Therefore, a client should close its connection as soon as it is done using it.
JAXM objects created using one ProviderConnection object cannot be used with a different
ProviderConnection object.
Member Summary
Methods
public void close()50
Closes this ProviderConnection object, freeing its resources and making it
immediately available for garbage collection.
public MessageFactory createMessageFactory(String)51
Creates a MessageFactory object that will produce SOAPMessage objects for
the given profile.
public ProviderMeta- getMetaData()51
Data Retrieves the ProviderMetaData object that contains information about the mes-
saging provider to which this ProviderConnection object is connected.
public void send(SOAPMessage)51
Sends the given SOAPMessage object and returns immediately after handing the
message over to the messaging provider.
Methods
close()
50
javax.xml.messaging ProviderConnection
createMessageFactory(String)
createMessageFactory(String)
getMetaData()
send(SOAPMessage)
51
ProviderConnectionFactory javax.xml.messaging
createConnection()
javax.xml.messaging
ProviderConnectionFactory
Declaration
Description
A factory for creating connections to a particular messaging provider. A ProviderConnectionFactory
object is an administered object that is created by the container (a servlet or Enterprise JavaBeansTM container)
in which an application runs.
A ProviderConnectionFactory object is configured in an implementation- specific way, and the con-
nections it creates will be to a particular messaging provider. A ProviderConnectionFactory object is
registered with a naming service, such as one based on Java Naming and Directory InterfaceTM (JNDI) technol-
ogy. This registration associates the ProviderConnectionFactory object with a logical name. When an
application wants to establish a connection with the provider associated with that ProviderConnection-
Factory object, it does a lookup, providing the logical name. The application can then use the Provider-
ConnectionFactory object that is returned to create a connection to the messaging provider.
Member Summary
Methods
public ProviderCon- createConnection()52
nection Creates a ProviderConnection object to the messaging provider that is the pro-
vider associated with this ProviderConnectionFactory object.
Methods
createConnection()
52
javax.xml.messaging ProviderMetaData
createConnection()
javax.xml.messaging
ProviderMetaData
Declaration
Description
Information about the messaging provider to which a client has a connection.
After obtaining a connection to its messaging provider, a client can get information about that provider. The fol-
lowing code fragment demonstrates how the ProviderConnection object con can be used to retrieve its
ProviderMetaData object and then to get the name and version number of the messaging provider.
ProviderMetaData pmd = con.getMetaData();
String name = pmd.getProviderName();
int majorVersion = pmd.getProviderMajorVersion();
int minorVersion = pmd.getProviderMinorVersion();
Member Summary
Methods
public int getMajorVersion()54
Retrieves an int indicating the major version number of the messaging provider to
which the ProviderConnection object described by this ProviderMeta-
Data object is connected.
public int getMinorVersion()54
Retrieves an int indicating the minor version number of the messaging provider to
which the ProviderConnection object described by this ProviderMeta-
Data object is connected.
public String getName()54
Retrieves a String containing the name of the messaging provider to which the
ProviderConnection object described by this ProviderMetaData object is
connected.
public String[] getSupportedProfiles()54
Retrieves a list of the messaging profiles that are supported by the messaging provider
to which the ProviderConnection object described by this ProviderMeta-
Data object is connected.
53
ProviderMetaData javax.xml.messaging
getMajorVersion()
Methods
getMajorVersion()
getMinorVersion()
getName()
getSupportedProfiles()
54
javax.xml.messaging SyncListener
onMessage(SOAPMessage)
javax.xml.messaging
SyncListener
Declaration
Description
A marker interface for components (for example, servlets) that are intended to be consumers of JAXM mes-
sages. Components that implement this interface are intended for request-response style interaction.
Member Summary
Methods
public SOAPMessage onMessage(SOAPMessage)55
Passes the given SOAPMessage object to this SyncListener object and returns
the response.
Methods
onMessage(SOAPMessage)
55
URLEndpoint javax.xml.messaging
onMessage(SOAPMessage)
javax.xml.messaging
URLEndpoint
Declaration
java.lang.Object
|
+--javax.xml.messaging.Endpoint41
|
+--javax.xml.messaging.URLEndpoint
Description
A special case of the Endpoint class used for simple applications that want to communicate directly with
another SOAP-based application instead of going through a provider.
A URLEndpoint object contains a URL, which is used to make connections to the remote party. A standalone
client can pass a URLEndpoint object to the SOAPConnection method call to send a message synchro-
nously.
Since: 0.93
Member Summary
Constructors
public URLEndpoint(String)57
Constructs a new URLEndpoint object using the given URL.
Methods
public String getURL()57
Gets the URL associated with this URLEndpoint object.
56
javax.xml.messaging URLEndpoint
URLEndpoint(String)
Constructors
URLEndpoint(String)
Methods
getURL()
57
URLEndpoint javax.xml.messaging
getURL()
58
C H A P T E R JAXM.5
Package javax.xml.soap
Class Summary
Interfaces
Detail68 A container for DetailEntry objects.
DetailEntry69 The content for a Detail object, giving details for a SOAPFault object.
Name79 A representation of an XML name.
Node81 A representation of a node (element) in a DOM representation of an XML document
that provides some tree manipulation methods.
SOAPBody83 An object that represents the contents of the SOAP body element in a SOAP message.
SOAPBodyElement86 A SOAPBodyElement object represents the contents in a SOAPBody object.
SOAPConstants89 This interface defines a number of constants pertaining to the SOAP 1.1 protocol.
SOAPElement90 An object representing the contents in a SOAPBody object, the contents in a SOAP-
Header object, the content that can follow the SOAPBody object in a SOAPEnve-
lope object, or what can follow the detail element in a SOAPFault object.
SOAPEnvelope96 The container for the SOAPHeader and SOAPBody portions of a SOAPPart object.
SOAPFault103 An object that contains error and/or status information within a SOAP message.
SOAPHeader105 A SOAPHeader object represents the contents of the SOAP header element.
SOAPHeaderElement108 An object representing the contents in the SOAP header part of the SOAP envelope.
Text122 A representation of a node whose value is text.
Classes
AttachmentPart61 A single attachment to a SOAPMessage object.
MessageFactory70 A factory for creating SOAPMessage objects.
MimeHeader73 An object that stores a MIME header name and its value.
MimeHeaders75 A container for MimeHeader objects, which represent the MIME headers present in
a MIME part of a message.
59
Package javax.xml.soap
Class Summary
SOAPConnection87 A connection that a client can use for sending messages directly to a remote party (rep-
resented by a URL, for instance) without using a messaging provider.
SOAPMessage110 The root class for all SOAP messages.
SOAPPart116 The container for the SOAP-specific portion of a SOAPMessage object.
Exceptions
SOAPException99 An exception that signals that a SOAP exception has occurred.
60
Package javax.xml.soap
javax.xml.soap
AttachmentPart
Declaration
Description
A single attachment to a SOAPMessage object. A SOAPMessage object may contain zero, one, or many
AttachmentPart objects. Each AttachmentPart object consists of two parts, application-specific con-
tent and associated MIME headers. The MIME header consists of name/value pairs that could be used identify
and describe the content.
An AttachmentPart object must conform to certain standards.
1. It must conform to MIME [RFC2045] standards (http://www.ietf.org/rfc/rfc2045.txt)
2. It MUST contain content
3. The header portion MUST include the following header:
• Content-Type
This header identifies the type of data in the content of an AttachmentPart object and MUST conform
to [RFC2045]. The following is an example of a Content-Type header:
Content-Type: application/xml
The following line of code, in which ap is an AttachmentPart object, sets the header in the exam-
ple.
ap.setMimeHeader(“Content-Type”, “application/xml”);
There are no restrictions on the content portion of an AttachmentPart object. The content may be any-
thing from a simple plain text object to a complex XML document or image file.
An AttachmentPart object is created with the method SOAPMessage.createAttachmentPart.
After setting its MIME headers, the AttachmentPart object is added to the message that created it with the
method SOAPMessage.addAttachmentPart.
The following code fragment, in which m is a SOAPMessage object and contentStringl is a String,
creates an instance of AttachmentPart, sets the AttachmentPart object with some content and header
information, and adds the AttachmentPart object to the SOAPMessage object.
AttachmentPart ap1 = m.createAttachmentPart();
ap1.setContent(contentString1, “text/plain”);
m.addAttachmentPart(ap1);
For “text/plain”, “text/html” and “text/xml” MIME content-types, the DataContentHandler object does
the conversions to and from the Java types corresponding to the MIME types. For other MIME types, you can
pass an InputStream object that contains the content data.
The following code fragment creates and adds a second AttachmentPart instance to the same message.
jpegData is a binary byte buffer representing the jpeg file.
61
Package javax.xml.soap
To retrieve the contents and header from an AttachmentPart object, the getContent method can be
used. Depending on the DataContentHandler objects present, the returned Object can either be a typed
Java object corresponding to the MIME type or an InputStream object that contains the content as bytes.
The method clearContent removes all the content from an AttachmentPart object but does not affect
its header information.
ap1.clearContent();
Member Summary
Constructors
public AttachmentPart()63
Methods
public abstract void addMimeHeader(String, String)63
Adds a MIME header with the specified name and value to this AttachmentPart
object.
public abstract void clearContent()64
Clears out the content of this AttachmentPart object.
public abstract Itera- getAllMimeHeaders()64
tor Retrieves all the headers for this AttachmentPart object as an iterator over the
MimeHeader objects.
public abstract Object getContent()64
Gets the content of this AttachmentPart object as a Java object.
public String getContentId()64
Gets the value of the MIME header whose name is “Content-Id”.
public String getContentLocation()64
Gets the value of the MIME header “Content-Location”.
public String getContentType()65
Gets the value of the MIME header “Content-Type”.
public abstract DataH- getDataHandler()65
andler Gets the DataHandler object for this AttachmentPart object.
public abstract Itera- getMatchingMimeHeaders(String[])65
tor Retrieves all MimeHeader objects that match a name in the given array.
public abstract getMimeHeader(String)65
String[] Gets all the values of the header identified by the given String.
public abstract Itera- getNonMatchingMimeHeaders(String[])65
tor Retrieves all MimeHeader objects whose name does not match a name in the given
array.
public abstract int getSize()66
Returns the number of bytes in this AttachmentPart object.
public abstract void removeAllMimeHeaders()66
Removes all the MIME header entries.
public abstract void removeMimeHeader(String)66
Removes all MIME headers that match the given name.
public abstract void setContent(Object, String)66
Sets the content of this attachment part to that of the given Object and sets the value
of the Content-Type header to the given type.
public void setContentId(String)66
Sets the MIME header “Content-Id” with the given value.
62
Package javax.xml.soap
Member Summary
public void setContentLocation(String)67
Sets the MIME header “Content-Location” with the given value.
public void setContentType(String)67
Sets the MIME header “Content-Type” with the given value.
public abstract void setDataHandler(DataHandler)67
Sets the given DataHandler object as the data handler for this Attachment-
Part object.
public abstract void setMimeHeader(String, String)67
Changes the first header entry that matches the given name to the given value, adding
a new header if no existing header matches.
Constructors
AttachmentPart()
public AttachmentPart()
Methods
addMimeHeader(String, String)
63
Package javax.xml.soap
clearContent()
getAllMimeHeaders()
getContent()
getContentId()
getContentLocation()
64
Package javax.xml.soap
getContentType()
getDataHandler()
getMatchingMimeHeaders(String[])
getMimeHeader(String)
getNonMatchingMimeHeaders(String[])
65
Package javax.xml.soap
getSize()
removeAllMimeHeaders()
removeMimeHeader(String)
setContent(Object, String)
setContentId(String)
66
Package javax.xml.soap
setContentLocation(String)
setContentType(String)
setDataHandler(DataHandler)
setMimeHeader(String, String)
67
Package javax.xml.soap
javax.xml.soap
Detail
Declaration
Description
A container for DetailEntry objects. DetailEntry objects give detailed error information that is applica-
tion-specific and related to the Body element.
A Detail object is part of a SOAPFault object. It can be retrieved using the method SOAPFault.get-
Detail.
Member Summary
Methods
public DetailEntry addDetailEntry(DetailEntry)68
Adds the given DetailEntry object to this Detail object.
public Iterator getDetailEntries()68
Gets a list of the detail entries in this Detail object.
Methods
addDetailEntry(DetailEntry)
getDetailEntries()
68
Package javax.xml.soap
javax.xml.soap
DetailEntry
Declaration
Description
The content for a Detail object, giving details for a SOAPFault object. A DetailEntry object, which
carries information about errors related to the Body element, is application-specific.
69
Package javax.xml.soap
javax.xml.soap
MessageFactory
Declaration
Description
A factory for creating SOAPMessage objects.
A JAXM client performs the following steps to create a message.
• Creates a MessageFactory object from a ProviderConnection object (con in the following line
of code).
MessageFactory mf = con.createMessageFactory();
It is also possible to create a MessageFactory object using the method newInstance, as shown in the fol-
lowing line of code.
MessageFactory mf = MessageFactory.newInstance();
This method is useful for clients that do not have a messaging provider and thus will not have a Provider-
Connection object from which to create a MessageFactory object.
Member Summary
Constructors
public MessageFactory()71
Methods
public abstract SOAP- createMessage()71
Message Creates a new SOAPMessage object with all the “standard” message header infor-
mation.
public abstract SOAP- createMessage(MimeHeaders, InputStream)71
Message Internalizes the contents of the given InputStream object into a new SOAPMes-
sage object and returns the SOAPMessage object.
public static Message- newInstance()72
Factory Creates a new MessageFactory object that is an instance of the default implemen-
tation.
70
Package javax.xml.soap
Constructors
MessageFactory()
public MessageFactory()
Methods
createMessage()
createMessage(MimeHeaders, InputStream)
71
Package javax.xml.soap
Throws:
IOException - if there is a problem in reading data from the input stream
SOAPException99 - if the message is invalid
newInstance()
72
Package javax.xml.soap
javax.xml.soap
MimeHeader
Declaration
Description
An object that stores a MIME header name and its value. One or more MimeHeader objects may be contained
in a MimeHeaders object.
Member Summary
Constructors
public MimeHeader(String, String)74
Constructs a MimeHeader object initialized with the given name and value.
Methods
public String getName()74
Returns the name of this MimeHeader object.
public String getValue()74
Returns the value of this MimeHeader object.
73
Package javax.xml.soap
Constructors
MimeHeader(String, String)
Methods
getName()
getValue()
74
Package javax.xml.soap
javax.xml.soap
MimeHeaders
Declaration
Description
A container for MimeHeader objects, which represent the MIME headers present in a MIME part of a mes-
sage.
This class is used primarily when an application wants to retrieve specific attachments based on certain MIME
headers and values (see SOAPMessage.getAttachments). This class will most likely be used by imple-
mentations of AttachmentPart and other MIME dependent parts of the JAXM API.
Member Summary
Constructors
public MimeHeaders()76
Constructs a default MimeHeaders object initialized with an empty Vector
object.
Methods
public void addHeader(String, String)76
Adds a MimeHeader object with the specified name and value to this Mime-
Headers object’s list of headers.
public Iterator getAllHeaders()76
Returns all the headers in this MimeHeaders object.
public String[] getHeader(String)76
Returns all of the values for the specified header as an array of String objects.
public Iterator getMatchingHeaders(String[])77
Returns all the MimeHeader objects whose name matches a name in the given array
of names.
public Iterator getNonMatchingHeaders(String[])77
Returns all of the MimeHeader objects whose name does not match a name in the
given array of names.
public void removeAllHeaders()77
Removes all the header entries from this MimeHeaders object.
public void removeHeader(String)77
Remove all MimeHeader objects whose name matches the the given name.
public void setHeader(String, String)77
Replaces the current value of the first header entry whose name matches the given
name with the given value, adding a new header if no existing header name matches.
75
Package javax.xml.soap
Constructors
MimeHeaders()
public MimeHeaders()
Constructs a default MimeHeaders object initialized with an empty Vector object.
Methods
addHeader(String, String)
getAllHeaders()
getHeader(String)
76
Package javax.xml.soap
Parameters:
name - the name of the header for which values will be returned
Returns: a String array with all of the values for the specified header
getMatchingHeaders(String[])
getNonMatchingHeaders(String[])
removeAllHeaders()
removeHeader(String)
setHeader(String, String)
77
Package javax.xml.soap
Parameters:
name - a String with the name of the header for which to search
value - a String with the value that will replace the current value of the specified header
Throws:
IllegalArgumentException - if there was a problem in the mime header name or the value
being set
78
Package javax.xml.soap
javax.xml.soap
Name
Declaration
Description
A representation of an XML name. This interface provides methods for getting the local and namespace-quali-
fied names and also for getting the prefix associated with the namespace for the name. It is also possible to get
the URI of the namespace.
The following is an example of a namespace declaration in an element.
WOMBAT:GetLastTradePrice xmlns:jaxm=“http://www.wombat.org/trader”
(“xmlns” stands for XML “namespace”.) The following shows what the methods in the Name interface will
return.
• getQualifiedName will return “prefix:LocalName” = “WOMBAT:GetLastTradePrice”
• getURI will return “http://www.wombat.org/trader”
• getLocalName will return “GetLastTracePrice”
• getPrefix will return “WOMBAT”
XML namespaces are used to disambiguate SOAP identifiers from application-specific identifiers.
Name objects are created using SOAPEnvelope.createName.
Member Summary
Methods
public String getLocalName()80
Gets the local name part of the XML name that this Name object represents.
public String getPrefix()80
Returns the prefix associated with the namespace for the XML name that this Name
object represents.
public String getQualifiedName()80
Gets the namespace-qualified name of the XML name that this Name object repre-
sents.
public String getURI()80
Returns the URI of the namespace for the XML name that this Name object repre-
sents.
79
Package javax.xml.soap
Methods
getLocalName()
getPrefix()
getQualifiedName()
getURI()
80
Package javax.xml.soap
javax.xml.soap
Node
Declaration
Description
A representation of a node (element) in a DOM representation of an XML document that provides some tree
manipulation methods. This interface provides methods for getting the value of a node, for getting and setting
the parent of a node, and for removing a node.
Member Summary
Methods
public void detachNode()81
Removes this Node object from the tree.
public SOAPElement getParentElement()82
Returns the parent element of this Node object.
public String getValue()82
Returns the the value of the immediate child of this Node object if a child exists and
its value is text.
public void recycleNode()82
Notifies the implementation that this Node object is no longer being used by the
application and that the implementation is free to reuse this object for nodes that may
be created later.
public void setParentElement(SOAPElement)82
Sets the parent of this Node object to the given SOAPElement object.
Methods
detachNode()
81
Package javax.xml.soap
getParentElement()
getValue()
recycleNode()
setParentElement(SOAPElement)
82
Package javax.xml.soap
javax.xml.soap
SOAPBody
Declaration
Description
An object that represents the contents of the SOAP body element in a SOAP message. A SOAP body element
consists of XML data that affects the way the application-specific content is processed.
A SOAPBody object contains SOAPBodyElement objects, which have the content for the SOAP body. A
SOAPFault object, which carries status and/or error information, is an example of a SOAPBodyElement
object.
Member Summary
Methods
public SOAPBodyEle- addBodyElement(Name)84
ment Creates a new SOAPBodyElement object with the specified name and adds it to this
SOAPBody object.
public SOAPFault addFault()84
Creates a new SOAPFault object and adds it to this SOAPBody object.
public SOAPFault getFault()84
Returns the SOAPFault object in this SOAPBody object.
public boolean hasFault()84
Indicates whether a SOAPFault object exists in this SOAPFault object.
83
Package javax.xml.soap
Methods
addBodyElement(Name)
addFault()
getFault()
hasFault()
84
Package javax.xml.soap
Returns: true if a SOAPFault object exists in this SOAPBody object; false otherwise
85
Package javax.xml.soap
javax.xml.soap
SOAPBodyElement
Declaration
Description
A SOAPBodyElement object represents the contents in a SOAPBody object. The SOAPFault interface is a
SOAPBodyElement object that has been defined.
A new SOAPBodyElement object can be created and added to a SOAPBody object with the SOAPBody
method addBodyElement. In the following line of code, sb is a SOAPBody object, and myName is a Name
object.
SOAPBodyElement sbe = sb.addBodyElement(myName);
86
Package javax.xml.soap
javax.xml.soap
SOAPConnection
Declaration
Description
A connection that a client can use for sending messages directly to a remote party (represented by a URL, for
instance) without using a messaging provider. A standalone client uses a SOAPConnection object rather than
a ProviderConnection object.
A client can obtain a SOAPConnection object simply by calling the static method SOAPMessage.new-
Instance.
A SOAPConnection object can be used to send messages directly to a URL following the request/response
paradigm. That is, messages are sent using the method call, which sends the message and then waits until it
gets a reply.
Member Summary
Constructors
public SOAPConnection()88
Methods
public abstract SOAP- call(SOAPMessage, Endpoint)88
Message Sends the given message to the specified endpoint and blocks until it has returned the
response.
public abstract void close()88
Closes this SOAPConntection object.
public static SOAPCon- newInstance()88
nection Creates a new SOAPConnection object.
87
Package javax.xml.soap
Constructors
SOAPConnection()
public SOAPConnection()
Methods
call(SOAPMessage, Endpoint)
close()
newInstance()
88
Package javax.xml.soap
javax.xml.soap
SOAPConstants
Declaration
Description
This interface defines a number of constants pertaining to the SOAP 1.1 protocol.
Member Summary
Fields
public static final URI_NS_SOAP_ENCODING89
The namespace identifier for the SOAP encoding (see section 5 of the SOAP 1.1 spec-
ification).
public static final URI_NS_SOAP_ENVELOPE89
The namespace identifier for the SOAP envelope.
public static final URI_SOAP_ACTOR_NEXT89
The URI identifying the first application processing a SOAP request as the intended
actor for a SOAP header entry (see section 4.2.2 of the SOAP 1.1 specification).
Fields
URI_NS_SOAP_ENCODING
URI_NS_SOAP_ENVELOPE
URI_SOAP_ACTOR_NEXT
89
Package javax.xml.soap
javax.xml.soap
SOAPElement
Declaration
Description
An object representing the contents in a SOAPBody object, the contents in a SOAPHeader object, the content
that can follow the SOAPBody object in a SOAPEnvelope object, or what can follow the detail element in a
SOAPFault object. It is the base class for all of the classes that represent the SOAP objects as defined in the
SOAP specification.
Member Summary
Methods
public SOAPElement addAttribute(Name, String)91
Adds an attribute with the specified name and value to this SOAPElement object.
public SOAPElement addChildElement(Name)91
Creates a new SOAPElement object initialized with the given Name object and adds
the new element to this SOAPElement object.
public SOAPElement addChildElement(String)92
Creates a new SOAPElement object initialized with the given String object and
adds the new element to this SOAPElement object.
public SOAPElement addChildElement(String, String)92
Creates a new SOAPElement object initialized with the specified local name and
prefix and adds the new element to this SOAPElement object.
public SOAPElement addChildElement(String, String, String)92
Creates a new SOAPElement object initialized with the specified local name, prefix,
and URI and adds the new element to this SOAPElement object.
public SOAPElement addNamespaceDeclaration(String, String)93
Adds a namespace declaration with the specified prefix and URI to this SOAPEle-
ment object.
public SOAPElement addTextNode(String)93
Creates a new Text object initialized with the text and adds it to this SOAPElement
object.
public Iterator getAllAttributes()93
Returns an iterator over all of the attribute names in this SOAPElement object.
public String getAttributeValue(Name)93
Returns the value of the attribute with the specified name.
public Iterator getChildElements()94
Returns an iterator over all the immediate content of this element.
public Iterator getChildElements(Name)94
Returns an iterator over all the child elements with the specified name.
90
Package javax.xml.soap
Member Summary
public Name getElementName()94
Returns the name of this SOAPElement object.
public String getEncodingStyle()94
Returns the encoding style for this SOAPElement object.
public Iterator getNamespacePrefixes()94
Returns an iterator of namespace prefixes.
public String getNamespaceURI(String)94
Returns the URI of the namespace that has the given prefix.
public boolean removeAttribute(Name)95
Removes the attribute with the specified name.
public boolean removeNamespaceDeclaration(String)95
Removes the namespace declaration corresponding to the given prefix.
public void setEncodingStyle(String)95
Sets the encoding style for this SOAPElement object to one specified.
Methods
addAttribute(Name, String)
addChildElement(Name)
91
Package javax.xml.soap
Parameters:
name - a Name object with the XML name for the new element
Returns: the new SOAPElement object that was created
Throws:
SOAPException99 - if there is an error in creating the SOAPElement object
addChildElement(String)
addChildElement(String, String)
92
Package javax.xml.soap
addNamespaceDeclaration(String, String)
addTextNode(String)
getAllAttributes()
getAttributeValue(Name)
93
Package javax.xml.soap
getChildElements()
getChildElements(Name)
getElementName()
getEncodingStyle()
getNamespacePrefixes()
getNamespaceURI(String)
94
Package javax.xml.soap
Parameters:
prefix - a String giving the prefix of the namespace for which to search
Returns: a String with the uri of the namespace that has the given prefix
removeAttribute(Name)
removeNamespaceDeclaration(String)
setEncodingStyle(String)
95
Package javax.xml.soap
javax.xml.soap
SOAPEnvelope
Declaration
Description
The container for the SOAPHeader and SOAPBody portions of a SOAPPart object.
A client can access the SOAP Header and SOAP Body of a SOAPEnvelope object by calling the methods
SOAPEnvelope.getHeader and SOAPEnvelope.getBody. The following lines of code, in which se
is a SOAPEnvelope object, retrieve the SOAP header and SOAP body.
SOAPHeader sh = se.getHeader();
SOAPBody sb = se.getBody();
To create a SOAPHeader object, a client can use the method SOAPPart.getEnvelope(true). The fol-
lowing code fragment, in which m is a SOAPMessage object, gets a SOAPPart object and uses it to create a
new SOAPHeader object. Note that the method getEnvelope returns a SOAPEnvelope object, but when
the method is passed the argument true, it also creates a SOAPHeader object and adds it to the SOAPEnve-
lope object.
SOAPPart sp = m.getSOAPPart();
SOAPEnvelope se = sp.getEnvelope(true);
Ihe SOAPBody object is a mandatory part of the SOAPEnvelope object and is created by the infrastructure.
Member Summary
Methods
public Name createName(String)97
Creates a new Name object initialized with the given local name.
public Name createName(String, String)97
Creates a new Name object initialized with the given local name and prefix.
public Name createName(String, String, String)98
Creates a new Name object initialized with the given local name, prefix, and URI.
public SOAPBody getBody()98
Returns the SOAPBody object associated with this SOAPEnvelope object.
public SOAPHeader getHeader()98
Returns the SOAPHeaderobject, if one has been set, for this SOAPEnvelope
object.
96
Package javax.xml.soap
Methods
createName(String)
createName(String, String)
97
Package javax.xml.soap
getBody()
getHeader()
98
Package javax.xml.soap
javax.xml.soap
SOAPException
Declaration
Description
An exception that signals that a SOAP exception has occurred. A SOAPException object may contain a
String that gives the reason for the exception, an embedded Throwable object, or both. This class provides
methods for retrieving reason messages and for retrieving the embedded Throwable object.
Typical reasons for throwing a SOAPException object are problems such as difficulty setting a header, not
being able to send a message, and not being able to get a connection with the provider. Reasons for embedding
a Throwable object include problems such as input/output errors or a parsing problem, such as an error in
parsing a header.
Member Summary
Constructors
public SOAPException()100
Constructs a SOAPException object with no reason or embedded Throwable
object.
public SOAPException(String)100
Constructs a SOAPException object with the given String as the reason for the
exception being thrown.
public SOAPException(String, Throwable)100
Constructs a SOAPException object with the given String as the reason for the
exception being thrown and the given Throwable object as an embedded exception.
public SOAPException(Throwable)101
Constructs a SOAPException object initialized with the given Throwable object.
Methods
public Throwable getCause()101
Returns the Throwable object embedded in this SOAPException if there is one.
public String getMessage()101
Returns the detail message for this SOAPException object.
99
Package javax.xml.soap
Member Summary
public synchronized initCause(Throwable)101
Throwable Initializes the cause field of this SOAPException object with the given Throw-
able object.
Constructors
SOAPException()
public SOAPException()
Constructs a SOAPException object with no reason or embedded Throwable object.
SOAPException(String)
SOAPException(String, Throwable)
100
Package javax.xml.soap
SOAPException(Throwable)
Methods
getCause()
getMessage()
initCause(Throwable)
101
Package javax.xml.soap
102
Package javax.xml.soap
javax.xml.soap
SOAPFault
Declaration
Description
An object that contains error and/or status information within a SOAP message. A SOAPFault object is used
as the value for a field in the SOAPBody interface.
Member Summary
Methods
public Detail getDetail()104
Returns the detail element for this SOAPFault object.
public String getFaultCode()104
Gets the fault code for this SOAPFault object.
public String getFaultString()104
Gets the fault string for this SOAPFault object.
public void setFaultCode(String)104
Sets this SOAPFault object with the given fault code.
public void setFaultString(String)104
Sets the fault string for this SOAPFault object to the given string.
103
Package javax.xml.soap
Methods
getDetail()
getFaultCode()
getFaultString()
setFaultCode(String)
setFaultString(String)
104
Package javax.xml.soap
javax.xml.soap
SOAPHeader
Declaration
Description
A SOAPHeader object represents the contents of the SOAP header element. A SOAP header element consists
of XML data that affects the way the application-specific content is processed by the message handler. For
example, transaction semantics, authentication information, and so on, can be specified as the content of a
SOAPHeader object.
To create a SOAPHeader object, a client can use the method SOAPPart.getEnvelope(true). The fol-
lowing code fragment, in which m is a SOAPMessage object, gets a SOAPPart object and uses it to create a
new SOAPHeader object. Note that the method getEnvelope returns a SOAPEnvelope object, but when
the method is passed the argument true, it also creates a SOAPHeader object and adds it to the SOAPEnve-
lope object.
SOAPPart sp = m.getSOAPPart();
SOAPEnvelope se = sp.getEnvelope(true);
A SOAPHeader object can have only SOAPHeaderElement objects as its immediate children. The method
addHeaderElement creates a new HeaderElement object and adds it to the SOAPHeader object.
Member Summary
Methods
public SOAPHeaderEle- addHeaderElement(Name)106
ment Creates a new SOAPHeaderElement object initialized with the specified name and
adds it to this SOAPHeader object.
public Iterator examineHeaderElements(String)106
Returns a list of all the SOAPHeaderElement objects in this SOAPHeader object
that have the the specified actor.
public Iterator extractHeaderElements(String)107
Returns a list of all the SOAPHeaderElement objects in this SOAPHeader object
that have the the specified actor and detaches them from this SOAPHeader object.
105
Package javax.xml.soap
Methods
addHeaderElement(Name)
examineHeaderElements(String)
106
Package javax.xml.soap
extractHeaderElements(String)
107
Package javax.xml.soap
javax.xml.soap
SOAPHeaderElement
Declaration
Description
An object representing the contents in the SOAP header part of the SOAP envelope. The immediate children of
a SOAPHeader object can be represented only as SOAPHeaderElement objects.
A SOAPHeaderElement object can have other SOAPElement objects as its children.
Member Summary
Methods
public String getActor()109
Returns the uri of the actor associated with this SOAPHeaderElement object.
public boolean getMustUnderstand()109
Returns the mustUnderstand attribute associated with this SOAPHeaderElement
object.
public void setActor(String)109
Sets the actor associated with this SOAPHeaderElement object to the specified
actor.
public void setMustUnderstand(boolean)109
Sets the mustUnderstand attribute for this SOAPHeaderElement object to be on or
off.
108
Package javax.xml.soap
Methods
getActor()
getMustUnderstand()
setActor(String)
setMustUnderstand(boolean)
109
Package javax.xml.soap
javax.xml.soap
SOAPMessage
Declaration
Description
The root class for all SOAP messages. As transmitted on the “wire”, a SOAP message is an XML document or
a MIME message whose first body part is an XML/SOAP document.
A SOAPMessage object consists of a SOAP part and optionally one or more attachment parts. The SOAP part
for a SOAPMessage object is a SOAPPart object, which contains information used for message routing and
identification. The SOAP part can be retrieved by calling the method SOAPMessage.getSOAPPart().
In addition to the mandatory SOAPPart object, a SOAPMessage object may contain zero or more
AttachmentPart objects, each of which contains application-specific data. The SOAPMessage interface
provides methods for creating AttachmentPart objects and also for adding them to a SOAPMessage
object. A party that has received a SOAPMessage object can examine its contents by retrieving individual
attachment parts.
Unlike the rest of a SOAP message, an attachment is not required to be in XML format and can therefore be
anything from simple text to an image file. Consequently, any message content that is not in XML format must
be in an AttachmentPart object.
A MessageFactory object creates new SOAPMessage objects.
Member Summary
Constructors
public SOAPMessage()112
Methods
public abstract void addAttachmentPart(AttachmentPart)112
Adds the given AttachmentPart object to this SOAPMessage object.
public abstract int countAttachments()112
Gets a count of the number of attachments in this message.
public abstract createAttachmentPart()112
AttachmentPart Creates a new empty AttachmentPart object.
public AttachmentPart createAttachmentPart(DataHandler)112
Creates an AttachmentPart object and populates it using the given Data-
Handler object.
public AttachmentPart createAttachmentPart(Object, String)113
Creates an AttachmentPart object and populates it with the specified data of the
specified content type.
public abstract Itera- getAttachments()113
tor Retrieves all the AttachmentPart objects that are part of this SOAPMessage
object.
110
Package javax.xml.soap
Member Summary
public abstract Itera- getAttachments(MimeHeaders)113
tor Retrieves all the AttachmentPart objects that have header entries that match the
specified headers.
public abstract String getContentDescription()113
Retrieves a description of this SOAPMessage object’s content.
public abstract Mime- getMimeHeaders()113
Headers Returns all the transport-specific MIME headers for this SOAPMessage object in a
transport-independent fashion.
public abstract SOAP- getSOAPPart()114
Part Gets the SOAP part of this SOAPMessage object.
public abstract void removeAllAttachments()114
Removes all AttachmentPart objects that have been added to this SOAPMes-
sage object.
public abstract void saveChanges()114
Updates this SOAPMessage object with all the changes that have been made to it.
public abstract bool- saveRequired()114
ean Indicates whether this SOAPMessage object has had the method saveChanges
called on it.
public abstract void setContentDescription(String)114
Sets the description of this SOAPMessage object’s content with the given descrip-
tion.
public abstract void writeTo(OutputStream)115
Writes this SOAPMessage object to the given output stream.
111
Package javax.xml.soap
Constructors
SOAPMessage()
public SOAPMessage()
Methods
addAttachmentPart(AttachmentPart)
countAttachments()
createAttachmentPart()
createAttachmentPart(DataHandler)
112
Package javax.xml.soap
Throws:
IllegalArgumentException - if there was a problem with the specified dataHandler
createAttachmentPart(Object, String)
getAttachments()
getAttachments(MimeHeaders)
getContentDescription()
getMimeHeaders()
113
Package javax.xml.soap
getSOAPPart()
removeAllAttachments()
saveChanges()
saveRequired()
setContentDescription(String)
114
Package javax.xml.soap
writeTo(OutputStream)
115
Package javax.xml.soap
javax.xml.soap
SOAPPart
Declaration
Description
The container for the SOAP-specific portion of a SOAPMessage object. The SOAPPart object is a MIME
part containing the SOAPEnvelope object, which in turn contains the SOAPBody object and the SOAP-
Header object if there is one.
A client can access the SOAP Envelope of a SOAPMessage object by calling the method
SOAPMessage.getSOAPPart. The following line of code, in which m is a SOAPMessage object, retrieves
the SOAP part of a message.
SOAPPart sp = m.getSOAPPart();
sp.getEnvelope can then be used to retrieve the SOAP Envelope itself.
Member Summary
Constructors
public SOAPPart()117
Methods
public abstract void addMimeHeader(String, String)117
Creates a MIMEHeader object with the specified name and value and adds it to this
SOAPPart object.
public abstract Itera- getAllMimeHeaders()118
tor Retrieves all the headers for this SOAPPart object as an iterator over the Mime-
Header objects.
public abstract Source getContent()118
Returns the content of the SOAPEnvelope as a JAXP Source object.
public String getContentId()118
Retrieves the value of the MIME header whose name is Content-Id.
public String getContentLocation()118
Retrieves the value of the MIME header whose name is Content-Location.
public abstract SOAP- getEnvelope()118
Envelope Gets the SOAP envelope associated with this SOAPPart object.
public abstract SOAP- getEnvelope(boolean)119
Envelope Gets the SOAPEnvelope object associated with this SOAPPart object and creates
a new SOAPHeader object and sets it on this SOAPEnvelope object if the argu-
ment passed to this method is true.
public abstract Itera- getMatchingMimeHeaders(String[])119
tor Retrieves all MimeHeader objects that match a name in the given array.
public abstract getMimeHeader(String)119
String[] Gets all the values of the MimeHeader object in this SOAPPart object that is iden-
tified by the given String.
116
Package javax.xml.soap
Member Summary
public abstract Itera- getNonMatchingMimeHeaders(String[])119
tor Retrieves all MimeHeader objects whose name does not match a name in the given
array.
public abstract void removeAllMimeHeaders()120
Removes all the MimeHeader objects for this SOAPEnvelope object.
public abstract void removeMimeHeader(String)120
Removex all MIME headers that match the given name.
public abstract void setContent(Source)120
Sets the content of the SOAPEnvelope object with the data from the given Source
object.
public void setContentId(String)120
Sets the value of the MIME header named Content-Id to the given String.
public void setContentLocation(String)120
Sets the value of the MIME header Content-Location to the given String.
public abstract void setMimeHeader(String, String)121
Changes the first header entry that matches the given header name so that its value is
the given value, adding a new header if no existing header is a match.
Constructors
SOAPPart()
public SOAPPart()
Methods
addMimeHeader(String, String)
117
Package javax.xml.soap
Throws:
IllegalArgumentException - if there was a problem with the specified mime header name or
value
getAllMimeHeaders()
getContent()
getContentId()
getContentLocation()
getEnvelope()
118
Package javax.xml.soap
getEnvelope(boolean)
getMatchingMimeHeaders(String[])
getMimeHeader(String)
getNonMatchingMimeHeaders(String[])
119
Package javax.xml.soap
Returns: all of the MIME headers in this SOAPPart object except those that match one of the names in
the given array. The nonmatching MIME headers are returned as an Iterator object.
removeAllMimeHeaders()
removeMimeHeader(String)
setContent(Source)
setContentId(String)
setContentLocation(String)
120
Package javax.xml.soap
Throws:
IlleglalArgumentException - if there is a problem in setting the content location.
See Also: getContentLocation()118
setMimeHeader(String, String)
121
Package javax.xml.soap
javax.xml.soap
Text
Declaration
Description
A representation of a node whose value is text. A Text object may represent text that is content or text that is a
comment.
Member Summary
Methods
public boolean isComment()122
Retrieves whether this Text object represents a comment.
Methods
isComment()
122
C H A P T E R JAXM.6
References
■
http://search.ietf.org/internet-drafts/draft-ietf-trade-iotp2-req-00.txt
■
http://search.ietf.org/internet-drafts/draft-ietf-ediint-as1-13.txt
• SOAP
■
http://www.w3.org/TR/SOAP
■
http://www.w3.org/TR/SOAP-attachments
■
http://java.sun.com/products/javabeans/glasgow/jaf.html
■
http://java.sun.com/xml/xml_jaxp.html
123
124 REFERENCES