Runtime components : Channels components : Mobile Channel : Concepts : Implementation mechanism : Server side implementation mechanism : Interaction between client and server
  
Interaction between client and server
This section introduces the interaction between client and server.
Establish session:
The following flow diagram demonstrates how a session is established:
Flow diagram demonstrates how a session is established
1 The eRCP application invokes MobileAdapter.establishSession() to create a session with the UDTT server application.
2 MobileAdapter sets HTTP Request Property User-Agent as mobile, and then sends HTTP request http://<server_address>:<port>/<url>? createSession=true to Server side. The <url> is defined in bttmobile.properties. The UDTT server application knows that the request is from mobile channel and its purpose is to create session.
3 MobileRequestServlet creates ChannelContext using ChannelDriver.createChannelContext().
4 ChannelContext is initialized with attributes of Request, Response, ChannelDriver, DeviceType and RequestData.
5 MobileRequestServlet invokes ChannelDriver.service() to process request.
6 ChannelDriver parses the request header and data, and then fills the created http session to ChannelContext (in attribute ChannelSession). Then it invokes MobileRequestHandler to process the request.
7 MobileRequestHandler determines that it is a session creation request. It invokes the StartupOp Operation, which is defined in btt.xml. You can write business logic in this operation, for example, creating Session Context and then chaining it to root context; creating operation context and then chaining it to Session Context.
8 StartupOp Operation returns. MobileRequestHandler adds SessionEntry (SessionId, SessionContext, httpsession) to sessionhandler.
9 MobileRequestHandler invokes MobileRepresentationHandler to commit SessionContext. SessionContext and all its children are committed into DB. This recovers Session data after the application restarted.
10 MobileRepresentationHandler returns after SessionContext is committed.
11 MobileRequestHandler returns.
12 ChannelDriver returns.
13 MobileRequestServlet returns http message 200 to client, which means the request has been handled successfully.
14 MobileAdapter parses HTTP header, and gets session id from HTTP header attribute Set-cookie, which is used in continuous request. MobileAdapter returns true for method establishSession() if all the requests are handled correctly. If not, it returns false.
Invoke server side operation:
The following flow diagram demonstrates how server side operation is invoked:
Flow diagram showing how the server side operationis invoked
15 The eRCP application invokes MobileAdapter.invoke () to invoke operation in server side.
16 MobileAdapter sets HTTP Request Property User-Agent as mobile, and cookie as sessionid, which is gotten from establishing session, and then it sends HTTP request http://<server_address>:<port>/<url>?action=<Server Operation ID>&responseDataId=<Response data ID> to server side (<Server Operation ID> and <Response data ID> are defined in server side XML files). With the request property cookie, the UDTT server application knows where the request is from. MobileAdapter also sends the serialized object, which is the input parameter for server operation over HTTP.
17 MobileRequestServlet creates ChannelContext using ChannelDriver.createChannelContext().
18 ChannelContext is initialized with attributes of Request, Response, ChannelDriver, DeviceType and RequestData.
19 MobileRequestServlet invokes ChannelDriver.service() to process request.
20 ChannelDriver parses the request header and data, and fills the existing HTTP session to ChannelContext (in attribute ChannelSession). Then it invokes MobileRequestHandler to process the request.
21 MobileRequestHandler determines that it is a service request. It parses the request data into Operation context and chains the operation context to session context, and then it invokes specified server operation.
22 MobileRequestHandler gets result from operation context after Server Operation returns.
23 MobileRequestHandler invokes MobileRepresentationHandler to process reply.
24 MobileRepresentationHandler returns after the reply is processed.
25 MobileRequestHandler returns.
26 ChannelDriver returns.
27 MobileRequestServlet returns HTTP message 200 to client which means the request has been handled successfully. And besides that, it returns serialized output Javabean to client.
28 MobileAdapter parses HTTP data and gets the output Javabean.
Go up to
Server side implementation mechanism