Sunday, 18 May 2014

What is CSS & its Properties..

The Whole Shebang

What is CSS?

CSS is a standard for applying style to HTML elements. This styling includes margins, positioning, fonts, colors, and so forth. The styling can apply to the complete document or be granular and apply to a specific element. Theoretically, the use of CSS promotes the separation of content and design, allowing the designer to focus on how a Web application will look while the developer(s) concentrate on the structure and functionality.
The main part of CSS is a rule. A rule consists of a selector (i.e., what will be styled) followed by a declaration (i.e., the style to be applied) that is broken into one or more properties and associated styles. In the following example, h1 is the selector, followed by the color property and the style of blue.
h1 {color: blue;}

What does the cascading portion of CSS mean?

Cascading refers to cascading order. It is a system of sorting the various CSS declarations to avoid conflicts. The process begins with a search for all declarations that apply to specific elements; it ends if no match is found. Cascading occurs if multiple styles are defined for an element. In general, values will be applied from the more specific style sheet. This could be its own article, so please refer to my CSS 101 TechRepublic post for more details.
Note: CSS properties take precedence of HTML attributes, but the HTML attributes will be used when/if a browser does not support CSS.

Is CSS case-sensitive?

The CSS standard is not case-sensitive, but if an XHTML doctype is used, then CSS class names will be case-sensitive in some browsers. In addition, items like font families, image URLs, and other direct references with the style sheet can be case-sensitive. To be safe, you should stick with lower-case to avoid confusion or unexpected problems.

What are different ways to apply styles to a Web page?

There are four ways to integrate CSS into a Web page (some consider items three and four the same):
  1. Inline: HTML elements may have CSS applied to them via the STYLE attribute.
  2. Embedded: CSS may be embedded in a Web page by placing the code in a STYLE element within the HEAD element.
  3. Linked: CSS may be placed in an external file (a simple text file containing CSS) and linked via the link element.
  4. Imported: Another way to utilize external CSS files via @import.

What is an ID selector?

An ID selector is a name assigned to a specific style. In turn, it can be associated with one HTML element with the assigned ID. Within CSS, ID selectors are defined with the # character followed by the selector name. The name can contain characters a-z, A-Z, digits 0-9, period, hyphen, escaped characters, and so forth.
The following snippet shows the CSS example1 defined followed by the use of an HTML element's ID attribute, which pairs it with the CSS selector.
#example1: {background: blue;}
<p id="selector">...</p>

What is a class?

A class is a style (i.e., a group of CSS attributes) that can be applied to one or more HTML elements. This means it can apply to instances of the same element or instances of different elements to which the same style can be attached. Classes are defined in CSS using a period followed by the class name. It is applied to an HTML element via the class attribute and the class name.
The following snippet shows a class defined, and then it being applied to an HTML DIV element.
.classexample {font-family: Helvetica; font-size: 20; background: black;}
<div class="classexample">....</div>
Also, you could define a style for all elements with a defined class. This is demonstrated with the following code that selects all P elements with the column class specified.
p.column {font-color: black;}

What is the difference between an ID selector and CLASS?

An ID selector identifies and sets style to only one occurrence of an element, while CLASS can be attached to any number of elements.

What is contextual selector?

Contextual selector addresses specific occurrence of an element. It is a string of individual selectors separated by white space (search pattern), where only the last element in the pattern is addressed providing it matches the specified context.

What is grouping?

When more than one selector shares the same declaration, they may be grouped together via a comma-separated list; this allows you to reduce the size of the CSS (every bit and byte is important) and makes it more readable. The following snippet applies the same background to the first three heading elements.
h1, h2, h3 {background: red;}

What are child selectors?



A child selector is used when you want to match an element that is the child of another specific element. The parent and child selectors are separated by spaces. The following selector locates an unordered list element within a paragraph element and makes a text within that element bold.
p > ul {font-weight: bold;}


What are pseudo classes?



Pseudo classes allow you to identify HTML elements on characteristics (as opposed to their name or attributes). The classes are specified using a colon to separate the element name and pseudo class. A good example is the :link and :visited pseudo classes for the HTML A element. Another good example is first-child, which finds an element's first child element.
The following CSS makes all visited links red and green, the actual link text becomes yellow when the mouse pointer is positioned over it, and the text of the first element of a paragraph is bold.
a:link {font-color: red;}
a:visited {font-color: green;}
a:hover {font-color: yellow;}
p.first-child {font-weight: bold;}


What does the following CSS do?

P {font-family: Verdana, Arial, Helvetica;}
The CSS sets the font for the P element. If available in the browser, Verdana is used. If Verdana is not available, Arial is used. If Arial is not an option, Helvetica is utilized.

How do you include comments in CSS?

Anything placed between /* and */ in CSS is considered a comment. Comments are ignored by the browser.

Have you utilized any CSS libraries or frameworks?

The answer to this question will not be standard, but it gives you an idea of a candidate's familiarity with the landscape. Possible answers include the YUI Library or YAML, but there are plenty more out there.

What do you see in the future of Web design?

This is an open-ended question that is purely subjective, but I want to hear the candidate discuss the explosion of non-standard devices such as phones, video game consoles, and so forth. These new platforms are changing how sites are designed. The candidate gets extra credit if they drop the phrase "responsive design."

Are you pro or against Flash?

The argument for and against Adobe Flash continues as HTML5 offers better and leaner ways to do the same thing, so this question allows you to hear the candidate's feeling on the subject and lets you know how well they keep up with industry buzz or trends.
CSS Question:-

1. What are different ways to integrate a CSS into a Web page?

There are three ways to integrate CSS into a Web page

a.) Inline: HTML elements may have CSS applied to them via the STYLE attribute.
b.) Embedded: By placing the code in a STYLE element within the HEAD element.
c.) Linked/ Imported: Place the CSS in an external file and link it via a link element.

2.) If background and colour should always be set together, why do they exist as separate properties?

The reasons for this are as follows:
- It increases the legibility of the style sheets. The background property is a complex property in CSS. If it is combined with color, the complexity will further increase.
- Color is inherited, but background isn’t. This can further increase the confusion.

3.) Explain external Style Sheet? How would you link to it?

- External Style Sheet can be called as a template/document/file which contains style information and can be linked with more than one HTML documents.
- Using this the entire site can be formatted and styles just by editing one file.
- The file is linked with HTML documents via the LINK element inside the HEAD element.
<HEAD> <LINK REL=STYLESHEET HREF="style.css" TYPE="text/css"> </HEAD>

4.) What are the advantages and disadvantages of External Style Sheets?

The advantages of External Style Sheets are:

- Using them, the styles of multiple documents can be controlled from one file.
- Classes can be created for use on multiple HTML element types in many documents.
- In complex situations, selector and grouping methods can be used to apply styles.

The disadvantages of External Style Sheets are:

- In order to import style information for each document, an extra download is needed.
- Until the external style sheet is loaded, it may not be possible to render the document.
- For small number of style definitions, it is not viable.

5. What are the advantages and disadvantages of Embedded Style Sheets?

The advantages of Embedded Style Sheets are:

- It is possible to create classes for use on multiple tag types in the document
- Under complex situations, selector and grouping methods can be used to apply styles.
- No extra download is required to import the information.

The disadvantages of Embedded Style Sheets are:

- It is not possible to control the styles for multiple documents from one file, using this method.

6. What are the advantages and disadvantages of Inline Styles?

The advantages of Inline Styles are:

- It is especially useful for small number of style definitions.
- It has the ability to override other style specification methods at the local level.

The disadvantages of Inline Styles are:

- It does not separate out the style information from content.
- The styles for many documents can not be controlled from one source.
- Selector grouping methods can not be used to handle complex situations.
- Control classes can not be created to control multiple element types within the document.

7. How can you eliminate the blue border around linked images on web page?

This can be done by specifying the border property for linked images in your CSS as none:
For e.g.
a img { border: none ; }

However, this makes it difficult for the users to differentiate between the clickable and non-clickable images.

8. What is CSS selector?

- Basically it is a string that identifies the elements to which a particular declaration or set of declarations will apply.
- It can also be referred to as a link between the HTML document and the style sheet.
- It is equivalent of HTML elements.

For example :
A {text-indent: 12pt}

Here, the selector is A, which is called as type selector.

9. What is Tweening?

- It is the short form for in-betweening.
- It is the process of generating intermediate frames between two images.
- It gives the impression that the first image has smoothly evolved into the second one.
- It is an important method used in all types of animations.
- In CSS3, Transforms(matrix,translate,rotate,scale etc) module can be used to achieve tweening.

10. Explain RWD.

- RWD is the abbreviation for Responsive web design.
- In this technique, the designed page is perfectly displayed on every screen size and device, be it desktop, mobile, laptop or any other device. You don’t need to create a different page for each device.

11. What is the use of CSS sprites?

- A web page with large number of images takes a longer time to load. This is because each image separately sends out a http request.
- The concept of CSS sprite helps in reducing this loading time for a web page by combining various small images into one image. This reduces the numbers of http request and hence the loading time.

CSS interview questions and answers

1. Explain in brief about the term CSS.
A stylesheet language used to describe the presentation of a document written in a markup language.................
Read answer
2. What are the various style sheets?
Inline, external, imported and embedded are the different types of style sheets...............
Read answer
3. What are style sheet properties?
CSS Background
CSS Text
CSS Font
CSS Border
CSS Outline..............
Read answer
4. List various font attributes used in style sheet.
font-style
font-variant
font-weight
font-size/line-height..................
Read answer
5. Explain inline, embedded and external style sheets.
Inline  - If only a small piece of code has to be styled then inline style sheets can be used..............

What is .rolloverfordnd?
.rolloverfordnd is a class selector to which the style gets applied. Dot(.) is used for class selector as it applies to any HTML elements that have the attribute as: class="rollverfordnd". This attribute can be added to multiple elements such that, if separate declarations are defined then the declaration with a specific selector win over any other.

Why my div are of different size in IE?
The specification which is been given for the size of div in IE is as follows:
Width of a box (i.e. a containing area) in CSS = width + border +padding (+margin).
Total box width is: 300px with a padding of 10px and a border of 5px. This requires the total area of 330px. IE5 uses different rules and out of width it subtracts the padding and border from the specific width so the total width becomes 270px. So, instead of 330px, IE uses 270px that is why the div are of different sizes.

What are the media types CSS allows?
Media is used to render the design and customize the documents. Media types allow user to load and apply their own selected style sheets. Media control is applied to external style sheets, in this way user can save time by retrieving the sheets from the network itself. Example: Speech based browsers can avoid the download of style sheets which are designed for visual rendering.

Can someone else's Style Sheet be used without their permission?

Style sheet information is written using special language syntax. Yes, someone else’s style sheet can be used without their permission, but it is not recommended, as it might overload the server. So, a local copy should be maintained, created and used instead of referencing a remote copy.

How do you override the underlining of hyperlinks?
Using CSS extra style functionality can be provided, that can control the status of underlining of hyperlinks. You can use style sheets in whatever way you want and can control the look and style of your display. The way in which it can be done is by introducing external level style sheet:
A { text-decoration: none } //within an anchor element as:
<a HREF="example.htm" STYLE="text-decoration: none">link text</a>

What is external Style Sheet? How to link it with HTML document?
External Style Sheet allows you to write the style content just like you do in a normal style sheet, but the advantage of it is that, it can be used anywhere and can be linked with HTML documents. It is very easy, convenient and portable way to use the formatting for the entire site.
External Style sheets can be linked with HTML documents by using a LINK element in HEAD area. It has the extension as .css. Example code:
<HEAD>
<LINK href="special.css" rel="stylesheet" type="text/css">
</HEAD>

What is imported Style Sheet? How to link it with HTML document?
Imported Style Sheet allows you to import the custom made style sheet from anywhere, in your HTML document. In this, one main sheet is made that consists of declarations applied to the whole site and other sheet is made, that consists of only specific declarations applied to specific documents. To link imported style sheet to HTML document @import is used in the STYLE element. For example:
<STYLE TYPE="text=css">
<!--
@import url(http://www.and.so.on.partial1.css);
@import url(http://www.and.so.on.partial2.css);
.... Other statements
-->
</STYLE>

How the concept of Style sheet is different from HTML?
HTML is an easy way to represent the structure, but when it comes to style then HTML becomes very hard to work with. The concept of style sheet is introduced to make the work easy for you to design without any hassles. Style sheets increases browser capabilities and allow different formatting options which have not been included in HTML.

Which style specification method should be used?


- External Style Sheets: should be used when you want to apply the same style to multiple documents.
- Embedded Style Sheets: should be used if you want to specify styles for a single document.
- Inline Styles: should be used if you want to apply style to one or few elements in a document.


What are logical and physical tags?
- Physical tags are known as presentational markup. They are used with recent versions of HTML. It suggests the visual appearance of the content. Ex: Italics, Underline, Bold
- Logical tags are not used for appearances, but they are used to show the purpose of the content written. For example em tag is used for emphasis not for any other thing.

Other Question & Answers

What is the concept of Postback in ASP.NET?
A postback is a request sent from a client to server from the same page user is already working with.
ASP.NET was introduced with a mechanism to post an HTTP POST request back to the same page. It’s basically posting a complete page back to server (i.e. sending all of its data) on same page. So, the whole page is refreshed.
Another concept related to this approach is “Callback” that is also asked sometimes during a technical interview question. Click here to understand Postback Vs Callback in ASP.NET.
Difference between ASP.NET WebForms and ASP.NET MVC?
ASP.NET Web Forms uses Page controller pattern approach for rendering layout. In this approach, every page has it’s own controller i.e. code-behind file that processes the request. On the other hand, ASP.NET MVC uses Front Controller approach. In this approach a common controller for all pages, processes the requests.
Please follow for detailed information on WebForms Vs MVC.
Please briefly explain ASP.NET Page life Cycle?
ASP.NET page passes through a series of steps during its life cycle. Following is the high-level explanation of life cycle stages/steps.

Initialization: Controls raise their Init event in this stage.Objects and variables are initializes for complete lifecyle of request.

LoadViewState: is a post back stage and loads the view state for the controls that enabled its view state property.

LoadPostBackData: is also a post back stage and loads the data posted for the controls and update them.

Load: In this stage page as well as all the controls raise their Load event. Till this stage all the controls are initialized and loaded. In most of the cases, we are coding this event handler.
RaisePostBackEvent: is again a postback stage. For example, it’s raise against a button click event. We can easily put our code here to perform certain actions.
SaveViewState: Finally, controls state is saved in this stage before Rendering HTML.
Render: This is the stage where HTML is generated for the page.
Dispose: Lastly, all objects associated with the request are cleaned up.
For very detailed explanation of Page Life Cycle is explained here.
.NET Jobs from Indeed in UAE

What is the difference between custom controls and user controls?
Custom controls are basically compiled code i.e. DLLs. These can be easily added to toolbox, so it can be easily used across multiple projects using drag and drop approach. These controls are comparatively hard to create.
But User Controls (.ascx) are just like pages (.aspx). These are comparatively easy to create but tightly couple with respect to User Interface and code. In order to use across multiple projects, we need to copy and paste to the other project as well.
What is the concept of view state in ASP.NET?
As in earlier question, we understood the concept of postback. So, in order to maintain the state between postbacks, ASP.NET provides a mechanism called view state. Hidden form fields are used to store the state of objects on client side and returned back to server in subsequent request (as postback occurs).
Difference between Response.Redirect and Server.Transfer?
In case of Response.Redirect, a new request is generated from client-side for redirected page. It’s a kind of additional round trip. As new request is generated from client, so the new URL is visible to user in browser after redirection.
While in case of Server.Transfer, a request is transferred from one page to another without making a round trip from client. For the end user, URL remains the same in browser even after transferring to another page.
Please briefly explain the usage of Global.asax?
Global.asax is basically ASP.NET Application file. It’s a place to write code for Application-level events such as Application start, Application end, Session start and end, Application error etc. raised by ASP.NET or by HTTP Modules.
There is a good list of events that are fired but following are few of the important events in Global.asax:
  • Application_Init occurs in case of application initialization for the very first time.
  • Application_Start fires on application start.
  • Session_Start fires when a new user session starts
  • Application_Error occurs in case of an unhandled exception generated from application.
  • Session_End fires when user session ends.
  • Application_End fires when application ends or time out.

What are the different types of Validation controls in ASP.NET?

In order to validate user input, ASP.NET provides validation server controls. All validation controls inherits from BaseValidator class which contains the common validation properties and methods like ControlToValidate, Enabled, IsValid, EnableClientScript, ValidationGroup,Validate() etc.
ASP.Net provides a range of validation controls:
  • RequiredFieldValidator validates compulsory/required input.
  • RangeValidator validates the range. Validates that input falls between the given range values.
  • CompareValidator validates or compares the input of a control with another control value or with a fixed value.
  • RegularExpressionValidator validates input value against a defined regular expression pattern.
  • CustomValidator allows to customize the validation logic with respect to our application logic.
  • ValidationSummary displays all errors on page collectively.

What are the types of Authentication in ASP.NET?

There are three types of authentication available in ASP.NET:
  • Windows Authentication: This authentication method uses built-in windows security features to authenticate user.
  • Forms Authentication: authenticate against a customized list of users or users in a database.
  • Passport Authentication: validates against Microsoft Passport service which is basically a centralized authentication service.

What are Session state modes in ASP.NET?

ASP.NET supports different session state storage options:
  • In-Process is the default approach. It stores session state locally on same web server memory where the application is running.
  • StateServer mode stores session state in a process other than the one where application is running. Naturally, it has added advantages that session state is accessible from multiple web servers in a Web Farm and also session state will remain preserved even web application is restarted.
  • SQLServer mode stores session state in SQL Server database. It has the same advantages as that of StateServer.
  • Custom modes allows to define our custom storage provider.
  • Off mode disables session storage.

Question about Web services..

 what are web services? 
The simplest answer would be that a web service is any piece of software available over the Internet that uses a standardized XML messaging system. To drill down, XML is a language used to encode all communications to a Web service. Because all communication is in XML, Web services are not limited to any one operating system or programming language. For instance, Java can talk with Per, Windows applications can talk with Unix applications, and so forth.
Beyond this basic definition, a Web service may further be defined as such:
1. A web service can have a public interface, defined in a common XML grammar. The interface describes all the methods available to clients and specifies the signature for each method. The interface definition is currently created using the Web Service Description Language (WSDL).
2. If you create a Web service, there should be some relatively simple mechanism for you to publish it. This would be the UDDI, Universal Description, Discovery, and Integration mechanism that allows the creators to house and service its public interface. Web services currently run a diversified range of production from news syndication and stock-market data to weather reports and package-tracking systems.
Remember these definitions as interviewers are likely to ask how you classify web services. Now let’s move on to frequently asked questions during web services interviews.

What are the components of web services?

There are four main components: XML, SOAP, UDDI, AND WSDL.
XML: eXtensible Markup Language is a uniform data representation and exchange mechanism.
SOAP: Simple Object Access Protocol, SOAP is a standard way of using XML vocabulary to enable programs on separate computers to interact across any network and describing messages between applications.
UDDI: Universal Description, Discovery, and Integration specification, UDDI is a mechanism to register and located WS based application.
WSDL: Web Services Description Language, this is a standard meta language to describe the services offered. Specifically, WSDL states what a request message much contain and what the response will look like in a clear notation. WSDL also defines where the service is available and what communications protocol is used to talk to that service.

What is new about Web services?

The answer is simply, XML. XML lies at the core of Web services, and provides a common language for describing Remote Procedure Calls, Web services, and Web service directories. Prior to XML, one could share data among different applications, but XML makes this so much easier to do. In the same vein, one can share services and code without Web services, but XML makes it easier to do these as well. By standardizing with XML, different applications can more easily talk to one another, and this makes software a whole lot more interesting. Try this course on getting started with XML to master this separate language.

What’s an example of a real web service in action?

IBM Web Services Browser, available on the IBM Alphaworks site, is a good and intuitive example of a real web service. The browser provides a series of web services demonstrations. Behind the scenes, it ties together SOAP, WSDL, and UDDI to provide a simple plug-and-play interface for finding and integrating web services. For example, you can find a stock-quote service, a traffic-report service, and a weather service. Each service is independent, and you can stack services like building blocks.

Explain the web services architecture.

The operations between different software applications, which are running on a variety of platforms and frame-working are supported by web services. This web services architecture provides the concepts, modeling, and understanding web services and relationships among the components. The WSA specifies the minimal characteristics that are very common for all web services and a number of characteristics to the needed web services. WSA is called interoperability architecture that means the global elements of a global web service network are identified by this architecture in order to perform the interoperability between the web services.

What are the steps to get a proxy object of a web service at the client side?

There are three steps to get a proxy object of a web service at the client side.
1. Access UDDI node for a list of web services.
2. Services thus responded by UDDI have URL pointing to DISCO or WSDL document.
3. Parse DISCO and WSDL document and build a proxy object which can communicate with the web service.

What types of operations are available in WSDL?

There are four operations available:
1. One-way, where the operation can receive a message but will not return a response.
2. Request-response, where the operation can receive a request and will return a response.
3. Solicit-response, where the operation can send a request and will wait for a response.
4. Notification, where the operation can send a message but will not wait for a response.

Define a REST web service.

REST is Representational State Transfer and it is a network of web pages where the client progresses through an application by selecting links. REST is an architectural style that uses existing standards such as HTTP.

Why do we need .Net Web Services?

We have a number of heterogeneous technologies available on internet. The demand for reusable components across platforms and programming languages are high. Most of the components have the limitation that they can't share or exchange data across different platforms, they are mostly language specific or platform specific. The technologies like COM, RMI, CORBA etc. contributed best to fulfill requirements to some extent, but components result from these said technologies are mostly either language specific or platform specific. 
To avoid above problem, we need to have web services. Through web services we have overcome the problem of interoperability between languages and platforms. Web services uses SOAP as transport protocol which uses a text based messaging model, i.e. XML to communicate between disparate systems. 

Deploying a Web Service

Deploying the .Net Web Services is as simple as any ASP.NET application. Similar to ASP.NET applications, you need to copy or upload the .ASMX file and the .DISCO files to the appropriate directories, and that's it.

What is new about Web services? 

People have been using Remote Procedure Calls (RPC) for some time now, and they long ago discovered how to send such calls over HTTP.
So, what is really new about Web services? The answer is XML.
XML lies at the core of Web services, and provides a common language for describing Remote Procedure Calls, Web services, and Web service directories.
Prior to XML, one could share data among different applications, but XML makes this so much easier to do. In the same vein, one can share services and code without Web services, but XML makes it easier to do these as well.
By standardizing on XML, different applications can more easily talk to one another, and this makes software a whole lot more interesting.

Explain WebMethod Attribute in Asp.Net Web Service..?

Attaching the WebMethod attribute to a Public method indicates that you want the method exposed as part of the XML Web service. The WebMethod attribute tells .NET that a particular public method should be exposed as a web-callable method. The WebMethod attribute has six associated properties to document and change the behavior of your web method. They are:

Description
MessageName
EnableSession
CacheDuration
TransactionOption
BufferResponse

The first two properties are used to document a web method, while the others affect its behavior.

Explain the protocols a .Net Web Service uses...??

In .Net, a web service is bind with three different protocols such as HTTP/POST, HTTP/GET, and SOAP. This allows client with three options to choose for communication. The protocols are included in the WSDL file that is automatically generated in .NET.
Http-Get and Http-Post can only be used when name/value pairs of data is dealt with. But when data is complex in nature such as ASP.NET dataset, XML notes etc, then we can use SOAP that serializes data in simpler form before sending.  

I keep reading about Web services, but I have never actually seen one. Can you show me a real Web service in action? 

If you want a more intuitive feel for Web services, try out the IBM Web Services Browser, available on the IBM Alphaworks site. The browser provides a series of Web services demonstrations. Behind the scenes, it ties together SOAP, WSDL, and UDDI to provide a simple plug-and-play interface for finding and invoking Web services. For example, you can find a stock-quote service, a traffic-report service, and a weather service. Each service is independent, and you can stack services like building blocks. You can, therefore, create a single page that displays multiple services--where the end result looks like a stripped-down version of my.yahoo or my.excite.


What is the Web service protocol stack?
The Web service protocol stack is an evolving set of protocols used to define, discover, and implement Web services. The core protocol stack consists of four layers:
Service Transport: This layer is responsible for transporting messages between applications. Currently, this includes HTTP, SMTP, FTP, and newer protocols, such as Blocks Extensible Exchange Protocol (BEEP).
XML Messaging: This layer is responsible for encoding messages in a common XML format so that messages can be understood at either end. Currently, this includes XML-RPC and SOAP.
Service Description: This layer is responsible for describing the public interface to a specific Web service. Currently, service description is handled via the WSDL.
Service Discovery: This layer is responsible for centralizing services into a common registry, and providing easy publish/find functionality. Currently, service discovery is handled via the UDDI.
Beyond the essentials of XML-RPC, SOAP, WSDL, and UDDI, the Web service protocol stack includes a whole zoo of newer, evolving protocols. These include WSFL (Web Services Flow Language), SOAP-DSIG (SOAP Security Extensions: Digital Signature), and USML (UDDI Search Markup Language). For an overview of these protocols, check out Pavel Kulchenko's article, Web Services Acronyms, Demystified, on XML.com.
Fortunately, you do not need to understand the full protocol stack to get started with Web services. Assuming you already know the basics of HTTP, it is best to start at the XML Messaging layer and work your way up.

What is XML-RPC? 

XML-RPC is a protocol that uses XML messages to perform Remote Procedure Calls. Requests are encoded in XML and sent via HTTP POST; XML responses are embedded in the body of the HTTP response.

More succinctly, XML-RPC = HTTP + XML + Remote Procedure Calls.
Because XML-RPC is platform independent, diverse applications can communicate with one another. For example, a Java client can speak XML-RPC to a Perl server.
To get a quick sense of XML-RPC, here is a sample XML-RPC request to a weather service (with the HTTP Headers omitted):
<?xml version="1.0" encoding="ISO-8859-1"?>
<methodCall>
<methodName>weather.getWeather</methodName>
<params>
<param><value>10016</value></param>
</params>
</methodCall>
The request consists of a simple element, which specifies the method name (getWeather) and any method parameters (zip code).

Here is a sample XML-RPC response from the weather service:

<?xml version="1.0" encoding="ISO-8859-1"?>
<methodResponse>
<params>
<param>
<value><int>65</int></value>
</param>
</params>
</methodResponse>
The response consists of a single element, which specifies the return value (the current temperature). In this case, the return value is specified as an integer.
In many ways, XML-RPC is much simpler than SOAP, and therefore represents the easiest way to get started with Web services.
The official XML-RPC specification is available at XML-RPC.com. Dozens of XML-RPC implementations are available in Perl, Python, Java, and Ruby. See the XML-RPC home page for a complete list of implementations.

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.
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.
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.
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.