Thank you for being a valued client of CM First Group. If you have any technical issues or concerns, please open a ticket on support.cmfirstgroup.com, email CM First technical support at support@cmfirstgroup.com or call us on our 24/7 customer hotline at +1 (512) 623-7586.

Follow

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) + "";

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.



belharraweb

index.html
index.htm
index.jsp
default.html
default.htm
default.jsp



WebClientServlet
WebClientServlet
com.adcaustin.webclient.servletproxy.WebClientServlet


WebClientServlet
/WebClientServlet/*


deeplink
deeplink
deeplink.deeplink

deeplink /InsertItem/*

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://///

 

back to top

Was this article helpful?
0 out of 1 found this helpful
Have more questions? Submit a request

Comments

Powered by Zendesk