0% found this document useful (0 votes)
6 views67 pages

Full NET Wireless Programming 1st Edition Mark Ridgeway Ebook All Chapters

Programming

Uploaded by

ekersniell4v
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views67 pages

Full NET Wireless Programming 1st Edition Mark Ridgeway Ebook All Chapters

Programming

Uploaded by

ekersniell4v
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 67

Visit https://ebookfinal.

com to download the full version and


explore more ebook

NET Wireless Programming 1st Edition Mark Ridgeway

_____ Click the link below to download _____


https://ebookfinal.com/download/net-wireless-
programming-1st-edition-mark-ridgeway/

Explore and download more ebook at ebookfinal.com


Here are some recommended products that might interest you.
You can download now and explore!

Distributed NET Programming in VB NET 1st Edition Tom


Barnaby (Auth.)

https://ebookfinal.com/download/distributed-net-programming-in-vb-
net-1st-edition-tom-barnaby-auth/

ebookfinal.com

Programming NET Security 1st Edition Adam Freeman

https://ebookfinal.com/download/programming-net-security-1st-edition-
adam-freeman/

ebookfinal.com

Programming MapPoint in NET 1st Edition Chandu Thota

https://ebookfinal.com/download/programming-mappoint-in-net-1st-
edition-chandu-thota/

ebookfinal.com

Wireless Java Programming with J2ME 1st Edition Yu Feng

https://ebookfinal.com/download/wireless-java-programming-
with-j2me-1st-edition-yu-feng/

ebookfinal.com
ASP NET Website Programming Problem Design Solution VB NET
Edition Marco Bellinaso

https://ebookfinal.com/download/asp-net-website-programming-problem-
design-solution-vb-net-edition-marco-bellinaso/

ebookfinal.com

Programming Microsoft ASP NET MVC 1st Edition Dino


Esposito

https://ebookfinal.com/download/programming-microsoft-asp-net-mvc-1st-
edition-dino-esposito/

ebookfinal.com

Programming Microsoft LINQ in NET Framework 4 1st Edition


Pialorsi

https://ebookfinal.com/download/programming-microsoft-linq-in-net-
framework-4-1st-edition-pialorsi/

ebookfinal.com

Object Oriented Programming in VB Net 1st Edition Alistair


Mcmonnies

https://ebookfinal.com/download/object-oriented-programming-in-vb-
net-1st-edition-alistair-mcmonnies/

ebookfinal.com

NET Programming 10 Minute Solutions 1st Edition Russell A.


Jones

https://ebookfinal.com/download/net-programming-10-minute-
solutions-1st-edition-russell-a-jones/

ebookfinal.com
NET Wireless Programming 1st Edition Mark Ridgeway
Digital Instant Download
Author(s): Mark Ridgeway
ISBN(s): 9780782129755, 0782129757
Edition: 1
File Details: PDF, 13.80 MB
Year: 2002
Language: english
.NET Wireless
Programming

Mark Ridgeway

SYBEX®
.NET Wireless
Programming
This page intentionally left blank
.NET Wireless
Programming
Mark Ridgeway

San Francisco • London


Associate Publisher: Richard Mills
Acquisitions and Developmental Editor: Denise Santoro Lincoln
Editors: Brianne Hope Agatep, Susan Berge, Jim Gabbert, Joseph Webb
Production Editor: Leslie E.H. Light
Technical Editors: Robert (Bob) Laberge and Srdjan Vujosevic
Graphic Illustrator: Tony Jonick
Electronic Publishing Specialist: Judy Fung
Proofreaders: Laurie O’Connell, Yariv Rabinovitch
Indexer: Jack Lewis
Cover Designer: Carol Gorska/Gorska Design
Cover Photographer: Tony Stone

Copyright © 2002 SYBEX Inc., 1151 Marina Village Parkway, Alameda, CA 94501. World rights reserved. The author(s) created reusable
code in this publication expressly for reuse by readers. Sybex grants readers limited permission to reuse the code found in this publication or
its accompanying website so long as author is attributed in any application containing the reusable code and the code itself is never distri-
buted, posted online by electronic transmission, sold, or commercially exploited as a stand-alone product. Aside from this specific exception
concerning reusable code, no part of this publication may be stored in a retrieval system, transmitted, or reproduced in any way, including
but not limited to photocopy, photograph, magnetic, or other record, without the prior agreement and written permission of the publisher.

Library of Congress Card Number: 2001096242

ISBN: 0-7821-2975-7

SYBEX and the SYBEX logo are either registered trademarks or trademarks of SYBEX Inc. in the United States and/or other countries.

Openwave, the Openwave logo, and UP.SDK are trademarks of Openwave Systems Inc. All rights reserved.

Netscape Communications, the Netscape Communications logo, Netscape, and Netscape Navigator are trademarks of Netscape Commu-
nications Corporation.

Netscape Communications Corporation has not authorized, sponsored, endorsed, or approved this publication and is not responsible for its
content. Netscape and the Netscape Communications Corporate Logos are trademarks and trade names of Netscape Communications
Corporation. All other product names and/or logos are trademarks of their respective owners.

Internet screen shot(s) using Microsoft Internet Explorer 6 reprinted by permission from Microsoft Corporation.

TRADEMARKS: SYBEX has attempted throughout this book to distinguish proprietary trademarks from descriptive terms by following
the capitalization style used by the manufacturer.

The author and publisher have made their best efforts to prepare this book, and the content is based upon final release software whenever
possible. Portions of the manuscript may be based upon pre-release versions supplied by software manufacturer(s). The author and the pub-
lisher make no representation or warranties of any kind with regard to the completeness or accuracy of the contents herein and accept no
liability of any kind including but not limited to performance, merchantability, fitness for any particular purpose, or any losses or damages
of any kind caused or alleged to be caused directly or indirectly from this book.

Manufactured in the United States of America

10 9 8 7 6 5 4 3 2 1
To the two most important people in my life:
my wife, Marian, and our son, Tyler.
Acknowledgements

any people have contributed to this book along the way. To the good people at Sybex,
M thank you for your ideas, support, and guidance. In particular, thank you to Denise
Santoro Lincoln, who originally suggested the book and got the whole project off the
ground. Thank you also to Leslie Light and Brianne Agatep, who have guided the project
through to completion, gently repaired my many grammatical mistakes, and helped entire
paragraphs make sense. I must also thank Joe Webb, Jim Gabbert, and Susan Berge from
Sybex for doing some of the editorial work on various chapters.
I would also like to thank the various people who have lent their technical expertise in sug-
gesting things I have overlooked, picking up any errors, and making sure that what I have
written about will actually work. In particular: Bob LaBerge, Srdjan Vujosevic, and Michael
Bruce—I would be in trouble without you!
I must also thank the many people at Microsoft who helped out with advice, suggestions,
and technical support at various points along the way. And a big thank you to the various
members of the mobile/wireless developers community—a rapidly growing brood who are
always willing to help each other out with ideas, suggestions, and specialized knowledge.
Finally, I must thank my family for their love, tolerance, and support. I wouldn’t have gotten
there without you.
Contents at a Glance

Introduction xix

Part I Microsoft .NET: The Overview


Chapter 1: What Is .NET? 3

Chapter 2: Microsoft’s End-to-End Mobile Strategy 13

Part II Mobile Wireless Technologies


Chapter 3: Wireless Overview 27

Chapter 4: An Example of Mobile Technology: WAP and WML 45

Chapter 5: Designing for the Mobile Web 81

Part III Introducing .NET Mobile


Chapter 6: Getting Started with the Mobile Internet Toolkit 97

Chapter 7: The Runtime Controls 123

Chapter 8: A Deeper Look at the Mobile Internet Toolkit and VB .NET 157

Part IV Using the Mobile Internet Toolkit


Chapter 9: Data Access with the Mobile Internet Toolkit, Part 1(List Controls) 189

Chapter 10: Data Access with the Mobile Internet Toolkit, Part 2 219

Chapter 11: Using Styles and Templates in the Mobile Internet Toolkit 267

Chapter 12: Creating Custom Controls 287

Chapter 13: Customizing the Device Adapters 303

Chapter 14: Using XML Web Services to Build Distributed Applications 309

Chapter 15: Building Performance Applications 329


Part V Building Applications with the Mobile Internet Toolkit
Chapter 16: Sample Mobile Website: My Computer Shop 339

Chapter 17: The HomeLoanCalculator 371

Chapter 18: MyTipple: A Wine Lover’s Portal 399

Chapter 19: Morris’s Wholesale Fruit & Vege: A Mobile Intranet 437

Chapter 20: MyNewContacts: MyContacts Revisited 479

Chapter 21: RockPaperScissors: An Online Game 515

Appendices
Appendix A: Class Listing for the Mobile Internet Toolkit 533

Appendix B: WML Language Reference 539

Appendix C: Internet References 547

Index 551
Contents

Introduction xix

Part I Microsoft .NET: The Overview 1

Chapter 1 What Is .NET? 3


The .NET Framework 6
Visual Studio .NET 6
SOAP 8
The Mobile Internet Toolkit 9
Summary 11

Chapter 2 Microsoft’s End-to-End Mobile Strategy 13


Understanding Microsoft’s Mobile Strategy 14
Components of Microsoft’s Mobile Strategy 16
Stinger Mobile Phone 17
Microsoft Mobile Explorer 18
Microsoft Mobile Information 2001 Server 19
Pocket PC 20
Handheld PC 21
Windows-Embedded Operating Systems 21
My Internet 23
Summary 24

Part II Mobile Wireless Technologies 25

Chapter 3 Wireless Overview 27


The Mobile Internet 28
The “G” Factors! 30
Current Services 31
x Contents

WAP (Wireless Application Protocol) 31


i-Mode 34
HDML 37
SMS 39
Bluetooth 41
Summary 43

Chapter 4 An Example of Mobile Technology: WAP and WML 45


Getting Started: Tools of the Trade 47
Setting Up: MIME Types and Servers 49
PWS 50
Setting MIME Types in PWS 52
Testing PWS 53
Internet Information Server 5.0 (IIS) 53
Setting Up IIS 55
Setting MIME Types in IIS 55
What Is WML? 56
Simple WML 60
Working with Images in WAP 64
Serving Dynamic WML Using ASP 65
Simple ASP 66
Using Advanced WAP 75
Push Technology 75
User Identification 76
Location-Based Services 76
WML Script 77
Overcoming Some Implementation Issues 77
Redirects 77
Protocol and Device Detection 78
Summary 80

Chapter 5 Designing for the Mobile Web 81


Appropriate Content for Mobile Sites 82
Twelve Tips for Application Design 85
Example Application: The Megapolis Civic Entertainment Guide 86
Technical Aspects to Consider 89
Contents xi

Mobile and Web: Can They Coexist? 91


Summary 93

Part III Introducing .NET Mobile 95

Chapter 6 Getting Started with the Mobile Internet Toolkit 97


Checking System Requirements 98
Introducing the Microsoft Mobile Internet Toolkit 99
Obtaining the Toolkit 99
Toolkit Contents 100
Toolkit Overview 100
The Microsoft Mobile Explorer Content Toolkit 102
Obtaining the Toolkit 103
Using the Toolkit with Visual Studio .NET 103
Supported Devices 105
Getting Started 106
The Toolbox 108
The Mobile Web Form Designer 108
The Properties Window 110
Testing the Application with the Emulators 111
Building a Simple Two-Card Deck 113
Using Code Behind 118
Summary 121

Chapter 7 The Runtime Controls 123


Introducing the Control Categories 125
Container Controls 127
The Form Control 127
The Panel Control 128
Standard Controls 129
The AdRotator Control 129
The Calendar Control 132
The Command Control 132
The Image Control 133
The Label Control 135
The Link Control 135
xii Contents

The PhoneCall Control 135


The TextBox Control 136
The TextView Control 137
List Controls 138
The List Control 139
The ObjectList Control 139
The SelectionList Control 139
Validation Controls 139
The CompareValidator Control 140
The CustomValidator Control 143
The RangeValidator Control 145
The RegularExpressionValidator Control 147
The RequiredFieldValidator Control 147
The ValidationSummary Control 148
Special Controls 150
The DeviceSpecific Control 150
The StyleSheet Control 153
Summary 154

Chapter 8 A Deeper Look at the Mobile Internet Toolkit and VB .NET 157
Components of a .NET Mobile Project 159
Exploring Extensibility 162
What’s New in Visual Basic .NET 162
How Does My Code Compile Under .NET? 166
Can I Port My Existing Code Over to .NET? 167
Differences between ASP.NET and .NET Mobile Web Forms 168
Looking at the Web.config, Global.asax, and AssemblyInfo.vb Files 169
The Web.config File 170
The Global.asax/asax.vb Files 173
The AssemblyInfo.vb File 174
<Assembly: AssemblyVersion(“1.0.*”)> Debugging Our Projects 175
Dynamic Debugging 175
Application-Level Tracing 177
Custom Error Pages 178
Handling Cookies and State Management 179
Cookies 180
Contents xiii

Hidden Variables 181


State Management 181
Managing Device Cache and Redirects 182
Managing Device Cache 182
Managing Redirects 183
Working with Pagination 183
Ensuring Security with the Mobile Internet Toolkit 185
Summary 187

Part IV Using the Mobile Internet Toolkit 187

Chapter 9 Data Access with the Mobile Internet Toolkit, Part 1 (List Controls) 189
Data Binding and the Mobile Internet Toolkit 190
What’s New in ADO.NET? 191
Using the List Control 191
Creating a Static List Using the Items Property 192
Connecting the List Control to a Database 193
Connecting the List Control to an Array 201
Using the ObjectList Control 204
Connecting the ObjectList Control to a Database 204
Setting Up Custom Fields 208
Using the SelectionList Control 210
Paginating a List 214
Summary 216

Chapter 10 Data Access with the Mobile Internet Toolkit, Part 2 219
Setting Up MyContacts 220
The Database 220
Building the Project 221
Accessing Data from DataSets 222
Using a DataView Object to Access Data from a DataSet 229
Customizing the Displayed Text in a List Control 232
Using the DataReader to Access Data 234
Summary of Data Access 236
Modifying Data 236
xiv Contents

Adding a Record via a DataSet 237


Setting Up MyContacts 237
Code for Inserting a New Record 239
Adding a Record Directly 242
Deleting a Record via a DataSet 246
Setting Up MyContacts for Record Deletion 246
Setting Up the Delete Command 248
Deleting a Record Directly 249
Setting Up MyContactsDR for Deleting a Record 249
Updating a Record via a DataSet 251
Updating a Record Directly 252
Full Code Listing for MyContacts 252
Full Code Listing for MyContactsDR 259
Summary 264

Chapter 11 Using Styles and Templates in the Mobile Internet Toolkit 267
Using Styles with the MIT Revisited 268
Creating an External Style Sheet 269
Using Template Sets in Style Sheets 272
Using MobileCapabilities 276
Adding Device Filters 285
Summary 286

Chapter 12 Creating Custom Controls 287


Customizing Controls 288
Creating User Controls 288
Using Inheritance to Create a Custom Control 292
Creating a Composite Control 295
Using Device-Specific Controls That Behave Differently
for Different Devices 301
Building Your Own Original Control 301
Summary 301

Chapter 13 Customizing the Device Adapters 303


Locating the Adapters 304
Compiling the Adapters 305
Contents xv

Deploying the Modified Adapters in a Project 306


Modifying Web.config 307
Summary 308

Chapter 14 Using XML Web Services to Build Distributed Applications 309


Creating a Simple XML Web Service 310
Building the Database 311
Building the XML Web Service 311
Consuming an XML Web Service 316
Web-Service Directories 318
Using the Add Web Reference Dialog 320
The Discovery Files 322
The SOAP Toolkit 327
Summary 328

Chapter 15 Building Performance Applications 329


Caching Output 330
Caching Portions of a Mobile Web Page 331
Session Management 331
Session Variables 332
Application Variables 332
Disabling Session State 332
Using ViewState 333
Additional Performance Hints 333
Page.IsPostback 333
Exception Handling 334
Data Connections 334
Disable Debug Mode 334
Code Behind vs. HTML View 335
Summary 335

Part V Building Applications with the Mobile Internet Toolkit 337

Chapter 16 Sample Mobile Website: My Computer Shop 339


Using a Naming Convention 340
Rationale 340
xvi Contents

Planning the Application 341


Proposed Deck and Card Layout 341
The Database 342
The User Control 343
Creating a WBMP Image 343
Building the User Control 344
Mobile Web Page 1 345
Mobile Web Page 2 347
Mobile Web Page 3 360
Finishing Touches 361
Running the Application 361
Some Considerations 366
Full ASPX Code 366
Summary 370

Chapter 17 The HomeLoanCalculator 371


Rationale 372
Planning the Application 372
WebServiceHomeLoanCalc 372
HomeLoanCalculator 373
The XML Web Service: WebServiceHomeLoanCalc 374
The Mobile Web Page 378
The Code Behind 384
Finishing Touches 391
Running the Application 391
Full ASPX Code Listing 394
Summary 397

Chapter 18 MyTipple: A Wine Lover’s Portal 399


Rationale 401
Planning the Application 402
Creating the Database 404
Setting Up the Images 408
Writing the User Control 409
Setting Up the AdRotator 410
Setting Up the Mobile Web Page 412
Contents xvii

Writing the Code Behind 419


Finishing Touches 429
Running the Application 429
Further Enhancements 433
Full ASPX Listing 433
Summary 435

Chapter 19 Morris’s Wholesale Fruit & Vege: A Mobile Intranet 437


Rationale 438
Planning the Application 439
Building the Database 440
Creating the Mobile Web Page 443
Writing the Code Behind 456
Finishing Touches 466
Expanding and Enhancing the Application 466
Running the Application 467
Full ASPX Code Listing 471
Summary 477

Chapter 20 MyNewContacts: MyContacts Revisited 479


Rationale 480
Planning the Application 480
Building the Database 481
Creating the Login Page 487
Creating the Mobile Web Page 492
Writing the Code Behind 501
Finishing Touches 507
Expanding and Enhancing the Application 508
Running the Application 508
Full ASPX Code Listing for MobileWebForm1 510
Summary 513

Chapter 21 RockPaperScissors: An Online Game 515


Rationale 516
Planning the Application 516
Creating the Images 517
xviii Contents

Creating the Mobile Web Page 518


Writing the Code Behind 522
Finishing Touches 526
Running the Application 527
Full ASPX Code Listing 530
Summary 531
Conclusion 532

Appendices 533

Appendix A Class Listing for the Mobile Internet Toolkit 533

Appendix B WML Language Reference 539

Appendix C Internet References 547

Index 551
Introduction

he lights in the crowded theatre had dimmed and the spotlight was focused on the
T Microsoft evangelists doing their thing on the stage. I had settled a little into my seat
amongst the audience and closed my eyes, waiting for the third coffee of the day to kick in.
All of a sudden, I heard the guy in a suit next to me straighten up in his seat and mutter,
“Amazing!” It was his first introduction to the power of mobile, wireless technologies, and
he instantly reminded me (who had been playing with the technology for the past 18 months)
of just how serendipitous that experience can be.
Imagine all your data, all your applications, and all your work available simultaneously
from a cell phone, a laptop, and a desktop computer. Imagine that your cell phone can be
used as a pocket or handheld PC. Access your organization’s Intranet and obtain information
from the Internet anytime, any place.
The Microsoft evangelists demonstrated an e-commerce system where they placed an
order over the Internet and then used a wireless Pocket PC to process the order at the ware-
house level. A confirmation of the order was sent to the client’s cell phone by the system.
The system just seemed to make so much sense that the guy in the suit muttered to him-
self, “Why aren’t we doing this now?” Around the whole theatre, this sense of excitement
rose as the rest of the demonstration unfolded. Never mind how all of this was supposed to
work—most of these people were playing at the management level and when they get excited
by an idea they expect to be able to point to others and say, “Make it happen.”
But Microsoft did not leave us hanging; they then introduced the next generation technol-
ogy that could help build a total end-to-end solution. Microsoft is by no means the first to
offer powerful tools for developing mobile, wireless applications. However, their .NET tech-
nologies offer possibilities for cross-platform solutions that extend the notion of computing
far beyond where we are today.
With this simple demonstration, Microsoft had succeeded in inspiring another generation
of management with a vision of the long-term, strategic possibilities for their IT budgets.
And for those of us who love to play at the cutting edge of technology, we thrive on new
ideas and exploring new possibilities, and we are more than happy to be the ones that are told
to “make it happen.”
If you haven’t been here before, welcome to the world of wireless and mobile connectivity.
This book that you hold in your hands now is about how to create interactive and dynamic
xx Introduction

applications for the Mobile Internet using some of the new tools being developed by
Microsoft, specifically, Microsoft’s Mobile Internet Toolkit and Visual Studio .NET.
The areas of wireless computing and mobile applications have grown rapidly over the last
five years, and it is expected that by the year 2005, the majority of Internet users will be able
to access the Web from a mobile device.
This creates enormous opportunities for developers wishing to get in on the “ground
floor” of a new technology and opens up exciting possibilities for how people will do business
st
and communicate in the early part of the 21 century.
Microsoft sees mobile technology as a key part of its integrated .NET strategy. The
company no longer views different technologies and platforms as being distinct entities that
operate independently from each other. Working with Microsoft’s mobile technologies
means that we also work with back-end database technologies, desktop application develop-
ment, Web design, distributed application architecture, ASP technologies, and content and
service provision.
To borrow a phrase that is almost irritatingly popular at Microsoft sponsored events: “This
stuff is amazingly cool!”
I even heard the guy in the suit say it. Enjoy the ride!
Mark Ridgeway, December 2001.

Key Terminology
The term wireless can be applied to a wide range of scenarios where computers are connected
by something other than wires. Examples include infrared, radio, and microwave. Wireless
can be used to connect the whole spectrum of digital devices, including desktop computers,
laptops, palmtops, PDAs, and mobile phones.
Mobile device usually refers to any digital device that is small enough to be easily carried
around and possessing its own power supply. This includes laptop computers, PDAs, palm-
tops, and mobile phones.
For our purposes, we are interested in wireless, mobile devices of the pocket-sized variety,
such as PDAs, palmtops, and mobile phones.
We also need to distinguish between online and embedded applications. The development
of embedded applications that exist and run on the device itself is very different from applica-
tions that exist online and are accessed by some form of browser software.
The purpose of this book is to illustrate the building of online sites and applications.
Introduction xxi

Finally, we need to distinguish between the Internet and the Mobile Internet. Internet sites
are mainly built using HTML (Hypertext Markup Language) and are designed for viewing
on conventional computer screens. On the other hand, Mobile Internet sites may or may not
be built using HTML—more likely WML (Wireless Markup Language)—and are designed
for viewing on very small, limited screens.

What Is the Mobile Internet Toolkit?


As part of its .NET development framework, Microsoft has introduced the Mobile Internet
Toolkit.
With the Mobile Internet Toolkit, Microsoft offers mobile developers a “write once, run
anywhere” approach. This is coupled to a drag-and-drop development environment powered
by the developer’s own language of choice.
Currently the mobile world is populated by a growing multitude of devices, each with their
own idiosyncrasies and individual interpretations of the protocols they support. There are
also a number of competing standards. This has resulted in a situation where a developer,
looking to create a widely accessible mobile application or site, needs to write a lot of extra
code and often multiple versions of the same site. Tools have been released by a number of
companies to help developers cope with this problem, and Microsoft has entered this rapidly
expanding market with its Mobile Internet Toolkit.
Microsoft has created a development/deployment environment that simplifies things sig-
nificantly. The developer is able to create their application or site using a combination of
graphical tools and their preferred language (i.e., Visual Basic, C++, C#, etc.). The deploy-
ment aspect of the package then automatically takes care of all the presentation problems.
It identifies the particular device and generates appropriate code (whether it be WML,
HTML, etc.) so that the site/application can be presented on that device.
The mobile developer, using the Mobile Internet Toolkit, no longer needs to have a detailed
understanding of the various mobile languages or keep up with the particular requirements of
the growing list of mobile devices. This enables developers to concentrate on designing the
business logic aspect of their applications and producing meaningful content for their sites.
In addition to the .NET development tools, Microsoft has developed an entire end-to-end
approach for mobile development and deployment. This includes the following packages:
● Microsoft Mobile Information 2001 Server
● Microsoft Mobile Explorer (Web browser for mobile devices)
● Stinger (software platform for mobile phones)
xxii Introduction

● Pocket Internet Explorer and Pocket Office applications for pocket PCs
● Content and services, including MSN Mobile
The company is also conducting ongoing development into related technologies such as
smart cards, location-based services, and speech technologies.

Who Should Read This Book?


First, answer these questions:
● Are you interested in the exciting world of the Mobile Internet? Have you heard about
the possibilities of mobile applications and wonder whether they have a place in your
organization?
● Are you a developer currently using Microsoft tools for application and/or Web develop-
ment? Are you looking for a way to expand your horizons and leverage your skills across
to mobile applications?
● Do you currently design sites for the Mobile Web and are you interested in whether
Microsoft offers a more powerful and/or simpler solution?
● Have you dabbled a little bit with Web design, maybe had a little exposure to scripting
languages such as VBScript, and want to find out more about building sites for mobile
devices?
● Are you a student or a teacher looking for information and projects to build for the
Mobile Web?
You do not need to have a detailed understanding of Visual Basic to read this book, although
it would help if you had some understanding of programming. The beauty of .NET is that
developers are able to use their preferred language to build their applications. All the examples
in this book are fully explained and can be easily rewritten into other computer languages.

Tools Required
To work with .NET and the Mobile Internet Toolkit, you will need to have a few tools:
Software You will need the following:
● A copy of Microsoft’s Visual Studio .NET including the .NET Framework and the
Mobile Internet Toolkit. These may be obtained separately or as part of the Visual
Studio .NET package.
Introduction xxiii

● Emulators for various mobile devices are either provided as stand-alone entities or
included in the SDKs released by various companies. These tools allow developers to
test code for a particular device on their own computer without having to go out and
buy that device. The following are good starting points:
● Mobile Explorer from Microsoft (worth getting as part of the Microsoft Mobile
Explorer Content Toolkit)
● The UP.Browser (http://www.openwave.com)
● The Nokia browser (http://forum.nokia.com/main.html)
● Your computer should be running (in either their Professional, Server, or Advanced
Server guises) Microsoft Windows NT 4, 2000, or XP (each with latest service packs).
Note that NT 4 Workstation is only supported for client-side development. You will
also need a copy of Microsoft’s Web server, IIS 5.0, and Internet Explorer 6 or up.

TIP The Mobile Internet Toolkit and Microsoft Mobile Explorer Content Toolkit can be obtained
directly from Microsoft at http://msdn.microsoft.com/downloads.

Hardware You will need the following:


● A computer powerful enough to run your particular mix of software and operating
system. The minimum recommended specifications for Visual Studio .NET are 450
MHz Pentium II class processor or above, 64MB RAM, and 3GB of installation space
available on the hard drive. Recommended specs are 733 MHz Pentium III class
processor, 128MB RAM, and 3GB hard drive.
● A mobile device capable of accessing the Internet (such as a WAP-enabled mobile
phone) is useful for viewing and testing your applications in “the wild.”

Production Systems For application deployment, a server requires the following


software:
● Microsoft .NET Framework
● The Mobile Internet Controls Runtime component of the Mobile Internet Toolkit

More Information
Sybex has published all the code used in this book on their Website at www.sybex.com/. Search
for this book using the title, author, or the ISBN number (2975), and click the Downloads
button. Once you have accepted the license agreement, you’ll be able to download any of the
code listed in this book.
xxiv Introduction

As with any code published on a Website, be careful when copying and pasting as extra line
breaks can sometimes occur that cause your application to go pear shaped!
A list of developer sites has been included in Appendix C, “Internet References.” Many of
these sites run excellent e-mail lists where people can discuss these technologies and share
problems and solutions. Microsoft runs its own Mobile Internet Toolkit SDK newsgroup
at http://microsoft.public.dotnet.framework.aspnet.mobile which can be accessed
through http://msdn.microsoft.com/newsgroups.

Some Final Points


This book has been written using the beta and release-candidate versions of the Mobile Inter-
net Toolkit and Visual Studio .NET. Inevitably, there will be some differences between these
and the final release versions of these packages. I have attempted to anticipate a number of
these differences and to point them out where they are likely to occur.
Many of the lines of code included in this book are simply too long for the page widths! I
have indicated line breaks in code listings with the following ➥ symbol.
Enjoy the book. I hope you find it a valuable resource as you explore the exciting new
world of wireless and mobile connectivity!
Pa rt I

Microsoft .NET: The


Overview
Chapter 1: What Is .NET?

Chapter 2: Microsoft’s End-to-End Mobile Strategy


This page intentionally left blank
Chapter 1

What Is .NET?
• The .NET Framework

• Visual Studio .NET

• SOAP (Simple Object Access Protocol)

• About the Mobile Internet Toolkit


4 Chapter 1 • What Is .NET?

t the end of the chapter, readers can expect to have achieved a basic understanding of the
A following:
● What Microsoft is hoping to achieve with .NET
● The distributed nature of .NET and the role of new developments such as XML Web
Services
● The role of individual aspects of .NET, particularly relevant to this book such as the
.NET Framework, Visual Studio .NET, SOAP, and the Mobile Internet Toolkit
Before we launch into a study of the Mobile Internet Toolkit portion of .NET, it is a good
idea to have an understanding of the entire .NET package.
In this chapter we will have a look at a broad outline of .NET, some of its key components
and how the Mobile Internet Toolkit fits into the total package.
Microsoft defines .NET as being a five-part strategy consisting of the following:
● The .NET Framework and Visual Studio .NET developer tools
● Server infrastructure—Microsoft’s various server packages
● Building Block Services such as portable user identification (Passport)
● Devices—software products covering a range of different devices
● User experiences—applications such as Office and services such as MSN
Later in this chapter, we will cover the .NET Framework and Visual Studio .NET
package. We will also investigate some of the other key .NET components. In Chapter 2,
“Microsoft’s End-to-End Mobile Strategy,” we will have a more detailed look at server infra-
structure, devices, and some of the building block services and user experiences.
Essentially, .NET represents an integrated approach to software development, deploy-
ment, and usage. Developers no longer need to build applications and services just for a
mobile platform, a Pocket PC platform, or a desktop platform. Each of these is seen as a
greater part of the whole with users able to seamlessly transfer data between the platforms. A
single application might work across these platforms—for example, a messaging system that
communicates delivery instructions from warehouse PCs (personal computers) to the deliv-
ery drivers’ mobile phones via a server. The information entered into the PC might come
directly from a dedicated wireless mobile barcode reader.
.NET is also firmly based on a distributed computing model. Applications can be assembled
from components or XML Web Services that exist on different machines. XML (eXtensible
Markup Language) is the language used to communicate between these XML Web Services,
and Microsoft sees it as the “glue” that makes .NET work. XML Web Services may be either
software components or resources such as data libraries.
What Is .NET? 5

XML Web Services rely on SOAP (Simple Object Access Protocol) to transmit and receive
data and commands within a distributed system. This protocol describes how the data and
commands should be represented using XML. There are a number of other services and tech-
nologies associated with the use of SOAP that are described in the “SOAP” section later in
this chapter.
As an application may consist of a number of XML Web Services accessing a number of
other XML Web Services, which could be spread over a large number of machines poten-
tially across the planet, execution sequences can become a problem. Not everything will
necessarily happen in the correct order. In these scenarios, .NET allows for the synchron-
ous (in sequence) or asynchronous (out of sequence) execution of the various functions.
This needs to be specified in the code during design, but it means that applications won’t
sit there churning away to themselves, waiting for something to come down the pipe, and
locking the user out of doing something else on their machine. Figure 1.1 illustrates how
an application built around XML Web Services might look.

FIGURE 1.1: Web Service: constantly updated


Sample application currency converter; commercial
using XML Web service based at Anne's Accounting
Desktop computers at Tom's
Services
Web Services: Relative
currency values from
Client application:
various world exchanges
Tom's Travel Agency
Customers using
the Internet Web Services: Accommodation
details and prices for various
hotels around the world

Customers using Web Service: Flight details and


the Mobile Internet prices for Royal Cactus Airlines

Tom’s Travel Agency (TTA) is able to give up-to-the-minute quotes on travel


costs using a Web Service-driven application. This application makes use of
a currency converter Web Service provided by Anne's Accounting. This
application draws on other Web Services to give hourly updated figures.
Anne charges users (such as TTA) for accessing this service. TTA also
accesses flight details and prices from their preferred airline and
accommodation costs from a range of worldwide hotels using Web
Services. TTA provides the information to customers from the desktop
computers at the agency, over the Internet, and over the Mobile Internet.
6 Chapter 1 • What Is .NET?

The .NET Framework


The .NET framework is the main environment for building, deploying, and using XML
Web Services. It consists of the following:
● The Common Language Runtime (CLR), the platform’s execution engine; code written
for .NET runs under its control
● The Framework classes
● ASP.NET (Active Server Pages for .NET)
Code is written using ASP.NET. Developers are able to use any .NET Framework-
compatible language to write their applications and can access all elements of the .NET
Framework from their code. Compatible languages include those shipping with .NET such
as Visual Basic .NET, C++ and C# (pronounced “C Sharp”) as well as a range of third-party
languages such as Eiffel that have compilers developed to target the .NET common language
runtime.
WYSIWYG (What You See Is What You Get) tools, such as Visual Studio .NET, work
seamlessly with ASP.NET and developers can use a forms-based approach to build Web
applications similar to how they may have used more traditional tools such as Visual Basic
to build conventional applications in the past. Microsoft refers to these as Web Forms.

Visual Studio .NET


Visual Studio .NET is the principal development tool for .NET. It integrates the formerly
separate Microsoft development platforms (such as Visual Basic, Visual FoxPro, Visual C++,
as well as the new C#) into a single IDE (Integrated Development Environment). You can
build the majority of your applications in Visual Studio .NET, whether it be a traditional
application, a distributed application based on XML Web Services, an XML Web Service or
COM component, or a Website.
Visual Studio .NET 7

It also provides the IDE for building mobile sites and applications using the Mobile Internet
Toolkit.
As illustrated in Figure 1.2, programmers can open Visual Studio .NET, and choose the
type of project they wish to build (such as a Windows application or XML Web Service) and
the language they wish to build it in. You can even change languages within a project where
necessary or use a non-Microsoft language (such as Eiffel).

FIGURE 1.2:
Developers have the
choice of project type
and language in Visual
Studio .NET.

In addition, Microsoft has included a new language in Visual Studio .NET, C#. This
language is designed to bring a simpler, more RAD (Rapid Application Development)
approach to the world of C/C++ programming. It is object-oriented, is type-safe, and offers
automatic garbage collection. As you can see in Figure 1.3, if you have previously used any
of the Microsoft visual development tools, the new Visual Studio .NET interface is very
familiar.
8 Chapter 1 • What Is .NET?

FIGURE 1.3:
The Visual Studio IDE

SOAP
SOAP (Simple Object Access Protocol) is a lightweight protocol for exchanging data in a
distributed heterogeneous environment. It provides a set of rules (or grammar for XML)
about how data and commands should be represented. In the past, distributed computing
has run aground because the objects required are unable to be accessed through the firewalls
and security protocols set up (quite rightly!) around many networks. SOAP now allows these
objects to transmit their data or receive commands via Port 80 (the HTTP port that any
network administrator wishing to use the Internet would normally leave open).
New XML Web Services are set up with SOAP already incorporated into them. Existing
COM objects can be given a SOAP “wrapper” (using Visual Studio .NET) that enables them
to be used as a distributed XML Web Service.
Microsoft has other members of the SOAP “family” that work alongside the protocol to
help make it possible for developers to actually find and use available XML Web Services in
their applications:
WSDL Another XML “grammar” (set of rules for XML) is WSDL (Web Service
Description Language). WSDL is used to expose the capabilities of an XML Web Ser-
vice. For example, we might have an XML Web Service that has some function called
“calculate” that requires three variables a, b, and c. We would talk to the XML Web Ser-
vice using WSDL to find out about this function and what its requirements were.
The Mobile Internet Toolkit 9

Disco Disco, which is short for SOAP Discovery, is used to locate descriptions for XML
Web Services. When an XML Web Service is created, a file with the extension .disco is
also generated. This file enables the WSDL description files for a particular site to be auto-
matically located when someone wishes to make use of the XML Web Services in a distri-
buted application. (This assumes that the owner of the site is willing to allow the use of his
or her XML Web Services in some other distributed application!)
UDDI UDDI (Universal Description, Discovery, and Integration) is a directory service to
provide the location of a whole range of XML Web Services. They are categorized into vari-
ous types of information and services. For more information, see http://www.uddi.org/.

The Mobile Internet Toolkit


The Mobile Internet Toolkit is all about developers being able to write a single site or appli-
cation for the mobile Internet that is viewable on any device irrespective of its individual
idiosyncrasies, platform, supported protocols, languages dial tone, case color, etc.
In principle, we could write a single site viewable on the “big screen” Internet as well as the
mobile Internet using this “write once, present anywhere” approach. In practice however, we
need to keep our desktop Internet sites and mobile Internet sites as separate entities unless
we are intent on wishing unsatisfactory browsing experiences on our site visitors! It may be at
some point in the future that the two may begin to converge, but at the moment they are two
quite separate mediums in the way they are used and the information they can convey.
Mobile applications are built in ASP.NET using a special set of mobile controls. The con-
trols are added to a Mobile Web Form (which is a particular type of ASP.NET Web Form)
and then coded “behind” using the development language of choice. We will be using Visual
Basic .NET in this book.
The Mobile Internet Toolkit SDK consists of a set of server-side mobile controls, the
Mobile Web Forms Designer, a tutorial, and relevant documentation. It is included as part
of the Visual Studio .NET package. Although it is possible to write the code for the Mobile
Internet Toolkit using any text editor (such as Notepad), it is a lot simpler to graphically
build the mobile site or application using Visual Studio’s standardized IDE.
If you are particularly keen to hand write applications using a standard text editor, the
Mobile Web Forms are saved with the same .aspx file extension used now for all ASP.NET
Web Forms. (Note: this is different from the old .asp extension used for Active Server Pages
pre-.NET.) The “code behind” needs to be saved in a file using the extension of the language
that you have used (.vb for Visual Basic and .cs for C#). This then needs to be compiled,
which can be done from the command line, but I’ll let you chase up the appropriate Microsoft
10 Chapter 1 • What Is .NET?

documentation on how to do it yourself! It then needs to be placed in a “bin” directory inside


the directory containing the Mobile Form. This can then be opened via your Web server as
will be explained later in Chapter 4, “An Example of Mobile Technology: WAP and WML.”
As the mobile environment is a rapidly expanding and changing field, the Mobile Internet
Toolkit has been designed to support a wide range of platforms and devices. It is also exten-
sible and allows for the further inclusion of new devices as they are developed.
Applications and sites built using .NET can be tested using “real devices” or emulators such
as the Mobile Explorer emulator or the Openwave emulator (as illustrated in Figure 1.4).

FIGURE 1.4:
The UP.Simulator,
an example of
Openwave’s mobile
emulator
Summary 11

Mobile applications are usually built-in “decks” of “cards” with each card representing the
Internet equivalent of a page. Each deck is in fact a single page of code, so in HTML terms,
it would be like writing your entire Website onto a single page of code and only using a sec-
tion of the code to represent each page of the site. The Mobile Internet Toolkit allows this to
happen by permitting developers to place multiple form controls onto a single Mobile Form
Web page. As controls are added to the forms on the page, each control has a runat=server
attribute declared to ensure that they are executed as server-side code.
The result is a streamlined development environment with drag-and-drop controls onto a
single form (or multiple forms if you wish). The business logic and content can then be added
in the traditional “code behind” approach used with Microsoft development tools. Developers
already schooled in ASP.NET have very little to learn before they begin developing sites and
applications for the mobile Internet. The adaptive rendering of the Mobile Internet Toolkit
handles device detection and appropriate presentation of the code for any mobile device.

Summary
Microsoft’s .NET brings together a range of development tools, platform software, and ser-
vices under one integrated umbrella. The developer can now create user-centric applications
that are designed to work across a particular environment rather than just on a particular plat-
form. Developers are able to use the tools and languages of their choice within the single IDE
of Visual Studio.NET. At the wider level, XML Web Services and their associated protocols
open up the real possibilities of building and using distributed applications across the Internet.
The strong mobile focus of .NET and the creation of a set of dedicated tools simplify devel-
opment in this area and help to ensure that any software solution is able to be equipped with
mobile capability where appropriate.
This page intentionally left blank
Chapter 2

Microsoft’s End-to-End
Mobile Strategy
• Understanding Microsoft’s Mobile Strategy

• Working with Components of Microsoft’s Mobile Strategy


14 Chapter 2 • Microsoft’s End-to-End Mobile Strategy

he purpose of this chapter is to introduce Microsoft’s strategy for mobile devices and to
T investigate some of its key components. By the end of the chapter, the reader can expect
to have some understanding of Microsoft’s philosophy in this area, which is designed to tar-
get each aspect of mobile application development and delivery. Microsoft is working closely
with hardware manufacturers to jointly produce products (such as mobile phones and hand-
held computers) that run its software on its operating systems. These products, in turn, are
linked very closely with other products (such as servers) also running on and using Microsoft
software. Lastly, Microsoft is also working at the service end to create and provide a range of
both free-to-air and commercial (paying) services available over the Internet to the full range
of devices and platforms capable of accessing the Web.
Readers will also be taken through various individual examples of Microsoft’s strategy with
a view to developing a closer understanding of how it all fits together. The examples include
the following:
Stinger Microsoft’s mobile phone platform.
Microsoft Mobile Explorer Microsoft’s Internet browser for mobile devices.
Microsoft Mobile Information 2001 Server Server platform specifically developed for
mobile devices.
Pocket PC PDA style mobile devices.
Handheld PC Small, portable computers.
Windows Embedded Operating Systems Various flavors of embedded operating
systems developed by Microsoft to run mobile and industrial devices.
My Internet An example of a commercial service being developed and offered by
Microsoft over the Internet.

Understanding Microsoft’s Mobile Strategy


Microsoft’s strategy for mobile technology goes far beyond just a development platform. It
also includes platform software for mobile devices, applications, server software and services
such as e-mail notification. Microsoft is also committed to ongoing research and develop-
ment in the field. Figure 2.1 is a screen shot of the emulator for Microsoft Mobile Explorer
that forms one plank of this strategy.
Understanding Microsoft’s Mobile Strategy 15

FIGURE 2.1:
The Mobile Explorer
Emulator

In Microsoft’s vision and strategy documentation for mobile technology, “Microsoft Vision
and Strategies for Mobile Technology,” Microsoft says its strategy is “to extend, connect, and
innovate.” This documentation can be found at http://microsoft.com/business/mobility/
vision.asp. The company expands these key words with the following descriptions:
● “To extend the communication and collaboration potential of the more than 80 million
users of MSN, MSN Hotmail, Microsoft Outlook, and Microsoft Exchange Server.”
● “To connect users to the information they want, when and how they want it.”
● “To innovate towards a new synergy among the platforms, applications, and tools of the
computing and wireless industries.”
Note that the italics are mine.
The company’s aim is to seamlessly connect people to their data and information irrespec-
tive of the device they are using. It has identified four categories of wireless players that it is
targeting with various services and technologies:
● Content and service providers
● Device manufacturers
Exploring the Variety of Random
Documents with Different Content
república; pero pasad adelante en
tanto que esto se remedia.
Lerma.—Es tanta la iñorancia
desta gente de quien hablamos,
que en lo que decían saber más
es en lo que menos saben,
porque la principal parte que han
de tener es en el conocimiento de
las hierbas y plantas y raíces y
piedras; notorio está que la mayor
fuerza de la medicina consiste en
ellas, y tanto que, según dice
Rasis en el segundo de los
anforismos, trayéndolo por
auctoridad de aquel gran filósofo
Hermes, si se conociesen bien las
propiedades y virtudes de las
hierbas y plantas, curarían los
médicos con solas ellas, de
manera que pareciese que
curaban con arte mágica; pues si
esto es assí, al médico conviene
ordenar y á los boticarios poner
en efeto lo que ellos ordenassen,
lo cual pueden muy mal hacer si
no conocen destintamente las
plantas y las hierbas y las raíces y
piedras, y aun las condiciones y
propiedades dellas. ¡Oh cuántos y
cuántos boticarios de los buenos
se engañan en tener unas hierbas
por otras, y en no conocer y
entender muchas dellas! ¿Que
harán los que no lo son? ¿Y esto
de donde pensáis que procede?
De que no saben gramática para
entender los libros que tratan
dellas, ó si la saben, porque les
falta la experiencia, que ni nunca
las han buscado ni visto, y
cuando las buscan, hallan
algunas que se parecen unas á
otras en las hojas, en el tamaño y
en las flores y en el olor, y por
ventura son tan distintas y
diferentes en las propiedades,
que la una mata y la otra sana, y
los mezquinos de los enfermos
han de estar sujetos á la simpleza
de un boticario, si acierta ó no
acierta, y no solamente los
enfermos, pero los médicos, que
desto y de otras muchas cosas
nos ponen la culpa, sin tenerla.
D. Gaspar.—¿Y qué pueden
hacer para esso los
protomédicos?
Lerma.—Yo lo diré. Que al que
examinasen, no había de ser ni
en un día, ni en ocho, ni aun en
quince, y también le habían de
examinar de la teórica como de la
prática, y de la experiencia como
de la ciencia; mostrándole mucha
cantidad de hierbas juntas, á lo
menos de las que más le traen en
uso, para que apartasen las unas
de las otras, y las nombrassen
por sus nombres y dixesen los
efectos que tienen y en qué
pueden servir en las medicinas,
pues tienen á Dioscórides y á
Plinio y á Leonardo Susio, y á
otros muchos que tan buena
noticia les dan de todas ellas, si
ellos las hubiesen buscado y
tratado para conocerlas. Pero el
mal es que nunca las buscan sino
cuando tienen necesidad dellas, y
por esto caen en tantos yerros, y
tan perjudiciales como aquí he
dicho. Lo mismo habían de hacer
en las piedras y raíces y gomas y
licores, y en todas las otras
medicinas; y dexando los
pecados que hacen en esto por
iñorancia, líbrenos Dios de los
boticarios que no tienen respeto
sino adquirir y ganar haciendas,
que la avaricia y codicia les hace
dejar de usar fielmente sus
oficios, porque éstos son aquellos
de quien dice Jacobo Silvio en el
proemio de su obra que hizo de
las cosas que tocan á este arte,
que se pueden llamar carniceros
y verdugos los boticarios que no
saben ni usan bien su obligación,
porque de lo que aprovecha es de
matar los hombres sin ningún
respeto ni piedad.
Verdaderamente, si no tienen
conciencia y fidelidad, y si han ya
perdido el temor de Dios por el de
los dineros, no hay cosa más
cruel que sus manos, más sin
piedad que su intención ni más
abominable que sus hechos,
porque no dan medicina que sea
buena, ni que haga buena
operación. Lo que los médicos
hacen, ellos lo dañan, ellos
destruyen la buena cura. Y
porque más claramente se
entienda quiero decir algunas
particularidades, pues que para
decirlas todas sería menester
muy largo tiempo. Tienen por flor
una cosa que diré, y es que
cuando un médico quiere recentar
una purga ó píldoras, ó otra cosa,
y pide las medicinas que entran
en ella para verlas, suele decir:
¿Tenéis buen reubarbo ó buen
agárico? Mostradlo acá. Y
entonces el boticario saca tres ó
cuatro pedazos que no valen dos
maravedises, y entre ellos uno
que es muy bueno, y antes que el
médico hable le dice: Señor, todo
el reubarbo es tal que no hay más
que pedir; pero este boleto dél es
el mejor del mundo, y por tal me
ha costado á tanto precio; dél se
podrá gastar en esta purga lo que
vuesa merced mandare. El
médico le dice: Pues echad dél
una dracma, ó media dracma
como ves que es menester; y en
volviendo las espaldas, el
boticario guarda aquello bueno y
echa de lo malo, de manera que
con un pedazo bueno vende
cuanto reubarbo tiene que no vale
nada, porque después que lo
muele y se echa en la purga, mal
se puede ver si era de lo uno ó de
lo otro.
D. Gaspar.—Si no se pudiera ver,
á lo menos podráse sentir en la
disposición y salud del enfermo,
pues no hará tan buena operación
lo malo como lo bueno.
Lerma.—Lo mesmo que digo
hacen en la escamonea, en el
acíbar y en todas las otras
medicinas desta suerte.
Pimentel.—¿Y en la cañafístola
hay algún engaño desos?
Lerma.—Si sueltan la rienda al
deseo de la ganancia, no hay
medicina en sus tiendas con que
no puedan engañar á las gentes,
y en la cañafístola hay lo que
dice. Si se receuta dos onzas
della y es la cañafístola de la
buena, sácale la pulpa necesaria,
y si es de la mala y seca, todo el
peso tiene la caña, y la pulpa no
es casi nada ni hace operación
ninguna, y para engañar á los
médicos ó á los que la compran,
meten la cañafístola en las
cuevas y lugares muy húmedos
porque parezca mejor y pese
más, y así los enfermos con la
cañafístola que les ha de
aprovechar como medicina
benedita, toman la mitad de
humedad que no obra de otra
cosa sino de destruir la salud y el
cuerpo.
Pimentel.—Y en las otras
medicinas simples ¿qué pueden ó
suelen hacer los boticarios?
Lerma.—Lo uno no conocerlas
cuando las compran ó cogen del
campo ó de los huertos en que
nacen; y lo otro, si las conocen,
no entender cuáles sean las
mejores ni las peores para usar
dellas, y lo que peor es, que hay
tantos boticarios tan necios y
iñorantes, que no saben
gramática ni entienden los
nombres de las medicinas en
latín, y cuando les dan las
receutas, por no mostrar su
iñorancia, dexan de echar aquella
medicina simple en el compuesto,
y por ventura es la que en todas
más hace al caso; y éstos tienen
á Mesue y á la declaración de los
fraires, y Antonio Musa y Jacobo
Silvio, y otros cien libros muy bien
encuadernados que no sirven de
más que de auctorizar su botica,
estando obligados á entenderlos
tan bien como los médicos
mismos. Y para que vuestras
mercedes entiendan lo que pasa,
yo sé boticario que, receutando
un médico en su casa cierta
medicina en que hubo necesidad
de poner media onza de simiente
de psilio, él no lo entendió ni supo
qué cosa era, y para salir de la
duda que tenía fuesse á casa de
otro boticario y preguntóle si tenía
psilio. El otro le respondió que sí.
Pues dadme media onza dél y
ved lo que me habéis de llevar
por ella. El otro boticario, que era
astuto y avisado, entendió luego
el negocio y díxole: No os la
puedo dar un maravedí menos de
un ducado, porque por dos
ducados compré la onza, y no os
hago poca cortesía en dárosla sin
ganancia. Pues que assí es, dixo
el que compraba, veis aquí el
ducado y dádmela. El otro lo tomó
y le dió en un papel la media onza
de psilio, y cuando lo hubo
descogido y mirado, vio que era
zaragatona y dixo: ¿Qué me dais
aquí, que esta zaragatona es?
Assí es verdad, dixo el otro que
se le había dado. Pues por cosa
que vale un maravedí, dixo él,
¿me lleváis un ducado? Sí,
respondió el que le había
vendido, que yo no os vendí la
zaragatona, sino el nombre, que
no lo sabíades, y el aviso para un
boticario como vos vale más que
diez ducados. Y aunque sobre
esto hubieron barajas y fueron
ante la justicia, se quedó con el
ducado y reyéndose todos del
boticario nescio que se lo había
dado.
D. Gaspar.—Por cierto él lo
merecía bien por lo que hizo.
Lerma.—No es menos de oir lo
que agora diré, y pasa así de
verdad; que queriendo hacer un
boticario el collirio blanco de
Rasis que aprovecha para el mal
de los ojos, viό que al cabo de las
medicinas que habían de entrar
en él estaba escrito tere sigilatim,
que quiere decir que las moliese
cada una por sí, y él entendió que
le mandaba echar una medicina
que se llamaba tierra sellada, y
teniendo todo junto para
revolverlo, llegó otro boticario, y
conociendo la tierra sellada,
díxole: ¿Qué es esto que hacéis?
En el collirio de Rasis no entra
esta medicina. Y el que lo hacía
porfiaba que sí y que así estaba
en la receuta del collirio. Sobre
porfía lo fueron á ver, donde el
boticario que había llegado de
fuera, conociendo la causa de su
yerro, le desengañó, mostrándole
lo que quería decir tere sigilatim, y
así le hizo quitar la tierra sellada,
y lo que en ello iba era que todas
las medicinas de aquel collirio son
frías, y ésta era cálida y de tal
condición, que bastaba para
quebrar los ojos en lugar de
sanarlos. Otras muchas cosas
pasan cada día desta mesma
manera, porque boticarios hay
que, siendo el espodio de Galeno,
y de los griegos Tucia, y el de
Avicena y los árabes raíces de
cañas quemadas, y el que
nosotros comúnmente usamos
dientes de elefantes, que es
verdadero marfil, ellos hacen otro
nuevo espodio echando los
huesos y canillas, y aun plega á
Dios que no sean de la primera
bestia quo hallasen muerta, y con
esto les parece que tienen
cumplido con lo que deben. Y
cuando vienen á hacer algún
compuesto en que entren muchas
medicinas, algunas dellas les
faltan, otras están dañadas, otras
secas y que les falta la virtud y no
dexan de echarlas sin tener
respeto á que: improbitas unius
simplicis totam compositionem
viciat.
D. Gaspar.—No entendemos
muy bien latín; vuestra merced lo
diga en romance.
Lerma.—Digo que la maldad de
una medicina simple, cuando se
junta con otras, destruye y hace
que no valga nada toda la
composición. Pues si esto es
assí, qué hará en la composición
de los xarabes, y purgas, y
píldoras, que alteran y
descomponen los cuerpos
humanos y más adonde entran
medicinas furiosas, recias y
venenosas, que se desvelan los
médicos por no errar en la cuantía
y en el peso y medida, y los
boticarios, yendo envidada la vida
de un hombre en acertar ó en
errar, no se les da dos maravedís
que sea más ni menos ni que
obren bien que mal. Su atención y
intención es de ganar, y sea como
fuere, que la culpa ha de ser del
médico y no del boticario.
D. Gaspar.—Esso es en las
purgas; pero en los xarabes ¿qué
hacen que no sea bien hecho?
Lerma.—Antes creo que no hay
xarabe que se haga bien en las
boticas de los hombres desta
suerte que he dicho, porque ó no
tienen los zumos tan buenos
como son menester y tan
perfectos como han de ser, ni los
echan en la cantidad que el
xarabe ha de llevar; y en el
azúcar tienen una alquimia que
siempre compran y traen el más
vellaco y más sucio que hallan,
porque con ser para xarabes,
parésceles que es pecado gastar
azúcar bueno y limpio. Y entre
diez xarabes no hallaréis los dos
que tengan el punto necesario.
Pimentel.—En esso parece que
no va tanto, aunque lo mejor sería
que todo fuese perfecto.
Lerna.—En las píldoras hay
también las mesmas faltas que en
las purgas, y aun otras que
parecen mayores, porque demás
de lo que he dicho, hay una
massa de píldoras que se quieren
gastar en haciéndose, y otras que
duran cuatro meses, y otras seis y
ocho y un año y más, pero
cuando passan de su tiempo
sécanse y pierden la virtud y
fuerza las medicinas que allí
están incorporadas, y assí no son
para aprovechar; y los boticarios
avarientos, por no perder el
intereses que dellas se les ha de
seguir, ni gastar en hacer otras de
nuevo, ¿qué pensáis que hacen?
Visitan las cajas donde tienen las
píldoras y miran un rétulo ó
cédula que tienen dentro dellas
en que está puesta la hecha del
año, mes y día, y si es pasado el
tiempo quitan aquella cédula y
ponen otra, por la cual parece que
no ha dos meses que se hicieron,
habiendo por ventura más de un
año que estaban hechas, estando
ya perdidas y corrompidas; y assí
engañan al médico que las pide y
receuta, y al enfermo que con
ellas se cura; y donde han de
hacer evacuar los humores si
estuviesen en su perfición, no
tienen fuerza más de para
alterarlos y moverlos más de lo
que están, en grandísimo daño y
perjuicio de los enfermos y de su
salud y vida. Pues en las aguas
que venden, ¿no hay engaños?
Muchas veces al medio año
acaban todas cuantas han
destilado y hinchen las redomas
de agua de la fuente ó del río, y lo
que les costó una blanca hacen
della tres ó cuatro ducados, y
jamás pedirán cosa ninguna en su
botica que digan que no la tienen
ó por gran maravilla; y dan unas
cosas por otras, diciendo que
tienen la misma propiedad y que
hacen el mismo efecto, y á esto
llaman ellos dar quid pro quo,
mudando las medicinas sin la
voluntad y consentimiento de los
médicos, por no dexar de vender
y hacer dineros. Y por ventura no
halló el licenciado Monardis
tantas medicinas en un diálogo
que hizo que se podiesen poner
unas por otras cuantas hallan los
boticarios porque los que traxeren
dineros á sus tiendas no se
vuelvan con ellos. En los aceites,
si se les van acabando, con poco
que tenga el cántaro ó la redoma,
la tornan á henchir encima del
que se vende en la plaza; y assí
me dixeron á mí de uno que
vendió un gran cántaro de aceite
rosado no teniendo sino un poco
en el hondón, sobre el cual
tornólo á henchir, y revolviéndolo
todo, quedóle un poquito de olor
con que lo pudo vender,
afirmando que era el mejor del
mundo. Y en los ingüentos
también pecan, ó por iñorancia ó
por malicia, que pocas veces
salen en su perfición. Lo mesmo
hacen en los polvos, y finalmente,
no hay medicina ninguna que no
hagan de manera que justamente
se pudiese condenar por falsa si
se pudiesen averiguar los simples
que echan en la composición, á lo
menos si son costosos ó
dificultosos de haber ó de
conocerse. Si mandaren á estos
boticarios hacer una buena triaca,
muchos de ellos no conocerían la
mitad de las medicinas simples
que entran en ella, y plega á Dios
que conozcan las de la confeción
de Hamech, que son menos y
más usadas, y las que entran en
otras confeciones desta suerte.
La triaca de esmeraldas que
venden no creo más en ella que
en Mahoma, si no la viese hacer
por los ojos, y por más cierto
tendría que echan esmeraldas
contrahechas de alquimia ó de
vidrio ó de unas que vienen de las
Indias, que de las finas; y por mi
consejo nadie las tomaría, ni
daría á quien bien quisiese, si no
la hubiese visto cuando se hacía
ó si no fuesse de mano de
boticario de quien estuviese tan
saneado que no se tuviere duda
de su conciencia y virtud.
D. Gaspar.—Harto ha dicho
vuesa merced, señor licenciado,
para que estemos más avisados y
advertidos de lo que los boticarios
pueden hacer; pero no es posible
que todos pequen tan á rienda
suelta.
Lerma.—No digo yo que todos,
porque haría injuria á algunos
buenos que hay entre ellos,
aunque no sean muchos, y los
que son malos es, ó porque son
simples y iñorantes, ó porque son
malos cristianos y tienen poco
temor de Dios, ó porque son
pobres, que la pobreza es
ocasión de grandes males.
Pimentel.—Pues, ¿qué remedio
se podría poner en este
desconcierto que bastase para
estorbar tan gran daño como los
malos boticarios hacen?
Lerma.—El primero ya yo le he
dicho, que no habían de permitir
que ninguno usase el oficio que
no fuese muy docto y muy
experimentado; y lo principal que
ha de tener es ser muy buen
gramático, para entender los
libros de su arte, muy estudioso y
curioso de saber y aprender todos
los primores que hay en ella, y sin
esto, se requiere que hayan
estudiado alguna medicina para
que sepan mejor lo que hacen.
Los boticarios que son buenos
muchas veces aprovechan de
advertir á los médicos en algunos
descuidos y yerros que hacen, y
no holgaría yo poco de que todos
los boticarios con quien tratase
fuesen tan suficientes que
supiesen hacer esto.
D. Gaspar.—¿Pues por qué os
enojasteis de que Dionisio dixo
poco ha que la cura del hígado no
iba por los términos que
convenía?
Lerma.—No me enojé yo porque
me lo dixese, sino porque me lo
dixo en público, y no ha de ser
por vía de reprensión sino de
consejo, y en esto no me negará
él que tengo razón; y, aunque no
lo quisiera decir en su presencia,
sería mal que vuesas mercedes
pensasen que ninguna cosa de
las que he dicho aquí toca en su
honor, porque yo certifico que
ninguna falta tiene para que no
sea uno de los mejores boticarios
que hay en el reino y de quien
más sin sospecha puedan
confiarse los enfermos y los
médicos que los curaren.
Pimentel.—Bien me parece que
después de descalabrado le
untéis la cabeza; yo fiador que, á
lo que creo, no os vais, señor
licenciado, sin respuesta, que no
sin causa os ha escuchado sin
contradeciros en nada. Pero
pasad adelante y decidnos otros
remedios.
Lerma.—No habían de ser los
boticarios pobres, sino que
también les habían de pedir si
tenían patrimonio de donde
ayudarse á sustentar, como
hacen á los clérigos cuando van á
ordenarse; que recia cosa sería
fiarse de un hombre pobre
muchos dineros sin contarlos, y
sin pensar que se aprovecharía
del los en sus necesidades,
podiendo hacerlo, y lo mesmo de
un boticario con pobreza las
medicinas, sin pensar que
procurase remediarla con ellas; y
por esto hay autores que dicen
que en un tiempo se tuvo en
Roma tanta cuenta con este
oficio, que las medicinas estaban
depositadas en ciertas personas
de gran confianza; que llevaban
salario por ello, y que allí iban los
médicos á tomarlas y los
boticarios las gastaban así como
las llevaban, sin que en ello, ni
por iñorancia ni por descuido,
pudiese haber yerro ninguno. El
otro remedio que se podría tener
es en las visitas que les hacen,
para las cuales, habiendo buena
gobernación, había de haber
visitadores generales que no
entendiesen en otra cosa, y éstos
habían de estar proveidos en
cada provincia y pagados del
dinero público, de manera que no
se les siguiese interés particular
ni les cupiese parte de la pena ni
de otra cosa, para que más sin
afición ni pasión pudiesen juzgar,
y que los que no hallasen
suficientes los inhabilitasen y
privasen del oficio sin tener
advertencia á la honra ó bien
particular de uno en perjuicio y
daño de toda la república.
Pimentel.—Bien sería esso, si se
hallasen personas de quien se
pudiese tener tan buena
confianza, y el rey, con otros
cuidados que tiene mayores, no
puede tener tan particular cuenta
con este negocio.
Lerma.—Pues habríala de tener
él ó los que tienen cargo de la
gobernación de sus reinos, como
lo tienen con examinar á uno que
ha de ser escribano real, que
quieren que sepa hacer bien una
escritura en que va la hacienda
de un hombre; y sería más justo
que procurasen de que también
fuesen bien hechas las medicinas
en que va la salud y vida de los
hombres, porque no son pocos
los que mueren por culpa dellos.
Y conforme á este parecer es lo
que dice Jacobo Silvio hablando
desta gente que digo: Dios haga y
provea que la justicia real alguna
vez tenga cuenta con los que
primero usan esta arte que la
hayan entendido, siendo á los
cuerpos de los hombres tan
saludable cuando bien se hace y
tan dañosa cuando iñorantemente
se trata. Y, finalmente, habrían de
tener los boticarios fieles que les
mirasen las medicinas y se las
tasasen en precios convenibles,
averiguando la costa que tienen y
dándoles ganancia con que se
pudiesen sustentar, aunque fuese
más de la que agora llevan, pues
las medicinas serían mejores y de
más valor; porque si las que
agora venden son buenas, yo
digo que las venden muy baratas,
y si son malas, en cualquiera
precio, aunque den dinero por
que las lleven, son tan caras que
ninguna mercaduría hay que tanto
lo sea.
Pimentel.—Pues, decidme,
señor licenciado: ¿de que
aprovecha el visitar las boticas
cuando los regimientos de los
pueblos traen boticarios de fuera
para hacerlo?
Lerma.—Algún fruto hace,
aunque poco, porque si los
médicos se hallan presentes,
como siempre lo están, es para
ayudar á los boticarios, y ellos
que habían de acusar sus defetos
se los encubren, porque son sus
amigos, y cuando les preguntan
alguna cosa que no saben,
responden por ellos, tomándoles
la palabra de la boca, y también
defienden algunas cosas cuesta
arriba, y con otras disimulan todos
ellos; y aun plega Dios que no
haya algunas que ni los unos ni
los otros no las entiendan. Y
sobre esto, no hay botica tan bien
visitada que si veniesse otro día
alguno que entendiese bien el
oficio no hallase cosas nuevas
que reprender y enmendar. Y
cuando ya se viene á dar la
sentencia, nunca faltan amigos y
favores que con buena maña
bastan para procurar con solicitud
que sea muy moderada; y de
ciento que podrían privar, no
hallaréis dos inhabilitados, y ya
que lo sean luego hay mil
remedios para que la sentencia
no se execute y tornen á usar sus
oficios contra justicia y conciencia
suya y de los que se lo permiten y
consienten. Dios ponga remedio
en esto, que harta necesidad hay
de que lo provea de su mano.

Fin de la primera parte del


colloquio de los médicos y
boticarios.
COMIENZA LA
SEGUNDA PARTE
del colloquio, en la cual se trata lo
que toca á los médicos.

INTERLOCUTORES

Los mesmos que en la primera.

Dionisio.—Hasta agora, señor


licenciado, no me ha faltado
atención para oir ni paciencia
para escuchar todo lo que vuesa
merced ha querido decir de los
boticarios, y, verdaderamente, no
sería justo que por hacer buenos
á los que son buenos yo quiero
que también lo sean los malos,
pues en todas las artes y oficios
que se usan en el mundo hay de
los unos y de los otros, y que los
haya en este oficio y arte de
boticario no es maravilla, aunque
yo confieso que tienen toda la
obligación que vuestra merced ha
dicho y que es muy mayor la
culpa que se les puede dar.
Porque va poco en que un platero
yerre una vasija, y un sastre una
ropa, y un pintor una imagen, y va
mucho en que un boticario y un
médico yerren la cura de un
hombre en que le va la salud y la
vida; el uno por falta de las
medicinas y el otro por faltarle la
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.

Let us accompany you on the journey of exploring knowledge and


personal growth!

ebookfinal.com

You might also like