Question & Answer
Question
This technote explains how you can obtain the IP address of the managed client that invokes the Web Service, after generating a Java Bean Skeleton Web Service from a WSDL file using IBM® WebSphere® Application Server 6.1 and JAX-RPC
Answer
DISCLAIMER
All source code and/or binaries attached to this document are referred to here as "the Program". IBM is not providing program services of any kind for the Program. IBM is providing the Program on an "AS IS" basis without warranty of any kind. IBM WILL NOT BE LIABLE FOR ANY ACTUAL, DIRECT, SPECIAL, INCIDENTAL, OR INDIRECT DAMAGES OR FOR ANY ECONOMIC CONSEQUENTIAL DAMAGES (INCLUDING LOST PROFITS OR SAVINGS), EVEN IF IBM, OR ITS RESELLER, HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
There are two possibilities to obtain the IP address of the client:
A. Add a servlet filter that gets access to the
javax.servlet.ServletRequest
object.
B. Implement javax.xml.rpc.server.ServiceLifecycle
so that you can get access to: javax.xml.rpc.server.ServletEndpointContext
A: Add a Servlet Filter
1. Open the web.xml file of the Dynamic Web project where you have already generated the Java Bean Skeleton Web Service.
2. Select the Filters tab
3. Click on the Add button in the Filters section
![](/support/pages/system/files/support/swg/rattech.nsf/0/4e1de403f7ec13b0852574410046186c/Content/0.6C4.gif)
5. Define the name of the class to be generated:
![](/support/pages/system/files/support/swg/rattech.nsf/0/4e1de403f7ec13b0852574410046186c/Content/0.719A.gif)
6. Let it implement:
javax.servlet.Filter
as the dialog suggests:![](/support/pages/system/files/support/swg/rattech.nsf/0/4e1de403f7ec13b0852574410046186c/Content/1.2766.gif)
7. In the Servlet Mapping section of the Filters tab of the web.xml file, add the Filter Mapping to Servlet by selecting the router servlet that was generated by the Web Services wizard and choose as Dispatcher type: REQUEST:
![](/support/pages/system/files/support/swg/rattech.nsf/0/4e1de403f7ec13b0852574410046186c/Content/3.14EA.gif)
8. Implement the filter as follows:
|
chain.doFilter(request, response);
is required so that the Web Services is actually invoked after the servlet filter is processed. When a Web client invokes the web service, the IP address of the client will be written to the server console.
B. Implement javax.xml.rpc.server.ServiceLifecycle
1. Have the web service implementation class implement the interface:
|
2. Add a field defined as follows:
|
3. Implement the init method to store the
ServletEndpointContext
:
|
4. Implement a method like the following:
|
Was this topic helpful?
Document Information
Modified date:
10 September 2020
UID
swg21304368