Using the Ajax proxy


IBM® WebSphere® Application Server Feature Pack for Web 2.0:

The Ajax proxy is distributed as an optional Web archive file (WAR) that can be installed directly into an application or combined with an existing application enterprise archive (EAR) file. The usage depends on your goals.

If you are developing an application that uses Ajax that must support cross site scripting because you are accessing data from one or more remote sites, you might embed the Ajax proxy WAR file as part of your application. If you have multiple applications that are accessing the same remote site, you might deploy the Ajax proxy as a standalone WAR file, and allow multiple applications to access it.



Getting started

You can apply the Ajax proxy in multiple ways. The following two scenarios demonstrate how you might use the Ajax proxy. The steps are covered in further detail in the document.

(Option 1) Using a proxy embedded as part of your JavaTM EE application

As a servlet, the proxy can be embedded in your Java EE application and deployed with the application. Embedding the proxy with the application supports proxy deployment with the application in a ready-to-run configuration. You might choose to embed the Ajax proxy in your application if you are building an application that combines the content from one or more service endpoints in an Ajax-based application.

  1. Modify your application.xml file and the geronimo-application.xml file, if using WebSphere® Application Server Community Edition 2.0, to include the AjaxProxy Servlet. Typically, if you already have an EAR file created, then you can associate the Ajax proxy for IBM® WebSphere Application Server Feature Pack for Web 2.0 WAR file with your EAR project, and Eclipse completes the rest.
  2. Modify the proxy-config.xml file to define URI context paths, URLs, and policies that the proxy supports.
  3. Build your application with the Ajax proxy servlet and deploy the application to WebSphere Application Server V6.0.x and later or WebSphere Application Server Community Edition 2.0.

(Option 2) Using a proxy as a stand-alone Web application

As a servlet, the proxy can run as a standard Web application. Other applications can use the proxy to broker requests.

  1. Modify the proxy-config.xml file to define URI context paths and polices that the proxy supports.
  2. Deploy the Ajax proxy for IBM WebSphere Application Server WAR file to your application server.

Locating the Ajax proxy application Web archive file (WAR)

The first step is locating the Ajax proxy WAR file. Depending on how you obtained and are viewing the documentation, there are two places the file can be located.

Using the Ajax proxy in an Eclipse-based IDE

Use any Eclipse 3.2.X, 3.3.X, or higher with the Web Tools Project 2.5 or higher, or Rational Application Developer, version 7.0 or higher, to import the WAR file. Complete the following steps:

  1. From the Eclipse IDE menu, select File > Import.
  2. In the presented panel, expand the Web option, then select WAR file, then click Next.
  3. In the WAR File entry field, click Browse, and select the AjaxProxy.war file you located earlier and enter the name of the Web Project.
  4. Click Finish.

When the import process completes, The Ajax proxy will be imported as a WAR file. You can associate the WAR file with another EAR project or treat the WAR file as a standalone web application.

Modify the proxy-config.xml file for the Ajax proxy

The proxy-config.xml file is located in the WEB-INF/ directory of the AjaxProxy.war file and controls how the proxy behaves when a client side request is passed to the proxy. The proxy-config.xml file is loaded during the servlets initialization phase, you must restart the servlet for changes to take effect. The section, WEB-INF/proxy-config.xml file discusses how to control the behavior of the proxy.