To provide a flexible mechanism to switch between Web Dynpro applications and non Web Dynpro applications there is the Suspend-Resume mechanism as part of the Web Dynpro programming model. Suspend and Exit Plugs use HTTP GET to redirect your Web Dynpro application to the specified ‘Url’. This blog explains how to use the Suspend Plug with HTTP POST. I am providing a cheatsheet to do this in NW04s.
When a POST is required in Suspend/Exit plug?
HTTP GET has the limitation of 1KB to send along the URL. No situation guarantees that no more than 1KB will be used while going out of the Web Dynpro application to non Web Dynpro applications. GET is normally categorized as ‘Idempotent Method’. This leads to caching of the page. So passing username and password through GET is not wise. These situations recommend using HTTP POST.
Here I am providing a way to realize HTTP POST in Web Dynpro Suspend Plug using static HTML.
The first step for using a suspend/resume plug is to make/add the application property ‘sap.suspendable.application’ as true.
In your View, add your InterfaceView as Required controller. This will generate convenience methods to access the suspend plug. This step is required to make the InterfaceView accessible to the View.
HTTP POST in suspend plug can be easily achieved in NW 7.1. Since HTTP POST is not available in Suspend Plug of all the Web Dynpro versions, I have found out a cheatsheet to do the same in NW04s. This approach can be used in NW 7.1 as well.(Anyway no need for this approach in NW 7.1)
Holy Grail, Web Dynpro has a flexible mechanism to create resources dynamically using its programming model. I am going to use this feature to do the HTTP POST while suspending the application.
1. Form the HTML content which can do the HTTP POST on loading to the actual destination.
2. Put the values that you want to POST in input fields in the Form.
Convert the HTML content from string to a byte Array.
Create a HTML file for the above content using the WDResourceFactory.
The file created will always be accompanied with a URL to access on the Web. Retrieve the URL for the ‘Post.html’ file and use that as the destination URL for the Suspend plug.
A new file will be created for each call to WDResourceFactory API to create the resource. This HTML file lives in the server till the end of the Application session. Application Server will take care of clearing the HTML file once the session expires.
Wow! I have written my first Technical weblog.