Windows XP Services
Windows Y2K and XP came out with a new configurable area. We'll be dealing with Windows XP services here. You will find these services in your Start, Programs menu named, "Administrative Tools". By Default Administrative Tools is not shown. You will have to enable it by opening Taskbar and Start Menu. Taskbar and Start Menu is accessible on the Classic Start Menu by clicking on Start, Settings, Taskbar and Start Menu. On the XP Start Menu you will have to get into the Control Panel and the Taskbar and Start Menu applet. Put a checkmark beside, "Display Administrative Tools. Click OK and then click on your Start, Programs, Administrative Tools and Services.
In the administrative tools, links will be provided for Services to open.
Or alternatively, Click RUN from the start menu and in textbox, type services.msc and hit return
Note:
Before tweaking your services, you may consider clearing the Event Log to quickly see what, if anything, has resulted in your adjustments. Do this by clicking on Start, Programs, Administrative Tools, Event Viewer. Click on the Action tab and Clear all events.
Another precaution to take is to use a pen and paper to record your changes. Modify a couple at a time and test your system.
I take no responsibilities for anything that may go wrong if you decide to use any of the suggested settings on this page. This page is meant for your information only.
Have fun and may your resources be with you.
Service | Description | Dependencies | Startup Type |
Alerter | Notifies selected users and computers of administrative alerts. If the service is stopped, programs that use administrative alerts will not receive them. If this service is disabled, any services that explicitly depend on it will fail to start. | Workstation | Disabled: Home user Automatic: Networked Computer |
Application Layer Gateway Service | Provides support for 3rd party protocol plug-ins for Internet Connection Sharing and the Internet Connection Firewall. | NULL | Disabled: Not using firewall/ sharing or else Automatic |
Application Management | Provides software installation services such as Assign, Publish, and Remove. | NULL | Manual: All users |
Automatic Updates | Enables the download and installation of critical Windows updates. If the service is disabled, the operating system can be manually updated at the Windows Update web site. | NULL | Disabled Automatic(D) |
Background Intelligent Transfer Service | Uses idle network bandwidth to transfer data. | Remote Procedure Call, Workstation | Disabled: If Automatic Updates is disabled |
Clip Book | Enables ClipBook Viewer to store information and share it with remote computers. If the service is stopped, ClipBook Viewer will not be able to share information with remote computers. If this service is disabled, any services that explicitly depend on it will fail to start. | Network DDE | Disabled Manual If unsure |
COM+ Event System | Supports System Event Notification service (SENS), which provides automatic distribution of events to subscribing Component Object Model (COM) components. If the service is stopped, SENS will close and will not be able to provide logon and logoff notifications. If this service is disabled, any services that explicitly depend on it will fail to start. | Remote Procedure Call (RPC) | Disabled Manual If Unsure |
Computer Browser | Maintains an updated list of computers on the network and supplies this list to computers designated as browsers. If this service is stopped, this list will not be updated or maintained. If this service is disabled, any services that explicitly depend on it will fail to start. | Server Workstation | Disabled |
Cryptographic Services | Provides three management services: Catalogue Database Service, which confirms the signatures of Windows files; Protected Root Service, which adds and removes Trusted Root Certification Authority certificates from this computer; and Key Service, which helps enrol this computer for certificates. If this service is stopped, these management services will not function properly. If this service is disabled, any services that explicitly depend on it will fail to start. | Remote Procedure Call | Automatic Disabled |
DHCP Client | Manages network configuration by registering and updating IP addresses and DNS names. | AFD Networking Support Environment, NETBios Over Tcpip, | Disabled: Static IP Enabled: Dynamic IP |
Distributed Link Tracking Client | Maintains links between NTFS files within a computer or across computers in a network domain. | RPC | Disabled |
Distributed Transaction Coordinator | Coordinates transactions that span multiple resource managers, such as databases, message queues, and file systems. If this service is stopped, these transactions will not occur. If this service is disabled, any services that explicitly depend on it will fail to start. | Remote Procedure Call (RPC) Security Accounts Manager | Disabled |
DNS Client | Resolves and caches Domain Name System (DNS) names for this computer. If this service is stopped, this computer will not be able to resolve DNS names and locate Active Directory domain controllers. If this service is disabled, any services that explicitly depend on it will fail to start. | TCP/IP Protocol Driver | Disabled |
EPSON Printer Status Agent2 | Lets you know when you are running out of ink. | NULL | Disabled |
Error Reporting Service | Allows error reporting for services and applications running in non-standard environments. | NULL | Disabled |
Event Log | Enables event log messages issued by Windows-based programs and components to be viewed in Event Viewer. This service cannot be stopped. | NULL | Disabled |
Fast User Switching Compatibility | Provides management for applications that require assistance in a multiple user environment. | Terminal Services | Automatic |
Fax | Enables you to send and receive faxes, utilizing fax resources available on this computer or on the network. | Plug and Play, | Disabled |
FTP Publishing Service | Used to provide a FTP server on your network. | IIS Admin | Disabled |
Help and Support | Enables Help and Support Center to run on this computer. If this service is stopped, Help and Support Center will be unavailable. If this service is disabled, any services that explicitly depend on it will fail to start. | Remote Procedure Call | Disabled |
IIS Admin | Usually used in conjunction with local web site or FTP servers. | RPC, Security Accounts Manager | Disabled |
IMAPI CD-Burning Service | Manages CD recording using Image Mastering Applications Programming Interface (IMAPI). If this service is stopped, this computer will be unable to record CDs. If this service is disabled, any services that explicitly depend on it will fail to start. | NULL | Disabled |
Indexing Service | Indexes contents and properties of files on local and remote computers; provides rapid access to files through flexible querying language. | RPC | Disabled |
Internet Connection Firewall(ICF)/ Internet Connection Sharing (ICS) | Provides network address translation, addressing, name resolution and/or intrusion prevention services for a home or small office network. | Application Layer Gateway Service, Network Connections,Network Location Awareness (NLA),Remote Access Connection Manager | Disabled |
IPSEC Services | Manages IP security policy and starts the ISAKMP/Oakley (IKE) and the IP security driver. | IPSEC Driver, | Disabled |
Logical Disc Manager | Detects and monitors new hard disk drives and sends disk volume information to Logical Disk Manager Administrative Service for configuration. If this service is stopped, dynamic disk status and configuration information may become out of date. If this service is disabled, any services that explicitly depend on it will fail to start. | Plug and Play, | Manual |
Local Disk Manager Administrative Service | Configures hard disk drives and volumes. The service only runs for configuration processes and then stops. | Logical Disk Manager, Plug and Play, | Manual |
Machine Debugger Manager | Manages local and remote debugging for Visual Studio debuggers. | Remote Procedure Call(RPC) | Disabled |
Messenger | Transmits net send and Alerter service messages between clients and servers. This service is not related to Windows Messenger. If this service is stopped, Alerter messages will not be transmitted. If this service is disabled, any services that explicitly depend on it will fail to start. | NetBIOS Interface, Plug and Play, RPC. ,Workstation | Disabled |
Message Queuing | *May be used on some domains. Not installed by default. Not available on XP Home. | Distributed Transaction Coordinator, Message Queuing Access Control, NT LM Security Support Provider, Reliable Multicast Protocol driver, RPC., Server | Disabled Automatic |
Message Queuing Services | *See link above for information on this service. | Message Queuing | Disabled |
MS Software Shadow Copy Provider | Manages software-based volume shadow copies taken by the Volume Shadow Copy service. If this service is stopped, software-based volume shadow copies cannot be managed. If this service is disabled, any services that explicitly depend on it will fail to start. | Remote Procedure Call(RPC) | Manual |
Net Logon | Supports pass-through authentication of account logon events for computers in a domain. | Workstation | Manual |
Net Meeting Remote desktop sharing | Enables an authorized user to access this computer remotely by using NetMeeting over a corporate intranet. If this service is stopped, remote desktop sharing will be unavailable. If this service is disabled, any services that explicitly depend on it will fail to start. | NULL | Disabled |
Network Connections | Manages objects in the Network and Dial-Up Connections folder, in which you can view both local area network and remote connections. | Remote Procedure Call (RPC) | Automatic |
Network DDE | Provides network transport and security for Dynamic Data Exchange (DDE) for programs running on the same computer or on different computers. If this service is stopped, DDE transport and security will be unavailable. If this service is disabled, any services that explicitly depend on it will fail to start. | Disabled | Disabled |
Network DDE SDM | Manages Dynamic Data Exchange (DDE) network shares. If this service is stopped, DDE network shares will be unavailable. If this service is disabled, any services that explicitly depend on it will fail to start. | NULL | Disabled |
Network Locations Awareness | Collects and stores network configuration and location information, and notifies applications when this information changes. | ADR Network Support Env. TCP/IP Protocol driver | Disabled |
NTLM Security Support | Provides security to remote procedure call (RPC) programs that use transports other than named pipes. | NULL | Disabled |
Performance Logs & Alerts | Collects performance data from local or remote computers based on preconfigured schedule parameters, then writes the data to a log or triggers an alert. If this service is stopped, performance information will not be collected. If this service is disabled, any services that explicitly depend on it will fail to start. | NULL | Disabled |
Plug n Play | Enables a computer to recognize and adapt to hardware changes with little or no user input. Stopping or disabling this service will result in system instability. | NULL | Automatic |
Portable Media Serial Number | Retrieves the serial number of any portable music player connected to your computer. | NULL | Disabled |
Print Spooler | Loads files to memory for later printing. | RPC | Disabled |
Protected Storage | Provides protected storage for sensitive data, such as private keys, to prevent access by unauthorized services, processes, or users. | RPC | Automatic: Saves Password Disabled: Secured |
Qos RSVP | Provides network signaling and local traffic control setup functionality for QoS-aware programs and control applets. | AFD Networking Support Environment,Remote Procedure Call (RPC), TCP/IP Protocol Driver | Disabled |
Remote Access Auto connection Manager | Creates a connection to a remote network whenever a program references a remote DNS or NetBIOS name or address. | Remote Access Conn. manager, Telephony | Based on Internet Connection |
Remote Desktop Help Session Manager | Manages and controls Remote Assistance. If this service is stopped, Remote Assistance will be unavailable. Before stopping this service, see the Dependencies tab of the Properties dialog box. | Remote Procedure Call (RPC) | Disabled |
Remote Procedure Call | Provides the endpoint mapper and other miscellaneous RPC services. | NULL | Automatic |
Remote Procedure Call Locator | Manages the RPC name service database. | Workstation | Disabled |
Remote Registry | Enables remote users to modify registry settings on this computer. If this service is stopped, the registry can be modified only by users on this computer. If this service is disabled, any services that explicitly depend on it will fail to start. | Remote Procedure Call (RPC) | Disabled |
Removable Storage | Used for managing removable media. | RPC | Manual |
Routing and Remote Access | Offers routing services to businesses in local area and wide area network environments. | RPC, NetBIOS Group | Disabled |
Secondary Logon | Enables starting processes under alternate credentials. If this service is stopped, this type of logon access will be unavailable. If this service is disabled, any services that explicitly depend on it will fail to start. | NULL | Disabled |
Security Accounts Manager(SAM) | Stores security information for local user accounts. | RPC | Disabled |
Server | Supports file, print, and named-pipe sharing over the network for this computer. If this service is stopped, these functions will be unavailable. If this service is disabled, any services that explicitly depend on it will fail to start. | NULL | Disabled |
Shell Hardware Detection | *Some actions require a device to be detected in order to produce. Such as playing a music CD. A CD-ROM device has to be found. Sorry for my vagueness on this one. | Remote Procedure Call (RPC) | Manual |
Simple Mail Transfer Protocol | *Supports the use of a local (outbound) email server. | Event Log, IIS Admin | Disabled |
Simple TCP/IP Service | *Supports UNIX Networking services. | AFD Support Network Environment | Disabled |
Smart Card | Manages access to smart cards read by this computer. If this service is stopped, this computer will be unable to read smart cards. If this service is disabled, any services that explicitly depend on it will fail to start. | Plug n Play | Disabled |
Smart Card Helper | Enables support for legacy non-plug and play smart-card readers used by this computer. If this service is stopped, this computer will not support legacy reader. If this service is disabled, any services that explicitly depend on it will fail to start. | NULL | Disabled |
SNMP Service | Supports the use of networking equipment that use SNMP as a mode of management. | NULL | Disabled |
SNMP Trap Service | Supports the use of networking equipment that use SNMP as a mode of management. | Event log | Disabled |
SSDP Discovery Service | Enables discovery of UPnP devices on your home network. | NULL | Disabled |
System Event Notification | Tracks system events such as Windows logon, network, and power events. Notifies COM+ Event System subscribers of these events. | COM+ Event System | Disabled |
System Restore Service | Performs system restore functions. To stop service, turn off System Restore from the System Restore tab in My Computer, Properties, System Restore tab. | Remote Procedure Call (RPC) | Automatic Disabled If you like to do fresh install if problem occurs. |
Task Scheduler | Enables a user to configure and schedule automated tasks on this computer. If this service is stopped, these tasks will not be run at their scheduled times. If this service is disabled, any services that explicitly depend on it will fail to start. | Remote Procedure Call (RPC) | Disabled If you can care updates or else keep Automatic |
TCP/IP NetBIOS Helper | Enables support for NetBIOS over TCP/IP (NetBT) service and NetBIOS name resolution. | AFD Network support Environment, NetBios Over TCP/IP | Disabled |
Telephony | Provides Telephony API (TAPI) support for programs that control telephony devices and IP based voice connections on the local computer and, through the LAN, on servers that are also running the service. | Plug n Play, Remote Procedure Call (RPC) | Automatic |
Telnet | Enables a remote user to log on to this computer and run programs, and supports various TCP/IP Telnet clients, including UNIX-based and Windows-based computers. If this service is stopped, remote user access to programs might be unavailable. If this service is disabled, any services that explicitly depend on it will fail to start. | NTLM Security Support Provider, RPC, TCP/IP Protocol Driver | Disabled |
Terminal Services | Allows multiple users to be connected interactively to a machine as well as the display of desktops and applications to remote computers. The underpinning of Remote Desktop (including RD for Administrators), Fast User Switching, Remote Assistance, and Terminal Server. | Remote Procedure Call (RPC) | Disabled |
Themes | Provides user experience theme management. | NULL | Automatic/ Disabled based on themes |
True Vector Internet Monitor | Monitors internet traffic and generates alerts for disallowed access. | AFD Networking Support Environment, RPC,vsdatant | Automatic |
Uninterruptable Power Supply | Manages an uninterruptible power supply (UPS) connected to the computer. | NULL | Disabled |
Universal Plug n Play Device Host | Provides support to host Universal Plug and Play devices. | SSDP Discovery Service | Disabled |
Upload Manager | Manages synchronous and asynchronous file transfers between clients and servers on the network. If this service is stopped, synchronous and asynchronous file transfers between clients and servers on the network will not occur. If this service is disabled, any services that explicitly depend on it will fail to start. | Remote Procedure Call (RPC) | Disabled |
Volume Shadow Copy | Manages and implements Volume Shadow Copies used for backup and other purposes. If this service is stopped, shadow copies will be unavailable for backup and the backup may fail. If this service is disabled, any services that explicitly depend on it will fail to start. | Remote Procedure Call (RPC) | Disabled Manual If unsure |
Web Client | Enables Windows-based programs to create, access, and modify Internet-based files. If this service is stopped, these functions will not be available. If this service is disabled, any services that explicitly depend on it will fail to start. | Webdav Client Redirector | Disabled |
Windows Audio | Manages audio devices for Windows-based programs. If this service is stopped, audio devices and effects will not function properly. If this service is disabled, any services that explicitly depend on it will fail to start. | Plug n Play, RPC | Automatic |
Windows Image Acquisition(WIA) | Provides image acquisition services for scanners and cameras. | Remote Procedure Call (RPC) | Disabled Automatic if problem occurs |
Windows Installer | Installs, repairs and removes software according to instructions contained in .MSI files. | Remote Procedure Call | Manual |
Windows Management Instrumentation | Provides a common interface and object model to access management information about operating system, devices, applications and services. If this service is stopped, most Windows-based software will not function properly. If this service is disabled, any services that explicitly depend on it will fail to start. | Event Log, Remote Procedure Call (RPC) | Automatic |
Windows Management Instrument Driver Extensions | Provides systems management information to and from drivers. | NULL | Manual |
Windows Time | Maintains date and time synchronization on all clients and servers in the network. If this service is stopped, date and time synchronization will be unavailable. If this service is disabled, any services that explicitly depend on it will fail to start. | NULL | Disabled |
Wireless Zero Configuration | Provides automatic configuration for the 802.11 adapters. | NDIS Usermode I/O Protocol, RPC | Disabled |
WMI Performance Adapter | Provides performance library information from WMI HiPerf providers. | Remote Procedure Call (RPC) | Disabled |
Workstation | Creates and maintains client network connections to remote servers. If this service is stopped, these connections will be unavailable. If this service is disabled, any services that explicitly depend on it will fail to start. | NULL | Automatic |
Windows Startup Programs
What are they?
After the booting process of computer is done, few programs also start after the operating system(Windows)is loaded. Thus ensuring the speedy opening of that application each time the application is accesses
So What is the Problem for a system
Virtually all applications you install using the default installation these days decide that they should start-up when Windows starts. If you allow these to take control, you can end up with a situation where (unless you have sufficient memory installed) every other program slows down to be unusable.
The reason for this is that all of these programs use a portion of the system memory and resources which leaves a smaller percentage for other programs once they're opened. On an older system, for example, prior to tweaking I had 33 programs running at start-up with the system resources at 59% and Windows took an age before it was ready for use. Post tweaking I had a mere 10, with system resources back to 92% and Windows was up and running within a minute.
For example, if you regularly take part in online gaming or do a lot of graphics or video editing then resources and memory are normally at a premium. Examples of programs that use up part of system memory and aren't really required (for most users) are:
- Updaters for products such as Sun's Java package (SunJavaUpdateSched) and Adobe software (AdobeUpdater or AdobeUpdateManager) which aren't changed that often and can be run manually.
- Mobile phone management/synchronization utilities - only required if you plug in your phone most days but they're normally available via the Start menu. And it is not must to have start up for these mobile management/ synchronization applications.
- Photo management "media watchers" - these wait in the background for you to insert a memory stick (or camera) with images on and then offer to add them to your album software (such as Adobe Photo Downloader)
- Ink level (or similar) monitors for printers - you can normally tell if the ink level is low and it doesn't run out often.
How to Identify these programs
MSConfig - Windows 9x/Me/2K/XP/Vista
You can also use the "System Configuration Utility" (referred to as MSConfig from now on) to identify startup programs. MSConfig is available for all Win9x/Me/2K/XP/Vista users (Win95/2K user can use the respective versions from here).
To use it to identify start-up programs do the following:
- Click Start → Run
- In the Open box type msconfig and then click on OK or press Enter
- Select the Startup tab and a window will be shown similar to one of those below (click on the thumbnail and it will open full-size in another window)
Few columns are available. Note that with all of these you can expand the width of each column by holding down the left mouse button with the cursor on the vertical line between the column headings (where applicable) and then dragging the mouse either left or right before releasing. With the XP & Vista versions (for which the window cannot be re-sized) you can also double-click on the vertical line between two column headings to maximize the column width.
Windows Defender - Windows XP/Vista
Microsoft currently recommend using Windows Defender (or the registry) on systems running XP or Vista for controlling which programs run when your computer starts - see here. This utility can be downloaded for XP from here and is included by default with Vista.
To use it to identify start-up programs do the following:
- Click Start → All Programs → Windows Defender
- Click Tools → Software Explorer
- Select Startup Programs under Category and a window will be shown similar to one of those below (click on the thumbnail and it will open full-size in another window)
- Click on each entry under the Name column to reveal the details for that entry
Several columns are available, according to interest, one can change the view.
Other tools
Several 3rd party tools are available and few Free wares are also available
Generally I trust free software downloads from cnet. From past 3 years I’ve been downloading and not even once my system is troubled. I found these useful utilities
Remove Startup Programs Buddy 2.2
Remove Startup Programs Buddy is a utility to remove malicious programs from Windows start-up. Remove Startup Programs Buddy inspects Windows start-up places and lists start-up programs so you could delete abusive items. Remove Startup Programs Buddy backs up configuration data so you can roll back all changes at any time. Version 2.2 may include unspecified updates, enhancements, or bug fixes.
Company: Scorpio Software
Size: 920.75K
Startup Optimizer 1.6
Although this start-up monitor effectively replaces MSCONFIG for day-to-day use, it occassionally incorrectly judges the harm factor of start-up items.
Startup optimizer’s free and checkbox interface is clean and well designed. The program loads all startup items and color codes them by harm factor: Required, Not Required, User’s Choice, Unknown and harmful. Each of these items include info needed to judged its worth. Program name, location, command path, rating, size columns can be quickly sorted and sized for readability. Single click on an item displays info in a larger box and adds a comment concerning the item. Most Comments include a link for more info about item.
We found the harm factor ratings tended to produce error on the side of cautiousness, with a safe product labelled as harmful on some of our test machines.Users can easily backup start-up list prior to making changes. However, while any level of level user would find Startup Optimizer easy to use, care must be taken before disabling or deleting any start-up items.
Company: Cyberlion Solutions
Size: 1.09MB
CNET Download
Note: Its sure that removing start-up programs will help to gain performance. But at the same, If any important start-up items are disabled, it may cause the system unable to boot normally.
Ajax Tutorial 6
I don't really enjoy writing articles that are primarily about something that you shouldn't do. Most of the time, it's a pretty silly type of thing to write. I spend half an article explaining something, just so I can spend the rest of the article explaining what a bad idea it is to use the techniques you've just learned about. Such was the case, to a large degree, with previous article, which taught you how to use XML as the data format for your Ajax apps' requests.
Hopefully, this article will redeem the time you spent learning about XML requests. In Ajax apps, while there are very few reasons to use XML as the sending data format, there are a lot of reasons why we may want a server to send XML back from a server, to a client. So everything we see about XML in the last article will definitely start to have some value in this article.
Servers can't say much (sometimes)
Before we go deeper into the technical details of getting an XML response from a server, we need to understand why it's such a good idea for a server to send XML in response to a request (and how that's different from a client sending that request in XML).
Clients speak in name/value pairs
As we recall from the last article, clients don't need to use XML in most cases because they can send requests using name/value pairs. So we might send a name like this: name=haki . We can stack those up by simply adding an ampersand ( & ) between successive name/value pairs, like this: name=haki&job=programmer . Using simple text and these name/value pairs; clients can send requests with multiple values to a server easily. There's rarely a need for the additional structure (and overhead) that XML provides.
In fact, almost all the reasons we'd need to send XML to a server can be grouped into two basic categories:
- The server only accepts XML requests. In these cases, we don't have a choice. The basics in last month's article should give us all the tools you need to send these sorts of requests.
- We're calling a remote API that only accepts XML or SOAP requests. This is really just a specialized case of the previous point, but it's worth mentioning on its own. If we want to use the APIs from Google or Amazon in an asynchronous request, there are some particular considerations. We'll look at those, and a few examples of making requests to APIs like this, in next month's article.
Servers can't send name/value pairs (in a standard way)
When we send name/value pairs, the Web browser sending the requests and the platform responding to that request and hosting a server program cooperate to turn those name/value pairs into data that a server program can work with easily. Practically every server-side technology -- from servlets to PHP to Perl to Ruby on Rails -- allows you to call a variety of methods to get at values based on a name. So getting the name attribute is trivial.
This isn't the case going in the other direction. If a server replied to an app with the string name=haki&job=programmer , the client has no standardized, easy way to break up the two name/value pairs, and then break each pair into a name and value. You'll have to parse the returned data manually. If a server returns a response made up of name/value pairs, that response is no easier (or harder) to interpret than a response with elements separated by semicolons, or pipe symbols, or any other nonstandard formatting character.
What that leaves us with, then, is no easy way to use plain text in our responses and have the client get that response and interpret it in a standard way, at least when the response contains multiple values. If our server simply sent back the number 42, say, plain text would be great. But what about if it's sending back the latest ratings for Movies Aundathi, Neninthe, and king, all at once? While we can chose many ways to send this response using plain text (see listing below for few examples), none are particularly easy to interpret without some work by the client, and none are standardized at all.
Listing.. Server response for movie ratings (various types)
movie=arundathi&ratings=14.2|movie=Neninthe&ratings=6.5|movie=King&rating=9.1
arundathi =14.2| Neninthe =6.5|King =9.1
arundathi|14.2|Neninthe|6.5|King|9.1
Even though it's not too hard to figure out how to break up these response strings, a client will have to parse and split the string up based on the semicolons, equal signs, pipes, and ampersands. This is hardly the way to write robust code that other developers can easily understand and maintain.
Enter XML
When we realize that there's no standard way for a server to respond to clients with name/value pairs, the reason behind using XML becomes pretty clear. When sending data to the server, name/value pairs are a great choice because servers and server-side languages can easily interpret the pairs; the same is true for using XML when returning data to a client. We saw the use of the DOM to parse XML in several earlier articles, and will see how JSON provides yet another option to parse XML in a future article. And on top of all that, we can treat XML as plain text, and get values out of it that way. So there are several ways to take an XML response from a server, and, with fairly standard code, pull the data out and use it in a client.
As an added bonus, XML is generally pretty easy to understand. Most people who program can make sense of the data in listing below, for example.
<ratings>
<movie>
<title>Arundathi</title><rating>14.2</rating>
</movie>
<movie>
<title>Neninthe</title><rating>6.5</rating>
</movie>
<movie>
<title>King</title><rating>9.1</rating>
</movie>
</ratings>
The code in above has no consideration about what a particular semicolon or apostrophe means.
Receiving XML from a server
Because the focus of this series is on the client side of the Ajax equation, we won't bother into much detail about how a server-side program can generate a response in XML. However, we need to know about some special considerations when your client receives XML.
First, you can treat an XML response from a server in two basic ways:
- As plain text that just happens to be formatted as XML
- As an XML document, represented by a DOM Document object.
Second, presume a simple response XML from a server for example's sake. Listing below shows the same TV listings as detailed above (this is, in fact, the same XML as in listing above reprinted for your convenience). I'll use this sample XML in the discussions in this section.
Listing.. XML-formatted movie for examples
Dealing with XML as plain text
The easiest option to handle XML, at least in terms of learning new programming techniques, is to treat it like any other piece of text returned from a server. In other words, we basically ignore the data format, and just grab the response from the server.
In this situation, we use the responseText property of your request object, just as you would when the server sends you a non-XML response (see Listing below).
Listing.. Treating XML as a normal server response
function updatePage()
{
if (request.readyState == 4)
{
if (request.status == 200)
{
var response = request.responseText;
// response has the XML response from the server
alert(response);
}
}
}
In this code fragment, updatePage() is the callback, and request is the XMLHttpRequest object. You end up with the XML response, all strung together, in the response variable. If you printed out that variable, we'd have something like Listing below. (Note that the code in listing below normally is one, continuous line. Here, it is shown on multiple lines for display purposes.)
Listing.. Value of response variable
<ratings><movie><title>Arundathi</title><rating>14.2</rating></movie> <movie><title>Neninthe</title><rating>6.5</rating></movie> <movie><title>King</title><rating>9.1</rating></movie></ratings>
The most important thing to note here is that the XML is all run together. In most cases, servers will not format XML with spaces and carriage returns; they'll just string it all together, like you see in Listing above. Of course, our apps don't care much about spacing, so this is no problem; it does make it a bit harder to read, though.
At this point, we can use the JavaScript split function to break up this data, and basic string manipulation to get at the element names and their values. Of course, that's a pretty big pain, and it ignores the handy fact that you spent a lot of time looking at the DOM, the Document Object Model, earlier in this series. So I'll urge you to keep in mind that you can use and output a server's XML response easily using responseText , but I won’t show you much more code; we shouldn't use this approach to get at the XML data when you can use the DOM, as you'll see next.
Treating XML as XML
While we can treat a server's XML-formatted response like any other textual response, there's no good reason to do so. First, if you've read this series faithfully, you know how to use the DOM, a JavaScript-friendly API with which we can manipulate XML. Better yet, JavaScript and the XMLHttpRequest object provide a property that is perfect for getting the server's XML response, and getting it in the form of a DOM Document object.
To see this in action, check out listing below. This code is similar to listing above, but rather than use the responseText property, the callback uses the responseXML property instead. This property, available on XMLHttpRequest , returns the server's response in the form of a DOM document.
Listing.. Treating XML as XML
function updatePage()
{
if (request.readyState == 4)
{
if (request.status == 200)
{
var xmlDoc = request.responseXML;
// work with xmlDoc using the DOM
}
}
}
Now we have a DOM Document , and we can work with it just like any other XML. For example, we might then grab all the show elements, as in listing below
Listing.. Grabbing all the show elements
{
if (request.readyState == 4)
{
if (request.status == 200)
{
var xmlDoc = request.responseXML;
var movieElements = xmlDoc.getElementsByTagName("movie");
}
}
}
If one are familiar with DOM, they should start to feel familiar. Here, we can use all the DOM methods that are already learned, and easily manipulate the XML you received from the server.
We can also, of course, mix in normal JavaScript code. For instance,we might iterate through all the show elements, as in listing below.
Listing.. Iterating through all the show elements
{
if (request.readyState == 4)
{
if (request.status == 200)
{
var xmlDoc = request.responseXML;
var showElements = xmlDoc.getElementsByTagName("movie");
for (var x=0; x<showElements.length; x++)
{ // We know that the first child of show is title, and the second is rating
var title = showElements[x].childNodes[0].value;
var rating = showElements[x].childNodes[1].value;
// Here every thing can be done to title and ratings to display…
}
}
}
}
With this relatively simple code, we treated an XML response like its XML, not just plain unformatted text, and used a little DOM and some simple JavaScript to deal with a server's response. Even more importantly, we worked with a standardized format XML, instead of comma-separated values or pipe-delimited name/value pairs. In other words, we’ve used XML where it made sense, and avoided it when it didn't, like in sending requests to the server.
XML on the server: A brief example
Although I haven't talked much about how to generate XML on the server, it's worth seeing a brief example, without much commentary, just so one can come up with their own ideas on how to deal with such a situation. Listing below shows a simple PHP script that outputs XML in response to a request, presumably from an asynchronous client.
This is the raw approach, where the PHP script is really just pounding out the XML output manually. We can find a variety of toolkits and APIs for PHP and most other server-side languages that also allow you to generate XML responses. In any case, this at least gives us an idea of what server-side scripts that generate and reply to requests with XML look like.
Listing.. PHP script that returns XML
<?php
// Connect to a MySQL database
$conn = @mysql_connect("localhost", "username", "secret-password");
if (!conn) die("Error connecting to database: " . mysql_error());
if (!mysql_select_db("movie", $conn)) die("Error selecting movie database: " . mysql_error());
// Get ratings for all TV shows in database
$query = 'SELECT title, rating from ratings';
$queryResult = mysql_query($query);
if (!$queryResult) die("Error retrieving ratings for movies.');
// Let the client know we're sending back XML
header("Content-Type: text/xml");
echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>";
echo "<ratings>";
while ($row = mysql_fetch_array($queryResult))
{
$title = $row['title'];
$rating = $row['rating'];
echo "<movie> echo "<title>" . $title . "</title>"; echo "<rating>" . $rating . "</rating>"; echo "</movie>";
}
echo "</ratings>";
mysql_close($conn);
?>
You can be able to output XML in a similar way using your own favorite server-side language.
Other options for interpreting XML
One very popular options for dealing with XML, beyond treating it as unformatted text or using the DOM, is important and worth mentioning. That's JSON, short for JavaScript Object Notation, and it's a free text format that is bundled into JavaScript. I don't have space to cover JSON in this article. You'll probably hear about it as soon as you mention XML and Ajax apps, however, so now you'll know what your co-workers are talking about.
In general, everything that you can do with JSON, you can do with the DOM, or vice versa; it's mostly about preference, and choosing the right approach for a specific application. For now, stick with the DOM, and get familiar with it in the context of receiving a server's response. In next articles, we'll have a good amount of time on JSON, and then you'll be ready to choose between the two on your next app. Lots of more XML could be in next articles.
In conclusion
I've talked about XML nearly non-stop since the last article in this series began, but have still really only scratched the surface of XML's contribution to the Ajax equation.
Your biggest task in the short term, though, is to really think about when XML makes sense for your own applications. In many cases, if your app is working well, then XML is nothing more than a technology buzzword that can cause you headaches, and you should resist the temptation to use it just so you can say you have XML in your application.
If you've a situation where the data the server sends you is limited, though, or in a strange comma- or pipe-delimited format, then XML might offer you real advantages. Consider working with or changing your server-side components so that they return responses in a more standard way, using XML, rather than a proprietary format that almost certainly isn't as robust as XML.
Most of all, realize that the more you learn about the technologies around Ajax, the more careful you have to be about your decisions. It's fun to write these Web 2.0 apps (and in coming articles, you'll return to the user interface and see some of the cool things that you can do), but it also takes some caution to make sure you don't throw technologies at a working Web page just to impress your friends. I know you can write a good app, so go out and do just that. When you're finished, come back here for article, and even more XML.
Ajax Tutorial 5
Using XML format for request
Even casual Ajax developers will notice the x in Ajax, and realize that it stands for XML. XML is one of the most popular data formats in any programming medium, and offers real advantages for server responses in asynchronous applications. In this article, we'll see how servers can send XML in response to a request.We really can't do any significant programming today without running across XML. Whether you're a Web page designer considering the move to XHTML, a Web programmer working with JavaScript, a server-side programmer using deployment descriptors and data binding, or a back-end developer investigating XML-based databases, the eXtensible Markup Language (XML) is everywhere. Then it is no surprise that, XML is considered one of the core technologies that lie under Ajax.
However, this opinion reflects the poor choice of names for the core object used in Ajax applications, XMLHttpRequest more than it does technical reality. In other words, most people think XML is a core part of Ajax because they assume that the XMLHttpRequest object actually always uses XML. But that's not the case, and the reasons why are the subject of the first part of this article. We can see that in most Ajax applications, XML rarely makes an appearance at all.
XML does have real uses in Ajax, and XMLHttpRequest allows for these as well. There's certainly nothing keeping us from sending XML to a server. Apart from normal data, XML is also a usable format. In this article; we'll look at how to do that. More importantly, though, we'll talk about why we might use XML for our request format, and where, it shouldn’t be used.
XML: Is it really there at all?
It's easy to make assumptions about Ajax applications and their usage of XML; both the technology name (Ajax) and the core object it uses (XMLHttpRequest) imply the use of XML, and we'll hear XML linked with Ajax applications all the time. However, this perception is simply wrong, and if we want to really know the stuff when it comes to writing asynchronous applications, we need to know that the perception is wrong -- and, better yet, know why it's wrong.XMLHttpRequest: Poor names and HTTP
One of the worst things that can happen to a technology is for it becomes so hot that changing core pieces of it becomes impossible. That's exactly what's happened with XMLHttpRequest, the basic object used in Ajax apps. It sounds like it's designed to either send XML over HTTP requests, or perhaps make HTTP requests in some sort of XML format. Whatever the object's name sounds like, though, what it actually does is simply provide a way for your client code (usually JavaScript in your Web page) to send an HTTP request. More than that, nothing is there.Thus, it would be nice to simply change XMLHttpRequest's name to something more accurate, like HttpRequest, or perhaps simply Request. However, millions of developers are now throwing Ajax into their applications, and because we all know that it takes years, if not decades -- for the majority of users to move to new browser versions like Internet Explorer 7.0 or Firefox 1.5, such a move is simply not feasible. The end result is that will be sucked up with XMLHttpRequest, and it's up to developers to realize that the thing is just poorly named.
It's somewhat telling that one of the best known fallback methods for dealing with a browser (especially on Windows) that doesn't support XMLHttpRequest is to use the Microsoft IFRAME object. Hardly sounds like XML, HTTP, or even a request, does it? Obviously, all those things might be involved, but this should simply make clear the fact that the XMLHttpRequest object is a lot more about making requests without requiring a page reload than it is about XML, or even HTTP.
The requests are HTTP, not XML
When we write code in a Web page to communicate with a server, whether it's using Ajax or a normal form POST or even a hyperlink, we're just talking HTTP.Given that pretty much all Web communication between browsers and servers takes place through HTTP, the idea that XML is somehow the transport or technology used by XMLHttpRequest under the covers just doesn't make any sense. It's certainly possible for XML to be sent in the HTTP request, but HTTP is a very precisely defined standard that isn't going away any time soon. Unless you're specifically using XML in your request, or the server is sending you a response in XML, there's nothing but plain old HTTP used in the XMLHttpRequest object. So the next time someone tells you, "Yeah, it's called XMLHttpRequest because it uses XML behind the scenes," just smile and patiently explain to them what HTTP is, and let them know that while XML can be sent over HTTP, XML is a data format, not a transfer protocol.
Using XML (for real)
So far, I've told you about all the places where XML isn't used in Ajax. But the x in Ajax and the XML in XMLHttpRequest are still very real, and you may have several options for using XML in Web applications. we'll look at the basic options first, and then really go in to detail in the rest of this article.Options for XML
In our asynchronous apps, we'll find two basic applications of XML:- To send a request from a Web page to a server in XML format
- To receive a request from a server in your Web page in XML format
The second of these options, to receive a request in XML; requires you to take a response from a server, and extract the data from XML (again, using either an API or more of a raw coding approach). In this case, focus is on the data from the server, and it just so happens that we've got to pull that data out of XML to use it in any constructive way. This is the subject of the next article in this series, and we'll go deeper then.
An introductory warning
Before we go to the details of using XML, a short cautionary word is in order: XML is not a small, fast, space-saving format. As we'll see in the next several sections and in the next article in this series, there are some great reasons to use XML in this context, and some advantages that XML has over plain text requests and responses (especially for responses). However, XML is almost always going to take up more space and be slower than plain text, because several tags and semantics required for XML in messages.If we want to write a tremendous fast application that feels like a desktop app, XML might not be the best place to start. If we begin with plain text, and find a specific need for XML, then that's great; however, if we use XML from the beginning, we are certainly slowing down application's responsiveness. In most cases, it's faster to send plain text, using name/value pairs like name=haki -- than to turn the text into XML like this:
XML from the client to the server
Let's look at using XML as the format to send data from a client to a server. First, we'll see how to do this technically, and then spend some time examining when this is a good idea, and when it's not.Sending name/value pairs
In about 90 percent of the Web apps we write, we'll end up with name/value pairs to send to a server. For example, if a user types their name and address into a form on your Web page, you might have data like this from the form:firstName=HakiIf you were just using plain text to send this data to a server, you might use code that looks something like listing below. (This is similar to an example used in the first article in this series.)
lastName=P
street= Rajendra Dall Mill Road
city= Vijayawada
state=Andhra Pradesh
zipCode=520012
Listing.. Sending name/value pairs in plain text
function callServer()
{
// Get the city and state from the Web form
var firstName = document.getElementById("firstName").value;
var lastName = document.getElementById("lastName").value;
var street = document.getElementById("street").value;
var city = document.getElementById("city").value;
var state = document.getElementById("state").value;
var zipCode = document.getElementById("zipCode").value;
// Build the URL to connect
var url = "noteUser.php?firstName=" + escape(firstName) +
"&lastName=" + escape(lastName) +
"&street=" + escape(street) + "&city=" + escape(city)
+ "&state=" + escape(state) + "&zipCode=" + escape(zipCode);
// Open a connection to the server
xmlHttp.open("GET", url, true);
// Set up a function for the server to run when it's done
xmlHttp.onreadystatechange = confirmUpdate;
// Send the request
xmlHttp.send(null); }
Converting name/value pairs to XML
The first thing we need to do if we need to use XML as a format for data like this is to come up with some basic XML format in which to store the data. Obviously, your name/value pairs can all turn into XML elements, where the element name is the name of the pair, and the content of the element is the value:<firstName>Haki</firstName>Of course, XML requires that we have a root element, or, if we're just working with a document fragment (a portion of an XML document), an enclosing element. So you might convert the XML above to something like this:
<lastName>P</lastName>
<street>Rajendra Dall Mill Road</street>
<city>Vijayawada</city>
<state>Andhra Pradesh</state>
<zipCode>520012</zipCode>
<address>Now we're almost ready to create this structure in your Web client, and send it to the server
<firstName>Haki</firstName>
<lastName>P</lastName>
<street>Rajendra Dall Mill Road</street>
<city>Vijayawada</city>
<state>Andhra Pradesh</state>
<zipCode>520012</zipCode>
</address>
Communication, of the verbal kind
Before we’re ready to start tossing XML over the network, we need to make sure that the server and script -- to which you send data actually accepts XML. For many of us it may not seem as a point to be noted, but for beginners, I thought it would be better to mention here only.In fact, we need to take two steps to ensure that the data sent in XML will be received correctly:
- Ensure that the script to which XML is sent, accepts XML as a data format.
- Ensure the script will accept the particular XML format and structure in which data is sent.
<profile>
<firstName>Haki</firstName>
<lastName>P</lastName>
<street Rajendra Dall Mill Road</street>
<city>Vijayawada</city>
<state>Andhra Pradesh</state>
<zip-Code>520012</zip-Code>
</profile>
This looks similar to the XML above, except for two things:
- The XML from the client is wrapped within an address element, but the server expects the data to be wrapped within a profile element.
- The XML from the client uses a zipCode element, while the server expects the zip code to be in a zip-code element.
Sending XML to the server
When it comes to sending XML to the server, we'll spend more of your code taking your data and wrapping it XML than you will actually transmitting the data. In fact, once you have the XML string ready to send to the server, you send it exactly as you would send any other plain text; check out listing below to see this in action.Listing.. Sending name/value pairs in XML
function callServer()Much of this is self-explanatory with just a few points worth noting. First, the data in your request must be manually formatted as XML. That's a bit of a letdown after three articles on using the Document Object Model, isn't it? And while nothing forbids you from using the DOM to create an XML document using JavaScript, we'd then have to convert that DOM object to text before sending it over the network with a GET or POST request. So it turns out to be easier to simply format the data using normal string manipulation. Of course, this introduces room for error and typographical mistakes, so one need to be extra careful when you write code that deals with XML.
{
// Get the city and state from the Web form
var firstName = document.getElementById("firstName").value;
var lastName = document.getElementById("lastName").value;
var street = document.getElementById("street").value;
var city = document.getElementById("city").value;
var state = document.getElementById("state").value;
var zipCode = document.getElementById("zipCode").value;
var xmlString = "<profile>" + " <firstName>" + escape(firstName) + "</firstName>" + " <lastName>" + escape(lastName) + "</lastName>" + " <street>" + escape(street) + "</street>" + " <city>" + escape(city) + "</city>" + " <state>" + escape(state) + "</state>" + " <zip-code>" + escape(zipCode) + "</zip-code>" + "</profile>";
// Build the URL to connect to
var url = "noteUser.php";
// Open a connection to the server
xmlHttp.open( "POST", url, true);
// Tell the server you're sending it XML
xmlHttp.setRequestHeader("Content-Type", "text/xml");
// Set up a function for the server to run when it's done
xmlHttp.onreadystatechange = confirmUpdate;
// Send the request
xmlHttp.send(xmlString);
//Generally for text, This would be null or blank.
}
Once XML is constructed, open a connection in largely the same way as it would be when sending text. I tend to prefer using POST requests for XML, since few browsers places a length limitation on GET query strings, and XML can get pretty long; we'll see that Listing above switches from GET to POST accordingly. Additionally, the XML is sent through the send() method, rather than as a parameter tacked on to the end of the URL you're requesting. These are all fairly trivial differences, easy for adjusting.
We need to write one entirely new line of code:
xmlHttp.setRequestHeader("Content-Type", "text/xml");This isn't hard to understand: it just tells the server that we're sending it XML, rather than plain old name/value pairs. In either case, we send data as text, but use text/xml here, or XML sent as plain text. If you just used name/value pairs, this line would read:
xmlHttp.setRequestHeader("Content-Type", "text/plain");If we forget mentioning Request type, server code will not work properly.
Once we get all this put together, all you need to do is call send() and pass in the XML string. The server will get our XML request, and (assuming we've done your pre-work) accept the XML, parse it, and send you back a response. That's really all there is to it -- XML requests with just a few changes of code.
Sending XML: Good or bad?
Before leaving XML requests (and this article) for XML responses, let's spend some real time thinking about the sensibility of using XML in your requests. I've already mentioned that XML is by no means the fastest data format in terms of transfer, but there's a lot more to think about.XML is not simple to construct
The first thing we need to realize is that XML is just not that easy to construct for use in requests. As we observed in listing above, our data quickly becomes pretty convoluted with the semantics of XML:var xmlString = "<profile>" +This might not seem so bad, but it's also an XML fragment that has only six fields. Most of the Web forms developed will have ten to fifteen; although we won't use Ajax for all of your requests, it is a consideration. we're spending at least as much time dealing with angle brackets and tag names as you are with actual data, and the potential to make little typing is tremendous.
" <firstName>" + escape(firstName) + "</firstName>" +
" <lastName>" + escape(lastName) + "</lastName>" +
" <street>" + escape(street) + "</street>"
+ " <city>" + escape(city) + "</city>"
+ " <state>" + escape(state) + "</state>"
+ " <zip-code>" + escape(zipCode) + "</zip-code>" +
"</profile>";
Another problem here is that, as already mentioned; we will have to construct this XML by hand. Using the DOM isn't a good option, as there aren't good, simple ways to turn a DOM object into a string that you request can be sent. So working with strings like this is really the best option; but it's also the option that's hardest to maintain, and hardest to understand for new developers. In this case, we constructed all the XML in one line; things only get more confusing when this is done in several steps.
For Requests, Nothing is added by XML
Beyond the issue of complexity, using XML for our requests really doesn't offer us much of an advantage, if any over plain text and name/value pairs. Consider that everything in this article has been focused on taking the same data we could already send using name/value pairs refer first listing in article and sending it using XML. At no point was anything said about data that you can send with XML that we could not send using plain text; that's because there almost never is anything that we can send using XML that you can't send using plain text.And that's really the bottom line with XML and requests: there's just rarely a compelling reason to do it. We'll see in the next article in this series that a server can use XML for some things that are much harder to do when using plain text; but it's just not the case with requests. So unless you're talking to a script that only accepts XML (and there are some out there), we're better off using plain text in almost every request situation.
In conclusion
We should definitely feel like we're starting to get the XML in Ajax figured out. We know that Ajax apps don't have to use XML, and that XML isn't some sort of magic bullet for data transfer. We should also feel pretty comfortable in sending XML from a Web page to a server. Even more importantly, we know what's involved in making sure that a server will actually handle and respond to your requests: we've got to ensure that the server script accepts XML, and that it accepts it in the format that we're using to send the data over.We also should have a good idea now of why XML isn't always that great a choice for a data format for requests. In future articles, you'll see some cases where it helps, but in most requests, it simply slows things down and adds complexity. So while I'd normally suggest that you immediately start using the things you learned in an article, I'll instead suggest that you be very careful about using what you've learned here. XML requests have their place in Ajax apps, but that place isn't as vastly as its thought of.
In the next article in this series, you'll look at how servers can respond using XML, and how your Web applications can handle those responses. Happily, there are a much larger number of reasons for a server to send XML back to a Web app than the other way around, so you'll get even more use out of that article's technical detail; for now, be sure you understand why XML isn't always a great idea -- at least for sending requests. We might even want to try and implement some Web apps using XML as the data format for requests, and then convert back to plain text, and see which seems both faster and easier to us.
Blog Archive
-
►
2013
(1)
- ► September 2013 (1)
-
►
2011
(7)
- ► April 2011 (7)
-
►
2010
(1)
- ► April 2010 (1)
-
▼
2009
(11)
- ► January 2009 (6)
-
►
2007
(3)
- ► October 2007 (3)
Categories
- Ajax (6)
- Buddha (2)
- Buddhism (2)
- Favorite Movie (1)
- First (1)
- Four Noble Truths (1)
- Ganesha (1)
- Hindu Deities (2)
- Hinduism (3)
- Krishna (1)
- Meditation (1)
- Namasthe (1)
- PHP Basics (3)
- power ful (1)
- respecting others (1)
- salutation (1)
- siva (1)
- siva tandava stotram (1)
- Speed up windows (1)
- Spiritual (1)
- Start up Programs (1)
- stotram (1)
- Windows Services (1)
- XP optimization (2)
- XP Services (1)