How to enable dynamic invocation of an endpoint with a
wired Web Service binding import.
Introduction
You can invoke services using
endpoints that are different to those specified in the import. For
Web Service bindings, you can specify a dynamic endpoint using a URL
that conforms to the Web services URI standard.
Figure 1. Illustration
of endpoint override by dynamic invocation, with wired import
You can create a mediation module that includes the
dynamic endpoint, by performing tasks in WebSphere® Integration Developer.
Programmatic override of endpoint addresses
You
can use the SCA public API to override the endpoint address. In the
following example code, the
uri value must be in
a valid Web services format.
epr = EndpointReferenceFactory.INSTANCE.createEndpointReference();
epr.setAddress(uri);
Service dynamicService = (Service) ServiceManager.INSTANCE.getService(refname, epr);
If
the URI has a prefix of
http:/, the address is interpreted
as a SOAP / HTTP endpoint. If the URI has a prefix of
jms:/,
the address is interpreted as a SOAP / JMS endpoint.
Creating a dynamic invocation with a Web Service endpoint
To
create a mediation module that includes the dynamic endpoint, perform
the following tasks:
- Create Mediation Module 1, containing a POJO wiring to Import.
- Create Mediation Module 2, containing Export 2 wiring to POJO
2.
- Create Mediation Module 3, containing Export 3 wiring to POJO
3.
- Configure the Import to route messages to Export 2.
- Check that Export 2 and Export 3 have the same port type.
- Deploy the three modules to the server.
Using dynamic invocation
Dynamic invocation
takes place when the POJO is invoked with Export 3 identified as the
endpoint in the message. The POJO extracts the endpoint from the message,
and identifies Export 3 as the endpoint, rather than the Export 2
endpoint specified in the original deployment. The POJO uses the SCA
Endpoint Reference API, and the reference wired to the Import, to
invoke the remote service specified by the endpoint in the message.
After the service is invoked, a response is returned to the POJO.
A
one-way invocation message works the same way as a two-way message,
except that no response message is returned.
A runtime exception
occurs when one of these conditions is true:
- The endpoint specified does not exist.
- The URL format and the import binding type are not compatible.
- The URI has invalid syntax.
- The URL starts with jms: but the import Web service binding is
not configured for SOAP/JMS processing.