SOAP messaging occurs when a SOAP message, produced by a message factory , is sent to an endpoint by way of a connection .
If you are working without a provider, you must do the following:
Create a SOAPConnectionFactory object.
Create a SOAPConnection object.
Create an Endpoint object that represents the message’s destination.
Create a MessageFactory object and use it to create a message.
Populate the message.
Send the message.
If you are working with a provider, you must do the following:
Create a ProviderConnectionFactory object.
Get a ProviderConnection object from the provider connection factory.
Get a MessageFactory object from the provider connection and use it to create a message.
Populate the message.
Send the message.
The following three sections describe endpoint, message factory, and connection objects in greater detail.
An endpoint identifies the final destination of a message. An endpoint is defined either by the Endpoint class (if you use a provider) or by the URLEndpoint class (if you don’t use a provider).)
You can initialize an endpoint by calling its constructor. The following code uses a constructor to create a URLEndpoint.
myEndpoint = new URLEndpoint("http://somehost/myServlet");
To address a message to an endpoint, specify the endpoint as a parameter to the SOAPConnection.call method, which you use to send a SOAP message.
You use a Message Factory to create a SOAP message.
To instantiate a message factory directly, use a statement like the following:
MessageFactory mf = MessageFactory.newInstance();
To send a SOAP message using SAAJ, you must obtain a SOAPConnection . You can also transport a SOAP message using Message Queue; for more information, see Integrating SOAP and Message Queue.
A SOAPConnection allows you to send messages directly to a remote party. You can obtain a SOAPConnection object simply by calling the static method SOAPConnectionFactory.newInstance(). Neither reliability nor security are guaranteed over this type of connection.