Using the HTTP Destination Within the Web
Dynpro 
Use
Once you have
created the HTTP destination on the AS Java, you must specify that this
destination is to be used by the Web Dynpro application. For this purpose, you
will insert the _setHTTPDestinationName() method in the component controller where the
methods for saving, canceling, and viewing reservations are
executed.
Prerequisites
|
 
|
The Web Dynpro
perspective is displayed in the SAP NetWeaver Developer Studio.
|
|
 
|
The Web Dynpro
project, TutWD_CarRental, is displayed in the
Web Dynpro Explorer.
|
Procedure
...
1.
If you are not
already working in the Web Dynpro perspective in the SAP NetWeaver Developer
Studio, then switch to it.
2.
Expand TutWD_CarRental ® Web Dynpro
® Web Dynpro
Components ® CarRentalComp.
3.
Select the Component Controller with a double-click.
The
CarRentalComp controller appears.
4.
Select the Implementation tab page.
5.
Adjust the source
code. Insert a call to the _setHTTPDestinationName() method before the execute() method is called. Insert this call in each
of the methods execute_ActiveBookings(), execute_Save(), and execute_Cancel().
See the
examples below.
Method
execute_ActiveBookings()
public void execute_ActiveBookings(
)
{
//@@begin
execute_ActiveBookings()
IWDMessageManager msgMgr = wdComponentAPI.getMessageManager();
try {
//
wdContext.currentActiveBookingsElement().modelObject().execute();
Request_QuickCarRentalServiceViDocument_viewActiveBookings modObj
=
wdContext.currentActiveBookingsElement().modelObject();
modObj._setHTTPDestinationName("CarRental");
modObj.execute();
wdContext.nodeResponse_ActiveBookings().invalidate();
} catch (Exception ex) {
msgMgr.reportException(ex.getMessage(), false);
}
//@@end
}
|
Method
execute_Save()
public void execute_Save( )
{
//@@begin execute_Save()
try {
//
wdContext.currentSaveBookingElement().modelObject().execute();
Request_QuickCarRentalServiceViDocument_saveBooking modObj =
wdContext.currentSaveBookingElement().modelObject();
modObj._setHTTPDestinationName("CarRental");
modObj.execute();
wdContext.nodeResponse().invalidate();
MessageManager msgMgr =
(MessageManager) wdComponentAPI.getMessageManager();
msgMgr.reportSuccess("Success! ");
} catch (Exception ex) {
MessageManager msgMgr =
(MessageManager) wdComponentAPI.getMessageManager();
msgMgr.reportException(ex.getLocalizedMessage(), true);
}
//@@end
}
|
Method
execute_Cancel()
public void execute_Cancel( )
{
//@@begin execute_Cancel()
try {
//
wdContext.currentCancelBookingElement().modelObject().execute();
Request_QuickCarRentalServiceViDocument_cancelBooking modObj =
wdContext.currentCancelBookingElement().modelObject();
modObj._setHTTPDestinationName("CarRental");
modObj.execute();
wdContext.nodeResponse_CancelBooking().invalidate();
MessageManager msgMgr =
(MessageManager) wdComponentAPI.getMessageManager();
msgMgr.reportSuccess(
"Success! "
+ wdContext.currentResponse_CancelBookingElement().
getResult());
} catch (Exception ex) {
MessageManager msgMgr =
(MessageManager) wdComponentAPI.getMessageManager();
msgMgr.reportException(ex.getLocalizedMessage(), true);
}
//@@end
}
|
6.
Save the
metadata.
Result
The Web Dynpro
application will use this destination to retrieve the logon ticket and pass it
to the Web service.
Next Step:
Protecting Access to
the EJB Methods Using UME Permissions