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 either by calling its constructor or by looking it up in a naming service. For information about creating administered objects for endpoints, see Using SOAP Administered Objects.
The following code uses a constructor to create a URLEndpoint:
myEndpoint = new URLEndpoint("http://somehost/myServlet");
If you are using a provider, the Message Factory creating the message includes the endpoint specification in the message header.
If you do not use a provider, you can specify the endpoint as a parameter to the SOAPConnection.call method, which you use to send a SOAP message.
If you are using an administered object to define an endpoint, note that it is possible to associate that administered object with multiple URLs--each URL, is capable of processing incoming SOAP messages. The code sample below associates the endpoint whose lookup name is myEndpoint with two URLs: http://www.myServlet1/ and http://www.myServlet2/.
imqobjmgr add -t e -l "cn=myEndpoint" -o "imqSOAPEndpointList=http://www.myServlet1/ http://www.myServlet2/" |
This syntax allows you to use a SOAP connection to publish a SOAP message to multiple endpoints. For additional information about the endpoint administered object, see Using SOAP Administered Objects.
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.