1. What are Windows
services?
Windows services, previously known as NT
services, are applications that are installed on the system as system services.
In other words, Windows services are applications that run in the background
with the Windows operating system. The primary use of Windows services is to
reduce the consumption of memory required for performing backend operations.
Let's take an example to understand this easily. Suppose you want to perform a
variety of functions, such as monitor the performance of your computer or
application, check the status of an application, and manage various devices,
such as printers.
In such a case, you can use Windows services to reduce memory consumption. In addition, Windows services can run on your system even if you have not logged on to your computer. In addition, these services do not have any user interface.
In such a case, you can use Windows services to reduce memory consumption. In addition, Windows services can run on your system even if you have not logged on to your computer. In addition, these services do not have any user interface.
2. Can you share a
process between Windows services?
Yes, you can share a process between Windows
services.
3. In .NET, which is
the parent class to create all Windows services?
The ServiceBase class is the parent
class to create all Windows services.
4. Which class in .NET
is used to install a Windows service?
The ServiceInstaller class, also known as
the project installer class, is used to install a Windows service.
5. While installing a
Windows service, an EventLogInstaller class is automatically
created to install the event log related to the particular service. Is it true?
Yes, it is true.
6. Which property of
the ServiceBase class can be used to
specify whether a service can be paused and resumed?
The CanPauseAndContinue property provides such
type of service.
7. Describe the services that UDDI
provides to Web applications.
UDDI provides the following types of services to a Web
application:
- XML
Schema for business descriptions - Includes information about the service
publisher (contact name, address, and so on) and specifications on the Web
service
- Web
registry of Web services - Includes business, service, and binding
information for the Web service
8. Write the file extension for a Web
service.
A Web service file extension is .asm file. For example, service1.asmx is a Web service
file.
9. Which method is used to uninstall
the Windows services?
The Uninstall() method is used to
uninstall the Windows services.
10. What is the use of the mustUnderstand attribute in the
Header element of a SOAP message?
The mustUnderstand attribute indicates
that a header entry is either required or optional for the recipient to process
further.
11. Explain the WSDL.
WSDL is a short form for Web Services Description Language,
which is used to describe a Web service in terms of the messages that it
creates and accepts. The WSDL document is an XML file that contains the
interface schema for the Web service. It identifies the methods that are used
during the exchange between a Web service consumer and a Web service provider.
The following are the elements contained in the WSDL document:
- Types - Describe the
variations of data types that are used to exchange messages between the user
and the provider.
- Message - Describes the
actual message or method call.
- portType - Describes the
set of operations and each related message.
- binding - Describes the
protocol details.
- service - Used to make
groups a set of related ports together.
12. What advantage UDDI has over DISCO?
The UDDI directory has an advantage over a DISCO file, as it
provides a single location where a client can find the Web services offered by
different organizations.
13. How can you ensure that only
authorized users access your Web service?
You should use the <authorization> element to ensure
that only authorized users access your Web service. This element allows or
denies access to your Web service according to their role.
14. Describe the EventLog class.
The EventLog class is used to
access the Windows event logs from Windows services. Using EventLog, you can also
customize Windows event logs that record information about important software
and hardware events, such as the events of the .NET controls, keyboard, or
other hardware devices.
The EventLog class allows you to read or write to event logs, delete logs, and create as well as delete event sources. You can use the EventLog class to create event logs while creating an event source. An event source can be used to write to only one event log at a particular time. However, it is possible to associate one event log to multiple sources.
The EventLog class allows you to read or write to event logs, delete logs, and create as well as delete event sources. You can use the EventLog class to create event logs while creating an event source. An event source can be used to write to only one event log at a particular time. However, it is possible to associate one event log to multiple sources.
15. How can you prevent your Web
services from unauthorized access?
The following are the ways to prevent your Web service from unauthorized
access:
- Using
encryption and message-based security.
- Using
authentication and access controls for the Web service.
16. Explain the concept of Web services
in brief.
A Web service may be defined as an independent and
self-sustained unit of a software application that is hosted on the Web and
implement specific functionalities to execute the business logic. A Web service
provides so many functionalities, such as generating pay slips for employees,
computing tax, broadcasting weather report, and providing updated news. The Web
service allows application to share information or exchange data with other
applications across different operating systems and hardware.
Therefore, the work of a Web service is to unite software by exchanging data irrespective of their operating systems, supported hardware, and programming language used in their development. The Web services transfer data in the XML format and use Simple Object Access Protocol (SOAP) to communicate. It is an XML based protocol. The Web services use Web Services Description Language (WSDL) and Universal Description, Discovery, and Integration (UDDI) to describe itself.
Therefore, the work of a Web service is to unite software by exchanging data irrespective of their operating systems, supported hardware, and programming language used in their development. The Web services transfer data in the XML format and use Simple Object Access Protocol (SOAP) to communicate. It is an XML based protocol. The Web services use Web Services Description Language (WSDL) and Universal Description, Discovery, and Integration (UDDI) to describe itself.
17. What advantages have Web services
over Component Object Model (COM) and Distributed Component Object Model
(DCOM)?
The advantages of Web services over COM and DCOM are as
follows:
- Web
services are simple to use and can be implemented on varied platforms.
- Web
services are loosely coupled; as a result, their interfaces and methods
can be extended.
- Web
services do not carry any state information with them so that multiple
requests can be processed simultaneously.
18. Mention the namespace that you must
import in code to build a Web service.
System.Web.Services is the elementary
namespace, which must be imported to develop code of a Web service.
19. What does the portType element of a WSDL
document contain?
The portType element contains the
operations exposed by the Web service, and the messages involved in the
communication between the Web service and its consumers.
20. What is DISCO?
DISCO is a technology developed by Microsoft to publish and
discover Web services. It discovers URLs of all XML Web services located on a
Web server and creates a list of these Web services in a file called as a DISCO
file.
21. Which two methods are used to
discover the URL of Web services?
The two methods to discover the URL of Web services are Web
service discovery tool (Disco.exe) and UDDI.
22. Which step is necessary to perform
before a Web service can be consumed?
It is necessary to build a proxy class by using the wsdl.exe utility before a Web
service can be consumed.
23. Which property of the WebMethod attribute allows you
to maintain the state of objects across sessions in a Web method?
The WebMethod attribute's EnableSession property enables you
to enable session state for a Web method.
24. Write the names of public
properties defined in the WebService class.
There are many properties defined in the WebServices class:
- Application - Obtains the
application object for the current HTTP request
- Context - Obtains the HttpContext object for the
current request, which encapsulates all HTTP-specific context used by the
HTTP server to process Web requests
- Server - Obtains the HttpServerUtility object for the
current request
- Session - Obtains the HttpSessionState object for the
current request
- SoapVersion - Obtains the
version of the SOAP protocol used to make the SOAP request to a Web
service
- User - Obtains the
Server User Object. This property can be used to authenticate whether a
user is authorized to execute the request.
·
25. What do you understand by SOAP encoding?
·
The
Serialization of the types, such as integers and strings, inside a SOAP message
is called encoding. The SOAP objects use XML elements and attributes to
serialized data, for example, encodingStyle is an attribute of theEnvelop element, which is used
to specify the encoding rules for a SOAP object.
·
26. What is the use of a .disco file?
·
A
client application uses a .disco file to locate or
discover the documents that contain the description of a Web service. The
.disco file contains links to other resources, which describe essential
features, such as capabilities of a Web service. The links contained in a .disco file can refer to
other discovery documents or XSD schemas. The description about the services
and capabilities of a Web service is written in Web services Description
Language (WSDL). A .disco file can also contain
the information about other XML Web services that reside on the same or a
different Web server.
·
27. Mention the name of the directory where it is
necessary to locate the proxy file to use a Web service.
·
The
proxy file must be stored in the /bin directory. This
directory is situated under the root directory of the application.
·
28. Does a Web service have state?
·
The
Web services do not have any technique to maintain state. However, it can
access ASP.NET objects, such as application and session if they extend from the WebService base class.
·
29. Which namespace must be included in a code that
enables a XML Web service to write events in an event log file?
·
The System.Diagnostics is the namespace,
which must be included in a code to enable a Web service for writing events in
an event log file.
·
30. Which tool installs the DLL on your local computer
and installs the Windows service in a transactional manner?
·
The Installutil.exe tool.
-----------------------------------------xxxxxxx-----------------------
Creating ASP.NET Web Services
Using
the .NET Framework, it's easy to get a basic service up and running. In just a
few minutes and fewer lines of code, you can put together a simple "Hello
World" service without any understanding of HTTP, SOAP, WSDL or any of the
several technologies that form the basis for web services. In fact, if you're a
Microsoft Visual Studio .NET user, all you need to do to create a simple
"Hello, World" service is to open a new Visual C# or Visual Basic
ASP.NET Web Service project and uncomment the sample code provided by the
template.
In
this chapter, you'll learn about ASP.NET, the new Microsoft technology for
building web applications and services, and how to use the .NET platform and
Visual Studio .NET to create some simple web services. We'll also talk about
some of the features of .NET that will get you on the road to developing
well-documented scalable web service applications. By the end of this chapter,
you'll have a solid understanding of how .NET supports web services and how to
use the .NET platform to create them. We'll start with the ubiquitous
"Hello, World" example exposed as a web service.
In
this section, you'll create a simple web service in the "Hello,
World" tradition. Through this brief example, you'll see how easy it is to
use ASP.NET to create a working web service (with a text editor or with VS.NET)
and learn about the basic technologies behind .NET web service.
While
Visual Studio .NET provides a feature-rich integrated development environment
for .NET development, it's not required to create .NET web services.
Applications can also be created using your favorite text editor and the
command-line tools that ship with the .NET Framework SDK. Here, we use Notepad
as a text editor, but you should feel free to use whatever editor you're most
comfortable with (Emacs or vi).
If
you chose to develop with a text editor, you must place all of your code in one
or more text files, assign them each the file extension .asmx and
place them in an IIS folder on a server or workstation that has the .NET
Framework installed. Once you save the code to a folder served by the IIS web
server, it's ready to run--that's it! How you get the file to your web server
is your business. If you're running IIS locally on your workstation (and you've
installed the .NET Framework), this is as simple as saving the file to a
suitable location on your local drive (e.g., c:\inetpub\wwwroot\).
If you're using a remote server (in which case there's no need to have the .NET
Framework installed locally), you might have to use FTP or a network share
instead (more about this later).
Once
you've chosen a text editor and file location, all that's left is to write the
code.
Example 2-1 lists the code for a C# version of the ubiquitous
"Hello, World" application; unlike the classic desktop version, this
one delivers its familiar message over the Web through an exposed method calledHelloWorld(). To identify the class
and method as a web service to the compiler, this code uses some special
notation. It also includes an ASP.NET directive at the head of the file.
To
create a C# version of the HelloWorld web service, enter the
code from Example 2-1 exactly as it appears, and save the file to your web server
under the c:\inetpub\wwwroot folder (or whatever folder is the
web root folder for your system) with the name HelloWorld.asmx.
<%@ WebService
Language="C#"
Class="ProgWS.Ch02.HelloWorldService"
%>
using
System.Web.Services;
namespace ProgWS.Ch02
{
public class HelloWorldService: WebService
{
[WebMethod]
public string HelloWorld()
{
return "Hello World";
}
}
}
In
the following sections, we'll explain the standard elements of this web service
source file and then show you how to test it.
No comments:
Post a Comment