Entering content frame

Background documentation Using the Session Protocol Locate the document in its SAP Library structure

With SAP NetWeaver Developer Studio Features

The Logical port editor of SAP NetWeaver Developer Studio provides option for configuring your proxy to use standard HTTP sessions or ABAP sessions. In addition, you can control this feature at runtime by using Session Protocol – com.sap.engine.services.webservices.jaxrpc.wsdl2java.features.builtin.SessionProtocol .

To get an instance of the protocol, use:

This graphic is explained in the accompanying text

SessionProtocol session = (SessionProtocol) ((BaseGeneratedStub) client)._getGlobalProtocols().getProtocol("SessionProtocol");

 

This protocol provides methods for restarting sessions and releasing session resources on the SAP ABAP and J2EE nodes. The methods provided are:

·        session.closeSession():void – Closes the current session and has the following behavior, depending on the session mode:

¡        Standard HTTP Session mode – Discards cookies and starts a new HTTP session. To release resources on the SAP J2EE node, invoke ((BaseGeneratedStub) client)._flush()

¡        ABAP Session mode – This is provided to support sessions on ABAP nodes. Because of the nature of the session, you must invoke session.closeSession()before the last invocation to ensure that the resources are released on the server.

·        session.isMaintainSession():boolean – Provides information about the current session state. The default is true.

To use sessions for ABAP elements, check the ABAP Session checkbox in the Logical Port editor. Alternatively, you may set this feature at runtime by invoking ((BaseGeneratedStub)client)._getGlobalFeatureConfig().getSubContext("http://www.sap.com/webas/630/soap/features/session/").setProperty("abapSession","yes").

With Java Code

When the session feature is not selected in the SAP NetWeaver Developer Studio Logical Port editor, and you want to use sessions within your client application at runtime, you must add the session protocol to your client manually and set the required properties. This is done with the following Java code.

This graphic is explained in the accompanying text

com.sap.engine.services.webservices.jaxrpc.wsdl2java.BaseGeneratedStub
bgs =  (com.sap.engine.services.webservices.jaxrpc.wsdl2java.BaseGeneratedStub) client;

 

 SessionProtocol session = new SessionProtocol();

 bgs._getGlobalProtocols().add(session);

 bgs._getGlobalFeatureConfig().getSubContext("http://www.sap.com/webas/
630/soap/features/session/"
).setProperty("SessionMethod","httpCookies");
// Sets cookie session method

 bgs._getGlobalFeatureConfig().getSubContext("http://www.sap.com/webas/
630/soap/features/session/"
).setProper("abapSession","yes");
// call this only for ABAP sessions.

 

The last line of the code must be used only if the Web service is an ABAP endpoint that supports sessions. The ABAP Web services provide a different type of session support – the client forces the session start, not the server.

Leaving content frame