Entering content frame

Procedure documentation Creating a Client JavaServer Page Locate the document in its SAP Library structure

Procedure

To create a JavaServer Page (JSP) that calls the deployable proxy, proceed as follows:

...

       1.      Create a Web Module project. Choose File ® New ® Project ® J2EE.

       2.      Select the name of the WEB project and choose New  ® JSP. Enter the required information and choose Finish.

       3.      Add the Web service client API.

Select the name of the project and choose Add Web Service Client API Library. This enables you to use the client API of the deployable proxy.

This graphic is explained in the accompanying text

 

This graphic is explained in the accompanying text

       4.      Implement the JSP

This graphic is explained in the accompanying text

<%@ page language="java" %>

<%@ page import="samplews.proxy.*, javax.naming.*, java.io.*" %>

 

<html>

   <head>

      <title>

         Title

      </title>

   </head>

   <body>

      <%

    

         try {

         InitialContext ic = new InitialContext();

         mplWS sampleWS = (SampleWS)ic.lookup("java:comp/env/SampleWSProxy");

         SampleWSViDocument vi = sampleWS.getLogicalPort();

         response.getWriter().write(vi.myBusinessMethod());

         }catch (Exception e){

         response.getWriter().write(e.toString());

         }

 

      %>   

   </body>

       </html>

       5.      Add JNDI mappings

Open the web-j2ee-engine.xml file and choose References. Then select the jndi mapping folder and choose Add. Enter the required data:

                            a.      Application local JNDI name – this is the name by which the proxy is looked up in the application (in our example this is “SampleWSProxy”).

                            b.      Server Component Name – service or application

                            c.      Server Component JNDI name – the name of the JNDI context by which the proxy is bound. The following convention is used:

/wsclients/proxies/<provider name>/<ApplicationName>/<ProxyName>

If the application name contains “/”, it must be replaced by “~”.

In our example the JNDI context is:

/wsclients/proxies/sap.com/SampleWSProxy_PRX/samplews.proxy.SampleWSProxy

This graphic is explained in the accompanying text

       6.      Add the JSP to the URL Pattern

Open web.xml, Choose Mapping ® Servlet Mappings and choose Add. Select your JSP and choose OK. In the displayed tab on the right-hand side, enter “/” in the URL Pattern field.

This graphic is explained in the accompanying text

       7.      Create a reference to the deployable proxy application

So that your client application can access the proxy classes, you need to provide an application reference. In this example, SampleWSClient_EAR application needs to reference the sap.com/SampleWSProxy_PRX proxy application.

To do this, open the application-j2ee-engine.xml editor of the EAR project. Choose General ® References ® Add® Create New.

Enter the corresponding data:

                            a.      Reference Target – this is the proxy project name. In this example it is: SampleWSProxy_PRX.

                            b.      Reference Type – hard means that your application will not be started if the proxy application is not started. Weak means that it will be started whether the proxy application is deployed or not, but it will not be useable until the proxy application is started.

                            c.      Reference Target Type – select application

                            d.      Provider Name – enter sap.com

This graphic is explained in the accompanying text

       8.      Add the WEB project to the application. Select the EAR project and choose Add Modules in the context menu.

This graphic is explained in the accompanying text

       9.      Edit the Context Root value of the WAR project to get the correct location to invoke the JSP. Select application.xml ® Modules ® Context Root and enter a new value.

This graphic is explained in the accompanying text

   10.      Build and deploy the EAR application.

You can test it under http://<host>:<port>/SampleWSClient/JSP

 

See also:

Creating a Client Bean

Creating a Client Servlet

Leaving content frame