Developer examples
This reference information provides examples and shows code snippets, command syntax, and configuration values that are relevant to performing application design, development, assembly, and deployment tasks.
You can also search for developer examples by title or by using keywords.
Subtopics
Call stub generator CSG.xml file
The CSG.xml file provides a complete example of how to start the COBOL call stub generator from Ant using the <csg> custom task or within Rational® Application Developer as an Ant build.Call stub generator CSGBatch.xml file
The CSGBatch.xml Ant build file provides an example for running <csg> against a batch of COBOL files, such as all *.cbl files in a directory. The call stub generator and CSGBatch.xml file are available with the IBM® Rational Application Developer for WebSphere® Software product.COBOL call stub Java class usage example
The COBOL call stub Java™ class usage example shows how a batch application can invoke a COBOL procedure using the COBOL container.COBOL container for batch troubleshooting
If you encounter problems when using COBOL container for batch troubleshooting, there are a number of options that are available to you.COBOL RETURNING, RETURN-CODE, getReturnValue, and getReturnCode parameters
If the COBOL module specifies a RETURNING parameter, it can be retrieved from the stub using the stub.getReturnValue() method. The method returns the Java object representation of the RETURNING parameter, which is the data bindings class generated by the COBOL call stub generator tool.Example: A com.ibm.wsspi.security.token.AuthenticationToken implementation
The following example illustrates an authentication token implementation. The following sample code does not extend an abstract class, but rather implements the com.ibm.wsspi.security.token.AuthenticationToken interface directly. You can implement the interface directly, but it might cause you to write duplicate code. However, you might choose to implement the interface directly if considerable differences exist between how you handle the various token implementations.Example: A com.ibm.wsspi.security.token.SingleSignonToken implementation
Use this file to see an example of a single sign-on implementation. The following sample code does not extend an abstract class, but implements the com.ibm.wsspi.security.token.SingleSignonToken interface directly. You can implement the interface directly, but it might cause you to write duplicate code. However, you might choose to implement the interface directly if considerable differences exist between how you handle the various token implementations.Example: ActiveX client application calling Java methods
In the ActiveX to Enterprise Java Beans (EJB) bridge, methods are called using the native language method invocation syntax.Example: ActiveX client application using helper methods for data type conversion
Generally, data type conversion between ActiveX (Visual Basic and VBScript) and Java methods occurs automatically, as described in ActiveX to EJB bridge, converting data types. However, the byte helper function and currency helper function are provided for cases where automatic conversion is not possible:Example: A custom authentication token login module
This examples shows how to determine if the login is an initial login or a propagation login.Example: A custom single sign-on token login module
This file shows how to determine if the login is an initial login or a propagation login.Example: An HTTP cookie retrieval
The following example shows you how to retrieve a cookie from an HTTP request, decode the cookie so that it is back to your original bytes, and create your custom SingleSignonToken object from the bytes. This example shows how to complete these steps from a login module. However, you also can complete these steps using a servlet.Example: Applet client code requirements
The code used by an applet to talk to an enterprise bean is the same as that used by a stand-alone Java program or a servlet, except for one additional property called java.naming.applet. This property informs the InitialContext and the Object Request Broker (ORB) that this client is an applet rather than a stand-alone Java application or servlet.Example: Applet client tag requirements
Standard applets require the HTML <APPLET> tag to identify the applet to the browser. The <APPLET> tag invokes the Java virtual machine (JVM) of the browser. It can also be replaced by <OBJECT> and <EMBED> tags.Example: Caching a command object
Cacheable commands are stored in the cache for reuse with a similar mechanism for servlets and JavaServer Pages (JSP) files.Example: Caching web services
You can build a set of cache policies and SOAP messages for a web services application.Example: com.ibm.wsspi.security.token.AuthorizationToken implementation
Use this file to see an example of a AuthorizationToken implementation. The following sample code does not extend an abstract class, but rather implements the com.ibm.wsspi.security.token.AuthorizationToken interface directly. You can implement the interface directly, but it might cause you to write duplicate code. However, you might choose to implement the interface directly if there are considerable differences between how you handle the various token implementations.Example: com.ibm.wsspi.security.token.PropagationToken implementation
Use this file to see an example of a propagation token implementation. The following sample code does not extend an abstract class, but implements the com.ibm.wsspi.security.token.PropagationToken interface directly. You can implement the interface directly, but it might cause you to write duplicate code. However, you might choose to implement the interface directly if considerable differences exist between how you handle the various token implementations.Example: Configuring handler classes for web services deployment descriptors
This scenario explains how to add a client and server handler class to a sample application, WebServicesSamples.ear. The handler classes display messages when given a request or response to handle.Example: Configuring the dynamic cache service
This example puts all of the steps together for configuring the dynamic cache service with the cachespec.xml file, showing the use of the cache ID generation rules, dependency IDs, and invalidation rules.Example: Configuring the extended portlet deployment descriptor to disable PortletServingServlet
Portlet URL serving supports direct access to all functions and states of a portlet by creating the appropriate URLs. In a production setup where the portlet is served through an enterprise portal application that applies its own access control, is considered a security risk. By setting the portletServingEnabled property to false, an administrator can ensure that a sensitive portlet is never accessed by direct URL serving.Example: Creating a web service that uses the JAX-WS Web Services Addressing API to access a generic web service resource instance
Consider an IT organization that has a network of printers that it wants to manage using web services. The organization might represent each printer as a resource that is addressed through an endpoint reference. This example shows how to code such a service by using the JAX-WS Web Services Addressing (WS-Addressing) application programming interfaces (APIs) that are provided by WebSphere Application Server.Example: custom AuthorizationToken login module
This file shows how to determine if the login is an initial login or a propagation login.Example: Custom propagation token login module
This example shows how to determine if the login is an initial login or a propagation login.Example: Enabling logging and tracing for activeX client applications
The ActiveX to EJB bridge provides two logging and tracing formats: Windows Application Event Log and Java Trace Log.Example: Enabling logging and tracing for application clients
The ActiveX to EJB bridge provides two logging and tracing formats: Windows Application Event Log and Java Trace Log.Example: Enterprise bean application code
The following Enterprise JavaBeans (EJB) component example illustrates the use of the isCallerInRole and the getCallerPrincipal methods in an EJB module.Example: Getting an initial context by setting the provider URL property
In general, Java Naming and Directory Interface (JNDI) clients should assume the correct environment is already configured so there is no need to explicitly set property values and pass them to the InitialContext constructor. However, a JNDI client might need to access a namespace other than the one identified in its environment. In this case, it is necessary to explicitly set the java.naming.provider.url (provider URL) property used by the InitialContext constructor. A provider URL contains bootstrap server information that the initial context factory can use to obtain an initial context. Any property values passed in directly to the InitialContext constructor take precedence over settings of those same properties found elsewhere in the environment.Example: Getting an initial context with CosNaming
In WebSphere Application Server, an initial context is obtained from a bootstrap server. The address for the bootstrap server consists of a host and port. To get an initial context, you must know the host and port for the server that is used as the bootstrap server.Example: Getting the default initial context
There are various ways for a program to get the default initial context.Example: Looking up an EJB home or business interface with JNDI
Most applications that use Java Naming and Directory Interface (JNDI) run in a container. Some do not. The name used to look up an object depends on whether or not the application is running in a container. Sometimes it is more convenient for an application to use a corbaname URL as the lookup name. Container-based JNDI clients and thin Java clients can use a corbaname URL.Example: Looking up an EJB home with CosNaming
You can look up an EJB home or other CORBA object from a WebSphere Application Server name server through the CORBA CosNaming interface.Example: Passing SOAP messages with attachments by using WSIF
Information and example code for using the Web Services Invocation Framework (WSIF) SOAP provider to pass attachments within a MIME multipart/related message in such a way that the SOAP processing rules for a standard SOAP message are not changed. This includes how to write the Web Services Description Language (WSDL) extensions for SOAP attachments, and how to work with types and type mappings.Example: Read-read consistency checking
Read-read consistency checking only applies to LifeTimeInCache beans whose data is read from another transaction.Example: Sample configuration for Web Services Security for a version 5.x application
To secure a version 5.x application with Web Services Security, you must define the security constraints in the IBM extension deployment descriptors and in IBM extension bindings. Sample keystore files and default binding information are provided for a sample configuration to demonstrate what IBM deployment descriptor extensions and bindings can do.Example: Setting client information with the setClientInformation(Properties) API
You can set WebSphere Application Server client information on connections to pass that information to your database with this API.Example: Setting the provider URL property to select a different root context as the initial context
Each server contains its own server root context, and, when bootstrapping to a server, the server root is the default initial JNDI context. Most of the time, this default is the desired initial context, since system artifacts such as EJB homes are bound there. However, other root contexts exist, which can contain bindings of interest. It is possible to specify a provider URL to select other root contexts.Example: SIP servlet Proxy servlet class
Example: SIP servlet SendOnServlet class
The SendOnServlet class is a simple SIP servlet that would perform the basic function of being called on each INVITE and sending the request on from there.Example: SIP servlet simple proxy
This is a servlet example of a simple proxy.Example: Using an ActiveX client application to access a Java class or object
You can use Java proxy objects with the ActiveX to Enterprise JavaBeans (EJB) bridge.Example: Using a read-only entity bean
A usage scenario and example for writing an Enterprise JavaBeans (EJB) application that uses a read-only entity bean.Example: Using connections with concurrency
A Runnable or Callable can use the connections that its creating component obtained using java:comp resource references.Example: Using JAX-WS properties to manipulate SOAP headers in a JAX-WS handler
WebSphere Application Server provides extensions to the Java API for XML-Based Web Services (JAX-WS) and Web Services for Java Platform, Enterprise Edition (Java EE) client programming models, including the jaxws.binding.soap.headers.outbound and jaxws.binding.soap.headers.inbound properties. This example shows how to use these two properties to manipulate SOAP headers in a JAX-WS handler.Example: Using the local interface for Dynamic query
When you run a dynamic Enterprise JavaBeans (EJB) query using the local interface, you are calling the executeQuery method on the QueryLocal interface. This interface does not initiate a transaction for the method; therefore you must explicitly establish a transaction context for the query to run.Example: Using the portlet aggregation tag library
You can use the aggregation tag library to aggregate multiple portlets to have multiple and different content on one page. The library can be used by every JavaServer Pages (JSP) file that has been included by a servlet.Example: Using the remote interface for Dynamic query
When you run a dynamic Enterprise JavaBeans (EJB) query using the remote interface, you are calling the executeQuery method on the Query interface. The executeQuery method has a transaction attribute of REQUIRED for this interface; therefore you do not need to explicitly establish a transaction context for the query to run.Example: Using the work area partition manager
Example: Using tsx:repeat JavaServer Pages tag to iterate over a results set (deprecated)
The <tsx:repeat> tag iterates over a results set. The results set is contained within a bean. The bean can be a static bean, for example, a bean created by using the IBM WebSphere Studio database wizard, or a dynamically generated bean, for example, a bean generated by the <tsx:dbquery> syntax.Example: Viewing a System.out message
The ActiveX to Enterprise JavaBeans (EJB) bridge does not have a console available to view Java System.out messages. To view these messages when running a stand-alone client program (such as Visual Basic), redirect the output to a file.Web Services code example
This Web Services Description Language (WSDL) example and code snippets show how to access fields within a Web services message for programming a mediation.


File name: welc_ref_dev_xmp.html