Calling WebClient from an External Application

Calling WebClient from an External Application

This section demonstrates how to pass a parameter to WebClient function. The following example is based on wxpcourse60 model calling the function WXwF, which prompts the user to insert an item record.

The first step is to create a URL which calls the insert item function, without parameters. To accomplish this, open WebClient.properties file and add the following property.
webclient.entry.url.InsertItem=WXPCOURSE60.WXwF

Now, the servlet will respond to the URL /WebClientServlet/InsertItem by calling the function WXPCOURSE60.WXwF as the WebClient entry point. However, it does not yet allow parameters to be passed.

To pass parameters in, a custom servlet needs to be created. Open J2EE perspective. Right-click on web project → Select New → Select Servlet.
Enter deeplink as the Java package and Class name. For the servlet mapping, specify InsertItem. Click Finish.



In the WebClient documentation folder, there exists a sample custom servlet, called deeplink.java, which will help you create a servlet that sends parameters to a Plex function. Copy and paste the code from deeplink.java to the newly created servlet. Change the package name to deeplink.



Change the class name to deeplink.



The parameters are passed to WebClient using an XML format. Locate the variable plexXML in the source code; this contains the XML data that is sent. Modify the input variable name and field name to match those expected by the WXwF function.

final String plexXML = " <FieldName=\"ItemID\">"+ encodeToXML(myVariable) + final String plexXML = "<PlexFunction
xmlns=\"http://adcaustin.com/ws-plex/1.0/%22%3E
<InputVariables Name=\"Input\"><FieldName=\"ItemID\">"+
encodeToXML(myVariable) +
"</Field></InputVariables></PlexFunction>";"";

Modify webClient URL from final String webclientURL =
"/webclient/test"; to final String webclientURL =
"/WebClientServlet/InsertItem";

Now the InsertItem servlet will forward its requests to the WebClient servlet. Save changes.
The last change that needs to be made is the servlet mapping. It needs to have the characters /* at the end to match against any parameter that is passed in the URL. Open web.xml and change deeplink servlet mapping to

/InsertItem/*

And WebClientServletservlet mapping to

/WebClientServlet/*

The web.xml file should look like below.

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance%22
xmlns="http://java.sun.com/xml/ns/javaee%22
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd%22 id="WebApp_ID"
version="3.0">
<display-name>belharraweb</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<servlet>
<description></description>
<display-name>WebClientServlet</display-name>
<servlet-name>WebClientServlet</servlet-name>
<servletclass>com.adcaustin.webclient.servletproxy.WebClientServlet</servletclass>
</servlet>
<servlet-mapping>
<servlet-name>WebClientServlet</servlet-name>
<url-pattern>/WebClientServlet/*</url-pattern>
</servlet-mapping>
<servlet>
<description></description>
<display-name>deeplink</display-name>
<servlet-name>deeplink</servlet-name>
<servlet-class>deeplink.deeplink</servlet-class>
</servlet>
Calling WebClient from an External Application
C M W e b C l i e n t U s e r M a n u a l P a g e 49 | 93
<servlet-mapping>
<servlet-name>deeplink</servlet-name>
<url-pattern>/InsertItem/*</url-pattern>
</servlet-mapping>
</web-app>

Save changes.
Build the web project and publish to the server.
To call the function, open a web browser and enter the following URL. http://localhost:8080/wxpcourse60web/InsertItem/001
URL format:
http://///

    • Related Articles

    • WebClient Manual

      Here you can find the articles of the CM WebClient user manual, just click on the name and it will take you directly to the article. Introduction Installation Requirements Plex Model Configuration Overview of Workspace Setup Calling WebClient from an ...
    • CM WebClient for CM M3

      Pre-requisites CA Plex dispatcher – The System i TCP/IP Dispatcher is required when the transformed applications call external iSeries objects (RPG, CL programs) Properties Configuration m3startup.properties This is the file were the AS400 ...
    • Customizing in CM WebClient

      Attach point A template for a given screen can be generated from more than one template by using attach points. The templates are arranged in order from root to leaf. An attach point is a location defined in a template that other templates further ...
    • Deploying a WebClient application as a WAR file

      You can deploy your WebClient application by exporting it to a WAR file and then publish it to a Tomcat server, to do this follow these steps: Installing the Tomcat server service a. Download the Tomcat service installer from the Tomcat official page ...
    • Patch Build to CM WebClient 1.8.8

      Latest Version: Date 10 /25/2024 WebClient-1.8.9-13546 NOTE : If the hightail link doesn't open correctly the first time, please just reload the screen, we recommend using the Chrome browser to open it. Current GA Release CM WebClient 1.8.7 WebClient ...