Configure web service client-preferred port mappings using wsadmin.sh
A client port type can be configured with ports that have different qualities of service. Use the WebServicesClientBindPreferredPort command-line option to specify which port we want to use.
If we have not deployed the EAR file yet, we need to have it ready or already deployed to the application server.
For each port type configured, one or more ports are available that implement that port type. When a web service client calls a getPort method, the preferred port mapping determines which port to use. This determination occurs when more than one port can satisfy the getPort method call, such as, a getPort call that specifies the port type, but not the port. For example, suppose the web service client is configured to use both Java Message Service (JMS) and an HTTP implementation. During installation or management, we can use the WebServicesClientBindPreferredPort command to configure the preferred port of the application to use the transport of choice.
To configure the preferred port mapping with the wsadmin tool proceed with the following steps:
Tasks
- Launch a scripting command. To learn more, see the starting the wsadmin scripting client information.
- Configure web service client-preferred port mappings.
To use the existing listener port instead of using or creating a new activation specification, determine whether the EJB JAR version is earlier than 2.1. The system automatically creates and uses an activation specification when we specify the -usedefaultbindings option to deploy an application. If an activation specification exists, the system ignores the listener port, and instead uses the activation specification. To deploy an application with an EJB JAR version greater than or equal to 2.1 using the defined listener ports instead of a new activation specification, set the com.ibm.websphere.management.application.dfltbndng.mdb.preferexisting system property to true in the wsadmin.properties file in the properties directory of the profile of interest.
Use the install, installInteractive, edit or editInteractive options to configure the web service client-preferred port mappings, as the following syntax demonstrates:
- Use Jython:
AdminApp.install('app_name', '[-usedefaultbindings -deployejb -WebServicesClientBindPreferredPort {{module_name EJB_name Web_service port_type port_name]')- Use Jacl:
$AdminApp install app_name {-usedefaultbindings -deployejb -WebServicesClientBindPreferredPort {{module_name EJB_name Web_service port_type port_name}}The example shows multiple modules and URL endpoints, because we can edit multiple URL fragments where:
- app_name is the application name, for example MultiEjbJar.ear
- EJB_name is the name of the enterprise bean module that is not a web module, for example, Exchange
- module_name is the module name, for example ejbclientonly.jar
- Web_service is the name of the web service, for example service/StockQuoteService
- port_type is the port type information, for example {http://stock.multiejbjar.test.wsfvt.ws.ibm.com}StockQuote
- port_name is the port name, for example {http://stock.multiejbjar.test.wsfvt.ws.ibm.com}StockQuote
We have configured web service client-preferred port mappings with the wsadmin tool.
Example
The following example includes the application, module, Web service, port type and port information as it is written in the command line:$AdminApp install MultiEjbJar.ear {-WebServicesClientBindPreferredPort {{ejbclientonly.jar Exchange service/StockQuoteService {http://stock.multiejbjar.test.wsfvt.ws.ibm.com}StockQuote {http://stock.multiejbjar.test.wsfvt.ws.ibm.com}StockQuote}...}}The port type information that drives the creation of the WebServicesClientBindPreferredPort option data resides in the client WSDL file. Because valid preferred port mappings are restricted to ports that implement the interface of the port type, validation requires the implementation type of each port. The client WSDL file must be accessed to determine both the type and the implementation information.
The client WSDL file name is in the ServiceRef attribute of the web service client deployment descriptor. Depending on the module type and version, the client deployment descriptor is located in either the application-client.xml file; the web.xml file, or the ejb-jar.xml file. If we are using J2EE 1.3, the client deployment descriptor information is located in the webservices.xml file.
What to do next
Now we can finish any other configurations, start or restart the application, and verify expected behavior of the web service.
Web services client bindings Start the wsadmin scripting client Options for the AdminApp object install, installInteractive, edit, editInteractive, update, and updateInteractive commands