Luxdeal report

Jan 2, 2004 - We're going to use Java to implement the web-services, but we have ... The Microsoft Foundation Class Library is an application framework for ...
955KB taille 20 téléchargements 228 vues
Mathieu Baeumler

Fabrice Daugan

David Hoeung

January 2004

Contents Intro

3

1 SOAP 1.1 W3C abstract . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.2 SOAP messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

4 4 5

2 server 2.1 Tomcat . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.2 Apache Soap . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.3 implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

7 7 8 8

3 SmartPhone 3.1 about . . . . . . . . . . . . . . . . . . . 3.2 development . . . . . . . . . . . . . . . . 3.2.1 ATL . . . . . . . . . . . . . . . . 3.2.2 MFC . . . . . . . . . . . . . . . . 3.2.3 2002 . . . . . . . . . . . . . . . . 3.2.4 2003 . . . . . . . . . . . . . . . . 3.2.5 Compatibility . . . . . . . . . . . 3.2.6 Documentations and Helper Links 3.3 development . . . . . . . . . . . . . . . . 3.3.1 Tools used . . . . . . . . . . . . . 3.3.2 Conception . . . . . . . . . . . . 3.3.3 Naming Convention . . . . . . . . 3.3.4 stringBuffer . . . . . . . . . . . . 3.4 SOAP . . . . . . . . . . . . . . . . . . . 3.5 Windows interface . . . . . . . . . . . . 3.5.1 Design . . . . . . . . . . . . . . . 3.5.2 guidelines . . . . . . . . . . . . . 3.5.3 Multi Language . . . . . . . . . . 3.5.4 windows messages . . . . . . . . . 3.5.5 Genese of NWT . . . . . . . . . . 3.5.6 Resolving Callback . . . . . . . . 3.5.7 Using NWT Dialog . . . . . . . . Conclusion

. . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . .

9 9 9 9 9 10 10 11 11 11 11 11 11 12 13 17 17 17 18 19 20 21 21 23

1

CONTENTS

Glossary

24

A Tomcat A.1 convention . . . . . . A.2 Tomcat . . . . . . . A.3 SOAP . . . . . . . . A.3.1 Apache SOAP A.3.2 libraries . . . A.4 SOAP Webapp . . . A.5 eclipse . . . . . . . . A.5.1 plugin . . . . A.6 Luxdeal . . . . . . .

. . . . . . . . .

26 26 26 26 26 26 27 27 28 31

. . . . . . . .

32 32 34 34 35 35 36 37 37

B smartphone B.1 connection . . . . B.2 settings . . . . . B.3 adding libraries . B.4 Visual editor . . . B.4.1 bitmap . . B.4.2 dialog . . B.4.3 menu bar B.4.4 spin list .

DESS IRS

. . . . . . . .

. . . . . . . .

. . . . . . . . .

. . . . . . . .

. . . . . . . . .

. . . . . . . .

. . . . . . . . .

. . . . . . . .

. . . . . . . . .

. . . . . . . .

. . . . . . . . .

. . . . . . . .

. . . . . . . . .

. . . . . . . .

. . . . . . . . .

. . . . . . . .

2

. . . . . . . . .

. . . . . . . .

. . . . . . . . .

. . . . . . . .

. . . . . . . . .

. . . . . . . .

. . . . . . . . .

. . . . . . . .

. . . . . . . . .

. . . . . . . .

. . . . . . . . .

. . . . . . . .

. . . . . . . . .

. . . . . . . .

. . . . . . . . .

. . . . . . . .

. . . . . . . . .

. . . . . . . .

. . . . . . . . .

. . . . . . . .

. . . . . . . . .

. . . . . . . .

. . . . . . . . .

. . . . . . . .

. . . . . . . . .

. . . . . . . .

. . . . . . . . .

. . . . . . . .

. . . . . . . . .

. . . . . . . .

. . . . . . . . .

. . . . . . . .

. . . . . . . . .

. . . . . . . .

. . . . . . . . .

. . . . . . . .

. . . . . . . . .

. . . . . . . .

January 2004

Introduction ’The LuxDeal case study consists of an e-exchange web site that allows its members to exchange items.’

hen we read for the first time the project’s main goals, an I-Mode and a WAP prototype had already been developed. We had to extend these implementations with SmartPhone[1] and J2ME[2] technologies. Considering the large variety of possible clients (web browser, mobile phone, Rich client) for such kind of applications, we tried to develop a light server architecture, independent of the client’s platform.

W

One of the major tasks of this project was to find a simple way for exchanging data between a server and the clients, regardless of their platform and their respective programming language. Several solutions exist that provide these functionalities, like CORBA or RMI. But another popular solution used by web-developers, and which suits well to our objectives, is the one using Web-services, supported by SOAP, the Simple Object Access Protocol. This is the solution we have chosen, and we’re going to explain how we have implemented the server and the clients. But first of all, we have to give a quick explanation of how SOAP works.

3

Chapter 1 The Simple Object Access Protocol 1.1

description

he W3C[3] organization provides us a simple definition of what SOAP is and what it does with its recommendations[4]:

T

SOAP Version 1.2 is a lightweight protocol intended for exchanging structured information in a decentralized, distributed environment. It uses XML technologies to define an extensible messaging framework providing a message construct that can be exchanged over a variety of underlying protocols. The framework has been designed to be independent of any particular programming model and other implementation specific semantics. Another way for explaining what SOAP does for us is to say that we have to provide some services to client’s applications. These services are described by the functions they implement, and the clients are aware of these functions. They send a SOAP request, in which they invoke a named function with its parameters, to a listener. This listener translates the request for the corresponding service, wait for the response and send it back within a SOAP message1 to the clients:

Figure 1.1: SOAP exchange

1

image thanks to SoapUser website[5]

4

Chapter 1. SOAP

1.2

Structure of SOAP messages

A soap message structure is formalized as below. Our server and clients applications must conform to it, but some parts are optional(*) and may be ignored. SOAP message, the basic unit of communication between SOAP nodes. SOAP envelope, The outermost element information item of a SOAP message. SOAP header*, A collection of zero or more SOAP header blocks each of which might be targeted at any SOAP receiver within the SOAP message path. SOAP header block*, In general, contains informations which might be of use to SOAP intermediaries as well as the ultimate destination of the message. SOAP body, A collection of zero or more element information items targeted at an ultimate SOAP receiver in the SOAP message path. SOAP fault*, A SOAP element information item which contains fault information generated by a SOAP node. Suppose a client want to contact a web-service named LuxdealService. It should use an authentification function first, called for example login. This function would have two string parameters, username an password. Finally, suppose that this service is hosted on localhost, listening the port 5555. Here we show the corresponding SOAP request, and the response2 : 2

in which the server as authentified the user

DESS IRS

5

January 2004

Chapter 1. SOAP

Figure 1.2: Example of SOAP transaction

DESS IRS

6

January 2004

Chapter 2 The LuxDeal Web-services 2.1

Apache Tomcat

s mentioned in figure 1.1, the central part of this project’s architecture is the listener. It waits SOAP request, then it translates them into a method call for the corresponding service. The listener used in the two precedent prototype was the Tomcat[6] servlet container. We keep it, along with the mysql database, although we used EasyPhp[7], which provides an easy-to-use administration tool. We can now draw the entire architecture of our project (see figure 1.1):

A

Figure 2.1: Server Architecture

7

Chapter 2. server

2.2

Apache Soap

We’re going to use Java to implement the web-services, but we have first to allow Tomcat to redirect SOAP requests to a servlet which can understand them and call the corresponding methods. This will be done with Apache SOAP [8] application. After the study of LuxDeal specifications, we have discovered that we can use simple types to fulfill all our transactions. To be more accurate, String Array is the only type we use, due to its portability with the different SOAP implementation. If you look for advanced compatibility tests, you can go at ksoap homepage and look their interoperability tests[9].

2.3

The LuxDeal Web-service

The server implementation of LuxDeal service consist in two main classes, LuxDealDBInitServlet and LuxDealDB . The first one is a simple servlet, launched at Tomcat startup. This servlet is connected with the database and ensures users’ authentification. It gives a connection to granted clients. LuxDealDBInitServlet is not yet configured to response to SOAP requests, but it could be used in the future to administrate the database as a private Web-service. A simple way to implement this service would be to create another class like LuxDealDB , but with administration functions. The class LuxDealDB implements the service methods. The functions of I-Mode and WAP prototypes are all supported, and new ones have been created.

Figure 2.2: Luxdeal Web-service Architecture

DESS IRS

8

January 2004

Chapter 3 SmartPhone 3.1

A few words about Smartphone

icrosoft Windows SmartPhone[1] is Windows CE based. Windows CE is an Operating System for connected, small-footprint devices. There are some devices that are based on Windows Smartphone :

M

In Europe, OrangeSPV e200. In America, Samsung i600, Motorola MPx200. In Asia, Mio 8380, Qtek 7070, Amazing Phone, dopod 515.

3.2 3.2.1

Developing Applications for Windows Smartphone Active Template Library

The Active Template Library is a set of template-based C++ classes that simplify the programming of Component Object Model (COM) objects. It allows developers to easily create a variety of COM objects, Automation servers, and ActiveX controls.

3.2.2

Microsoft Foundation Class Library

The Microsoft Foundation Class Library is an application framework for programming in Microsoft Windows. Written in C++, MFC provides much of the code necessary for: • managing windows, menus, and dialog boxes, • performing basic input/output, • storing collections of data objects, and so on.

9

Chapter 3. SmartPhone

All you need to do is add your application-specific code to this framework. Thus, given the nature of C++ class programming, it’s easy to extend or override the basic functionality the MFC framework supplies. The MFC framework is a powerful approach that lets you build upon the work of expert programmers for Windows: • MFC shortens development time, • makes code more portable, • provides tremendous support without reducing programming freedom and flexibility, • gives easy access to hard to program user-interface elements and technologies, like Active technology, OLE, and Internet programming. Furthermore, MFC simplifies database programming through Data Access Objects and Open Database Connectivity, and network programming through Windows Sockets. MFC makes it easy to program features like property sheets (”tab dialogs”), print preview, and floating, customizable tool bars.

3.2.3

Smartphone 2002 development tools

To start developing applications for Microsoft Smartphone 2002, we need eMbedded Visual C++ 3.0 and the Smartphone 2002 SDK, available on the Microsoft website. MFC and ATL are not supported in Smartphone 2002.

3.2.4

Smartphone 2003 development tools

With Smartphone 2003 we have two options for development, either native code through eMbedded Visual C++ 4.0 with Service Pack 2 or managed code through Visual Studio .NET 2003. In both cases the Smartphone 2003 SDK is needed. Smartphone 2003 SDK, eMbedded Visual C++ 4.0 and his Service Pack 2 is available on the Microsoft website[10] for free. ATL 4.0 is supported in Smartphone 2003. The .NET Compact Framework will be also available in ROM on Smartphone 2003. The Microsoft .NET Compact Framework is the smart device development framework for Microsoft .NET, bringing the world of managed code to devices. The .NET Compact Framework greatly simplifies the process of creating and deploying applications to mobile and embedded devices, while taking full advantage of the capabilities of the device. Visual Studio .NET 2003 is required to develop .NET Compact Framework basedapplications, but is paying.

DESS IRS

10

January 2004

Chapter 3. SmartPhone

3.2.5

Compatibility

Well-behaved Smartphone 2002 applications that have used documented APIs are expected to run without being recompiled on Smartphone 2003 devices.

3.2.6

Documentations and Helper Links

The official Microsoft documentation, is the Microsoft Developer Network. It is a very good resource and reference, but it is not easy to find what you are looking for. The website Smartphone Developer Network[11] is a good site, with community, forums, articles, libraries, examples for developpers. It offers a replacement for MFC : Windows Template Library, but it is not official, there are no documentations, and works only with Smartphone 2002.

3.3 3.3.1

Developing the Application Tools Used for Developing

The latest development tools was chosen : • Microsoft eMbedded Visual C++ 4.0 SP2 • Microsoft Smartphone 2003 SDK

3.3.2

Conception

No particular model was used for building applications, nor Document/View, nor Model/View/Controller.

3.3.3

Naming Convention

We use a naming convention. It looks like an hungarian notation. It is a variable naming convention that includes C++ information: • data type • whether it is a reference, pointer, constant. • scope Resource type: bitmap, IDB ($name) static text, IDC STATIC ($name) edit box, IDC EDIT ($name) list box, IDC LB ($name)

DESS IRS

11

January 2004

Chapter 3. SmartPhone

dialog, IDD DLG ($name) menu, IDM ($name) menu item, IDR ($name) MENUBAR string resource, IDS ($name) C++ type: C++’s class, C($name) Dialog’s class, CDlg($name) Dialog object, dlg($name) HWND structure, hWnd CStringBuffer, sb char* null terminated, sz TCHAR* null terminated, tsz int, i pointer, p Scope: m , member g , global s , static l , local For example, with convention, an int variable called NbUser member of a class : m iNbUser

3.3.4

The class StringBuffer

A class for string manipulation was implemented, because we can’t use the CString class. The CString class is part of MFC, and we know that it is not supported in Smartphone. The Standard Template Library is not supported too. A solution could be the use of a porting of a string class available on internet. This the reason why CStringBuffer was coded. It is not really difficult and provide all we need for our solution of multi-language.

DESS IRS

12

January 2004

Chapter 3. SmartPhone

3.4

SOAP

At high level SOAP is now very used in web-services, result in the fact, there’s a lot of library available. In Windows world, we have MS SOAP Toolkit. Unfortunately, it works with Pocket PC, but not for Smartphone. So we can’t use high level function to sends serialized object in a request, and are not able to treat the response. We have to work at a lower level.

At low level SOAP is just the use of encapsulating data in XML transiting over HTTP.

WinInet API The Microsoft Win32 Internet functions (WinInet) assist us in making the Internet an integral part of any application. Its functions simplify the access to the Internet, using HTTP (Hypertext Transfer Protocol) and FTP (File Transfer Protocol). The firsts things to do is to: • include header file: #define INITGUID // declare before connmgr.h #include • initialize Internet functions: InternetOpen(TEXT("CeHttp"), INTERNET_OPEN_TYPE_PRECONFIG, NULL, 0, 0); Next, we have to create a connection request with ConnMgrEstablishConnectionSync(...); Then we open a session for a specified site with InternetConnect(...); We can now opens an HTTP request handle with HttpOpenRequest(...); To send the specified request to the HTTP server, we use HttpSendRequest(...); And to read data from the server, we use InternetReadFile. This is all the functions we need for sending HTTP request and getting HTTP response.

Parsing XML COM was created by Microsoft. It is a framework, a component software model for creating and using components. It provides reusable, client and server components. So COM is similar to CORBA, but it is the Microsoft solution. For parsing XML data, we use the Microsoft XML parser : MSXML. This parser implements the Document Object Model. (The DOM is a W3C[3] recommendation.) There is no other solution provided by Microsoft. MSXML is a COM server, so we call it with COM invokation. (this component is also used by internet explorer) DESS IRS

13

January 2004

Chapter 3. SmartPhone

COM Before use any method of a COM object, we have to initialize COM services : CoInitializeEx(0, COINIT MULTITHREADED); At this point, we can now use COM service, get a COM object and call its methods: CoCreateInstance (MSXML::CLSID DOMDocument, NULL, CLSCTX INPROC SERVER — CLSCTX LOCAL SERVER, MSXML::IID IXMLDOMDocument, (LPVOID *)&m pDom)) Creates a single uninitialized object of the class associated with a specified CLSID (MSXML::CLSID DOMDocument). m pDom is our base object (IXMLDOMDocument) for xml parsing. When we are done with COM services, we end the COM services by calling CoU ninitialize(); This function closes the OLE COM library, freeing any resources that it maintains. Parsing with IXMLDOMDocument The first thing to do is to load the XML Data, by calling IXMLDOMDocument::loadXML() If the result is successful, this indicates that the parsing has been achieved without any errors. The following methods is used to browse the XML tree: • selectNodes() • get length() • get item() • get childNodes() • get nodeValue()

SOAP classes Three classes was written for encapsulating calls, requests and responses : CSoapConnector, CSoapWriter and CSoapReader. CSoapConnector allows multiple calls with one connector. It instantiates a writer, which is useful for formatting a SOAP request. (The writer uses the class CStringBuffer.) It also instantiates a reader, which is used for parsing a SOAP response. To use this classes, CSoapConnector must be instantiated. The sequence initialization consists of the calls of: • Init() • Connect() A SOAP call sequence consists of DESS IRS

14

January 2004

Chapter 3. SmartPhone

• calling the PrepareNewRequest() method, • formatting the SOAP message, with Open methods,

(), Close

() and WriteElement()

• calling the CallService() method, • parsing the response, with LoadXML(), • and getting the value, with Get

().

Figure 3.1: Class Diagram

DESS IRS

15

January 2004

Chapter 3. SmartPhone

Figure 3.2: Sequence initialization

Figure 3.3: Execution example

DESS IRS

16

January 2004

Chapter 3. SmartPhone

3.5 3.5.1

Dealing with the Windows User Interface Designing User Interface

eMbedded Visual C++ is a powerful Integrated Development Tool. A windows resource editor is included. By selecting a control, and placing it in the frame (Window or Dialog) with the mouse, user interface is created and looks like it should, when application is running. A preview can be seen, if necessary.

3.5.2

Following the Smartphone UI guidelines

Reduce redundancy promote one way to do things. Let the user learn once, do everywhere. Design for performance. Avoid options. Instead, figure out the best way to do it. 1. The left soft key: • Always displays the most likely user task. • Is the Done soft key that closes the window, when needed. 2. The right soft key: • Always displays the Menu soft key when there is a menu. The command represented by the left soft key should be on the menu. • Should display the second most likely user task if there is no menu. • Is blank if it is not needed. 3. Use only one column. 4. Use only one control per row. The Back key can perform the following functions for Smartphone applications: -The Back key performs a global back function, navigating out of the current application. When the user visits one screen several times in one session, only one instance of the screen is saved. Duplicates should be removed from the back stack. -If a menu is open, the Back key should close the menu. -Pressing the Back key in an edit control performs a backspace. For text box on edit screens with one or more lines, pressing and holding the Back key clears an entire box. For full-screen edits, pressing and holding the Back key performs repeated backspaces. -Pressing the Back key when viewing a message box closes the message box and cancels the action. - For windows other than dialog boxes or message boxes, if the user presses the Back key, the system returns the user to the previous screen. The current window DESS IRS

17

January 2004

Chapter 3. SmartPhone

is not closed; instead, the previous window is brought to the top of the z-order. The system performs this action automatically; the application does not need to include any code to implement this function if the window does not override the Back key. - For dialog boxes with edit controls, the Back key functions as BACKSPACE in an edit control. Such dialog boxes must override the Back key by sending the SHCMBM OVERRIDEKEY message to its menu bar. When the dialog box receives the overridden Back key (as a WM HOTKEY message), it must call SHSendBackToFocusWindow to send the Back key to the control with focus. For an example of how to handle the overridden Back key, see the code sample in the section that follows. - For dialog boxes without edit controls or message boxes, if the user presses the Back key, the dialog or message box is sent a WM COMMAND/IDCANCEL message. Dialog boxes and message boxes typically close when this message is received. For an example of how to handle the WM COMMAND message, see the code sample in the section that follows.

3.5.3

Multi Language Support

The Multilingual User Interface is a feature that gives the end user the ability to change the language of the User Interface. For example, an end user working with an English UI will be able to change the language of the UI to Spanish. To make this possible, the MUI uses a single core binary that includes the system default language together with one resource dynamic-link library (DLL) per additional target language. The initial boot of the device is generated with the system default language. When the end user selects another language, the new language goes into effect after the device is reset. Obviously, the switch requires recreating windows, menus, and dialog boxes with the newly loaded resources. In addition, to be considered successful, the language switch must display these elements with the correct fonts and with the correct locale-specific information. The resource DLL for an application must be named the same as the application with the ”.xxxx.MUI” suffix added, where xxxx is the 4-digit hex locale code for the resource language. For example an application called MYAPP.EXE that wanted to support US English, French and Japanese, would supply DLLs named: MYAPP.EXE.0409.MUI, resources in English MYAPP.EXE.040C.MUI, resources in French MYAPP.EXE.0411.MUI, resources in Japanese The main problem with this solution is that the user must reset his Smartphone. Home-made localization We prefer that when the user change the language, the changes happen immediately. We can gather all string of the application, in the String Table Resource. So these strings depend of a language, and are localizable. Another solution for

DESS IRS

18

January 2004

Chapter 3. SmartPhone

multi-language, is to set the control’s label at runtime, depending on the chosen language. There is a little problem : controls may be localizable. But if we following the guidelines, there’s only one control by row, so control can take all the width’s screen. Thus, the problem doesn’t apply. To arrange locale string, there are two solution: • We chose a numerical range for each language. When we add a new language, we just have to add another range. But when the number of string is too many, a range overlaps another one. • For a string, we set the value of all the languages. We chose a separator character. When we add a new control label, we add a new string. When we add a new language, we have to add for each locale string, the new language value. This solution seems to be correct. The separator character chosen is ’:’. example : ”Password:Mot de Passe:Kennwort:Passwuert:” remark : because the LoadString function doesn’t always return a null terminated string, it is convenient to write the separator at the end of the string. It facilitates the extracting of the locale resource.

3.5.4

Handling windows messages

Because we can’t use MFC, and as neither WTL nor ATL are convenient to use, we have to deal with WIN32 API for creating applications, windows or dialog, and especially event handling. Win32 or Object Oriented ? A Windows program is event-driven. It means that the application, are supposed to be on the defensive. The end user will send events to Windows with various input actions, and Windows will send to your program messages corresponding to these actions. The program have to respond to these messages. Windows convert each event into a message consisting in 3 variables : Msg, lParam, wParam. Msg is an unsigned int, lParam and wParam are double word. The big trouble is that the API is absolutely not Object Oriented. All these messages end up in a message queue. Windows keeps a message queue for every running application (for every thread). We have to retrieve these messages one-by-one in what is called a message loop. The program has to call the GetMessage function to retrieve a message. Then it must call the DispatchMessage function to give it back to Windows. Then Windows sends back the control to the application through a Callback. A Callback is a function that we pass to Windows, for each created dialogs or created windows.

DESS IRS

19

January 2004

Chapter 3. SmartPhone

Figure 3.4: Event Handling

It becomes fastidious (especially when we are not familiar), for each window or dialog, we must write a callback method. For each message that we want to handle, we have to test the low-order word, high-order word of the wParam and the lParam, in order to identify the message. For developing, easily and quickly, we need a window toolkit to help us.

3.5.5

Genese of NWT

A basic dialog class was written for handling window messages. It provides an Object Oriented style like Java AWT. Like Abstract Window Toolkit to handle an event, we just have to override a method, that will called when the event occurs. It is very convenient. The differences here, is that it doesn’t use the Observer/Observable pattern, Listener needn’t to register for subject. Only one class for dialog was written. A generic method that does the callback jobs was written. It handles the following event : • initialization of the dialog for first drawing. (WM INITDIALOG) • the dialog gets the focus and is activated. (WM ACTIVATE) • the dialog is being closed. (WM CLOSE) • and WM COMMAND : Button press, Change selected item on a list box, radio button change, check box modification, menu item activation. We suppose it is a minimal event handler, for starting developing application. This class also support the multi-language previously specified.

DESS IRS

20

January 2004

Chapter 3. SmartPhone

Figure 3.5: Class diagram

3.5.6

Resolving Callback

Callback is a problem when passing from standard C to C++. In our class, the callback is a method. We can’t pass the callback method to the dialog’s creation function (DialogBox()). The reason is simple, the calling convention differs between C and C++. In C, a function use cdecl invokation. In C++, a method use stdcall invokation. There isn’t any casting possible. The only solution is to define a callback function that invokes a callback method. To do this, the callback must know to which object it has to send the message. Unfortunately, due to message queue system, we can’t bind callback with an object, without lost the dialog handle (HWND). The only solution we’ve found is to define a dialog object in global scope.

3.5.7

Using NWT Dialog

There was a counterpart of using this basic Dialog class. There are some steps to follow to use it correctly : 1. Preparing dialog : • to design the elements with the IDE (dialog, control, menu, ...), • to override the base class CDialogNWT, in header file #include "DialogNWT.h" class CDlgSample : public CDialogNWT • to define the callback in header file, BOOL CALLBACK DialogSampleProc(const HWND hWnd, const UINT Msg, const WPARAM wParam, const LPARAM lParam); DESS IRS

21

January 2004

Chapter 3. SmartPhone

• to declare a global object in source file of the inherited class (CDlgSample here), CDlgSample g_dlgSample; • to implement the callback that calls the generic method in CDialogNWT, in source file of the inherited class (CDlgSample here) BOOL CALLBACK DialogSampleProc(const HWND hWnd, const UINT Msg, const WPARAM wParam, const LPARAM lParam){ g_dlgSample.m_hWnd = hWnd; return g_dlgSample.DialogProcMsg(Msg, wParam, lParam); } 2. Calling Dialog (for showing) in the client context source file : • to define the global object as extern and include the header #include "DlgSample.h" extern CDlgSample g_dlgSample; • to define instance handle as extern (if not yet) extern HINSTANCE g_hInst; • to call DialogBox with the resource dialog’s ID, the menubar’s ID, the callback and the current windows handle (parent handle for the new dialog). g_dlgSample.m_uiMenuBarId = IDR_OKCANCEL_MENUBAR; DialogBox(g_hInst, MAKEINTRESOURCE(IDD_DLG_SAMPLE), m_hWnd, (DLGPROC)DialogSampleProc); And now we are able to write the event handler, by overriding the virtual method of CDialogNWT (by default they do nothing). These virtual methods receive in parameter, the resource control’s ID responsible of the event.

DESS IRS

22

January 2004

Conclusion

23

Glossary A ATL

Active Template Library, p. 10.

C COM

Component Object Model, p. 9.

CORBA

Common Object Request Broker Architecture, p. 3.

J J2ME

Java 2 Platform, Micro Edition, p. 3.

JAF

JavaBeans Activation Framework, p. 27.

M MFC

Microsoft Foundation Class Library, p. 9.

MUI

Multilingual User Interface, p. 18.

O OLE

Object Linking and Embedding, p. 14.

R RMI

Java Remote Method Invocation, p. 3.

S SOAP

Simple Object Access Protocol, p. 3.

U UI

User Interface, p. 18.

24

GLOSSARY

W W3C

World Wide Web Consortium, p. 13.

WAP

Wireless Application Protocol, p. 3.

WTL

Windows Template Library, p. 19.

DESS IRS

25

January 2004

Appendix A Using Tomcat and invoking Luxdeal web-services

F

or a complete example of installation, please visit the SoapUser website[5].

A.1

local directory

Create a soap directory on your machine. We will refer to it as %soap% for the remaining of the installation procedure.

A.2

Installing Apache Tomcat

Just get the latest version of Tomcat[6] and decompress it to the %soap% directory. Everything will be contained in a subdirectory named jakarta-tomcat-5.0.x. You can use the scripts located in the bin subdirectory to test Tomcat[6]. Note that your Tomcat[6] server will run and listen for requests on port 8080.

A.3 A.3.1

Deploying the SOAP Webapp to Tomcat Download and install Apache SOAP

Download the Apache SOAP [8] for Java package and unpack it to the %soap% directory. Everything will be contained in a subdirectory named soap-2 3 .x. You must have the file soap.jar in the lib subdirectory!

A.3.2

Download and install libraries required by Apache SOAP

javamail Download JavaMail [12] and unpack it to the %soap% directory. Everything will be contained in a subdirectory called javamail-1.3. You must have the file mail.jar in this subdirectory! 26

Chapter A. Tomcat

JAF Download JAF[13] and unpack it to the %soap% directory. Everything will be contained in a subdirectory called jaf-1.0.2. You must have the file activation.jar in this subdirectory! Xerces Download Xerces[14] and unpack it to the %soap% directory. Everything will be contained in a subdirectory called xerces-1 2 3. Follow the SoapUser website[5] recommandation and do not choose a later version of Xerces-J. You must have the file xerces.jar in this subdirectory!

A.4

Deploy the SOAP Webapp to Tomcat

We need to supply Tomcat with the SOAP webapp modules. To do this simply copy the soap.war file from %soap%\soap-2.3\webapps to %soap%\jakarta-tomcat5.0.x\webapps.

A.5

Using Tomcat within Eclipse

Download a stable release of Eclipse[15]1 and unpack it where you want, commonly your ’program files’ directory.

1

2.2, not 3.0

DESS IRS

27

January 2004

Chapter A. Tomcat

A.5.1

The Sysdeo Plugin

A simple way to use Tomcat[6], create and test Webapps is to use Tomcat Launcher Plugin[16] from Sysdeo[17]. After the installation of this plugin (you just have to unpack it to the plugins directory of Eclipse[15]), you have to configure it: • go to Window-Customize perspective. . . • in the menu Other, check Tomcat. You will see three new icons in the menu bar:

Figure A.1: Launching Tomcat with Eclipse

DESS IRS

28

January 2004

Chapter A. Tomcat

• go to Window-Preferences • configure Tomcat plugin.

Figure A.2: Configuring plugin to work with Tomcat

DESS IRS

29

January 2004

Chapter A. Tomcat

You have to set a correct classpath to allow Tomcat to use the SOAP applications. Look at this screenshot and add Follow these steps in this order to avoid error with Xerces[14]. • add mysql-connector.jar to classpath AND boot classpath, • add soap.jar, • add mail.jar, • add activation.jar, • add xerces.jar • finally, add jakarta-tomcat-5.0.16\common\lib\servlet-api.jar . Your screen must look like this:

Figure A.3: Setting plugin classpath

DESS IRS

30

January 2004

Chapter A. Tomcat

A.6

Deploying Luxdeal within Eclipse

You have to create a new project: • create a new Tomcat project, nammed Luxdeal. • unpack Luxdeal.zip. This will create a ’Luxdeal’ directory with all necessary sources within. • import this directory into the Luxdeal project. • add the Eclipse\workspace\luxdeal\WEB-INF\classes directory to classpath AND boot classpath, in the Tomcat configuration. Before running Tomcat, check the ’web.xml’ file and set the parameters according to your mysql configuration. Now you can start Tomcat. If all is well done, you will see a little message in the dialog box, saying the connection to the database was sucessfull.

Figure A.4: Tomcat startup

To deploy Luxdeal services, just launch ’Deployer.java’. You can test it by lanching the clientTest with parameter: http://localhost:xxxx/soap/servlet/rpcrouter xxxx is the port listening for soap requests, 8080 by default or anything else if you want to use TcpTunnelGui.

DESS IRS

31

January 2004

Appendix B Deploying SmartPhone B.1

F

Connecting the Smartphone to the Local Area Network

rom the Home Screen on the Smartphone,

• Press ”Start”, • Select ”Settings”, • Select ”Data Connections”, • Press ”Menu” and ”Edit Connections”, • Select ”Proxy Connections”, • Press ”Menu” and ”Add” Fill in the form.

32

Chapter B. smartphone

Figure B.1: Connection

Type any text into ”Description” Edit Box. Select in ”Connects From”, ”My Corporate Network” (SP2002) or ”Work” (SP2003). Select in ”Connects To”, ”The Internet”. Press ”Done” until get back to Start Menu. It is done.

DESS IRS

33

January 2004

Chapter B. smartphone

B.2

setting up the output linked file directly in the smartphone accessories directories

In the Visual C++ Menubar: select Project –¿ Settings select the configuration (on the top left, ”Settings For”) for which the settings should apply (Debug, Release, Target). All configurations may be chosen. select ”debug” tab in the project settings panel. In the ”General” Category, replace the Download directory default value : \Storage\Application Data\Volatile\ by \Storage\Windows\Start Menu\Accessories

B.3

adding a library to the project

In the Visual C++ Menubar, select Project –¿ Settings select the configuration (on the top left, ”Settings For”) for which the settings should apply (Debug, Release, Target). All configurations may be chosen. select ”link” tab in the project settings panel in the ”General” Category, the required *.lib, must be declared in the library modules.

DESS IRS

34

January 2004

Chapter B. smartphone

B.4

Using Visual’s Resource editor

Edit the String table :

Figure B.2: The String table

In the workspace view, in the resource tab, in the expanded resources folder, in the expanded string table folder, double click string table item. To add an item, double click on the last table item (a blank item) and set ID, and caption. The value is automatically set by Visual.

B.4.1

Importing a Bitmap

In the workspace view window, in the resource tab right click on project’s resources. Select import and browse to the requested bmp file (luxdeal splash screen : 176x220x256)

DESS IRS

35

January 2004

Chapter B. smartphone

B.4.2

Creating a dialog

Figure B.3: Dialog example

In the workspace view window, in the resource tab, right click on project’s resources. Select insert... dialog. In dialog properties: style : popup border : none ID : IDD DLG $name Other properties are default settings.(dialog is : 101x93) Chose a control in the control panels and place the selected control to its place in the frame.

DESS IRS

36

January 2004

Chapter B. smartphone

B.4.3

Inserting a menu bar

Figure B.4: Menu bar example

In the workspace view window, in the resource tab, right click on project’s resources. Select insert... menu bar. In menu properties: ID : identifier caption : name for UI control For node menu item, default settings. For leaf menu item, uncheck popup property.

B.4.4

Adding a spin list control to a dialog

The spin list control doesn’t exist in the resource editor. But there is a way to add this spin list. In the resource editor, add a list box control. In the list box properties, in the ”styles” tab, uncheck ”Vertical scroll”. Add a spin control at the right end of the list box, and close the resource editor. Open the rc file of the project in a text editor (notepad), and look for the IDD DIALOG DIALOG DISCARDABLE, where IDD DIALOG is your dialog identifier. Look for the spin control that has been added: CONTROL ”Spin1”,IDC SPIN,”msctls updown32”,UDS ARROWKEYS,85,7,9, where IDC SPIN is the spin identifier. Replace the 4th field of the CONTROL statement by : UDS SETBUDDYINT | UDS ALIGNRIGHT | UDS AUTOBUDDY | UDS ARROWKEYS | UDS HORZ | 0x200

DESS IRS

37

January 2004

List of Figures 1.1 SOAP exchange . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.2 Example of SOAP transaction . . . . . . . . . . . . . . . . . . . . . .

4 6

2.1 2.2

Server Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . Luxdeal Web-service Architecture . . . . . . . . . . . . . . . . . . . .

7 8

3.1 3.2 3.3 3.4 3.5

Class Diagram . . . . . Sequence initialization Execution example . . Event Handling . . . . Class diagram . . . . .

A.1 A.2 A.3 A.4 B.1 B.2 B.3 B.4

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

15 16 16 20 21

Launching Tomcat with Eclipse Configuring plugin to work with Setting plugin classpath . . . . Tomcat startup . . . . . . . . .

. . . . . Tomcat . . . . . . . . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

28 29 30 31

Connection . . . . The String table . . Dialog example . . Menu bar example

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

33 35 36 37

. . . .

. . . .

. . . . .

. . . .

. . . . .

. . . .

. . . . .

. . . .

. . . . .

. . . .

. . . . .

. . . .

. . . . .

38

. . . . .

. . . .

. . . . .

. . . .

. . . . .

. . . .

. . . .

Bibliography [1] Windows software mobile for smartphones. http://www.microsoft.com/ windowsmobile/products/smartphone/default.mspx. 3, 9 [2] Java 2 platform, micro edition (j2me). http://java.sun.com/j2me/. 3 [3] The w3c organization. http://www.w3.org. 4, 13 [4] Soap w3c recommendation. http://www.w3.org/TR/SOAP/. 4 [5] Soapuser website. http://www.soapuser.com/. 4, 26, 27 [6] Tomcat, version 5. http://jakarta.apache.org/tomcat/index.html. 7, 26, 28 [7] Easyphp homepage. http://www.easyphp.org/. 7 [8] Apache soap for java package,version-2.3.1. http://xml.apache.org/soap/ index.html. 8, 26 [9] compatibility issue with ksoap. http://ksoap.enhydra.org/software/ documentation/round-2-base/index.html. 8 [10] Microsoft developer network. http://msdn.microsoft.com/. 10 [11] Smartphone developer network. http://www.smartphonedn.com/. 11 [12] Javamail api 1.3.1. http://java.sun.com/products/javamail. 26 [13] Javabeans activation framework 1.0.2. javabeans/glasgow/jaf.html. 27

http://java.sun.com/products/

[14] Xerces 1.2.3. http://xml.apache.org/xerces2-j/index.html. 27, 30 [15] The eclipse project homepage. http://www.eclipse.org/. 27, 28 [16] Sysdeo eclipse tomcat launcher plugin. http://www.sysdeo.com/eclipse/ tomcatPlugin.html. 28 [17] Sysdeo web site. http://www.sysdeo.com. 28

39