Network Deployment (Distributed operating systems), v8.0 > End-to-end paths > Web services
Implement JAX-RPC web services clients
We can develop web services clients based on the Web Services for Java EE specification and the JAX-RPC programming model.
IBM WAS supports the JAX-WS programming model and the Java API for XML-based RPC (JAX-RPC) programming model. JAX-WS is the next generation web services programming model extending the foundation provided by JAX-RPC. Using the strategic JAX-WS programming model, development of web services and clients is simplified through support of a standards-based annotations model. Although JAX-RPC and applications are still supported, take advantage of the easy-to-implement JAX-WS programming model to develop new web services applications and clients. bprac
Develop web services clients based on the JAX-RPC programming model
The web services client programming model provides the guidelines for accessing web services in a Java EE environment. We can develop web services clients based on the Web Services for Java EE specification and the Java API for XML-based remote procedure call (JAX-RPC) specification. WAS v8 supports EJB clients, Java EE application clients, JSP files and servlets that are based on JAX-RPC.
Managed and unmanaged JAX-RPC web services clients
WAS v8 supports both managed and unmanaged web services clients when using JAX-RPC:
- Managed clients
Web services for Java EE clients are defined by Java Specification Requirements (JSR) 109 and are managed clients because they run in a Java EE container. These clients are packaged as EAR files and contain components that act as service requesters. These components are comprised of a Java EE client application, a web component such as a servlet or JSP, or a session EJB. Web services managed clients use JSR 109 APIs and deployment information to look up and invoke a web service.
For the managed clients, the service look up is through Java Naming and Directory Interface (JNDI) lookup. Read about setting up UserName token Web Services Security, digital signature Web Services Security and Lightweight Third-Party Authentication (LTPA) token Web Services Security. The following code is an example of a context lookup that is JSR 109 compliant:
InitialContext ctx = new InitialContext(); FredsBankServiceLocator locator =(FredsBankService)ctx.lookup("java:comp/env/service/FredsBankService"); FredsBank fb = locator.getFredsBank(url); long balance = fb.getBalance();When you are instantiating a context lookup for a managed client, do not use new() method for the service locator. Here is an example that is not JSR 109 compliant (new ServiceLocator):
Properties prop = new Properties(); InitialContext ctx = new InitialContext(prop); FredsBankServiceLocator locator = new FredsBankServiceLocator(); FredsBank fb = locator.getFredsBank(url); long balance = fb.getBalance();Without the lookup() call, the client has no access to the deployment descriptor. For JAX-RPC web services, the Web Services Security configuration is in the web services deployment descriptor.
- Unmanaged clients
Java Platform, Standard Edition (Java SE 6) clients that use the JAX-RPC runtime environment to invoke web services and do not run in any Java EE container are known as unmanaged clients. A web services unmanaged client is a stand-alone Java client that can directly inspect a WSDL file and formulate the calls to the web service by using the JAX-RPC APIs directly. These clients are packaged as JAR files which do not contain any deployment information.
For a Java application to act as a web service client, a mapping between the WSDL file and the Java application must exist. For JAX-RPC web services, the mapping is defined by the JAX-RPC specification. We can use a Java component to implement a web service by specifying the component interface and binding information in the WSDL file and designing the application server infrastructure to accept the service request. This entire process is based on the Web Services for Java EE specification. The JAX-RPC specification defines the mapping between a WSDL file, Java code, and XML Schema types.
Procedure
- Obtain the WSDL document for the web service to access.
We can locate the WSDL from the services provider through email, through a Uniform Resource Locator (URL) or by looking it up in a Universal Description, Discovery and Integration (UDDI) registry.
- Develop client bindings from a WSDL file using the WSDL2Java command-line tool. The information needed to invoke the web service is generated, including the service endpoint interface and implementations, the generated service interface and the ibm-webservicesclient-bnd.xmi and ibm-webservicesclient-ext.xmi deployment descriptors.
- Complete the client implementation. Write your client application code used to invoke the web service.
See Chapter 4 of the JSR 109 specification. For a complete list of the supported standards and specifications, see the web services specifications and API documentation.
If an application creates a number of threads in the JSR 109 client, the metadata (including the WAS configuration) is not copied to the thread, and the Global Security Handler is not called.
We can review the JAX-RPC-based web services sample, GetQuote client, in the WebServicesSamples application that is available for download.
To learn more, see the v8.0 Samples information.
- (Optional) Assemble a web services-enabled client Java archive (JAR) file into an EAR file. Complete this step if you are developing a managed JAX-RPC web services client that runs in the Java EE client container.
- (Optional) Assemble a web services-enabled client WAR file into an EAR file. Complete this step if you are developing a managed JAX-RPC web services client that runs in the Java EE client container.
- (Optional) Configure the client deployment descriptor. Complete this step if you are developing a managed JAX-RPC client.
- (Optional) Configure the ibm-webservicesclient-bnd.xmi deployment descriptor. Complete this step if you are deploying a managed JAX-RPC client that runs in the Java EE client container, and to override the default client settings. See ibm-webservicesclient-bnd.xmi assembly properties for more information about the ibm-webservicesclient-bnd.xmi deployment descriptor.
- (Optional) Deploy the web services client application. Complete this step to deploy a managed JAX-RPC web services client that runs in the Java EE client container.
- Test the Web services-enabled client application. We can test an unmanaged client JAR file or a managed client application.
Results
You have created and tested a web services client application.
What to do next
After you develop a web services application client, and the client is statically bound, the service endpoint used by the implementation is the one that is identified in the WSDL file that you used during the development process. During or after installation of the web services application, you might want to change the service endpoint. For managed clients, you can change the endpoint with the admin console or the wsadmin scripting tool.
We can additionally consider customizing your web service by implementing extensions to your web services client. Some examples of these extensions include sending and receiving values in SOAP headers, sending and receiving HTTP or JMS transport headers, or using custom bindings.
To learn more about these extensions, read about implementing extensions to web services clients.
Related
Develop client bindings from a WSDL file for a JAX-RPC Web services client
Change SOAP message encoding to support WSI-Basic Profile
Configure the JAX-RPC web services client deployment descriptor with an assembly tool
Configure the JAX-RPC client deployment descriptor for handler classes
Configure the JAX-RPC web services client bindings in the ibm-webservicesclient-bnd.xmi deployment descriptor
Implement extensions to JAX-RPC web services clients
Web services
JAX-RPC
Access the samples
Configure a web services client to access resources using a web proxy
Assembling a web services-enabled client JAR file into an EAR file
Assembling a web services-enabled client WAR file into an EAR file
Deploy web services client applications
Test web services-enabled clients
Implement web services applications with JAX-RPC
Set up a development environment for web services
Example: Installing a web services sample with the console
Task overview: Implementing web services applications
Samples documentation
Related
Web services client to web container optimized communication
Artifacts used to develop web services
JAX-RPC web services enabled module - deployment descriptor settings (ibm-webservices-bnd.xmi file)
Map between Java language, WSDL and XML for JAX-RPC applications
Web services specifications and APIs
http://www.ibm.com/developerworks/websphere/techjournal/0604_singh/0604
http://www.ibm.com/developerworks/websphere/techjournal/0606_singh/0606
http://www.ibm.com/developerworks/websphere/techjournal/0607_desprets/06