Wednesday, May 6, 2009

Frequently asked interview questions in ASP.Net web services

This article explains the frequently asked interview questions in ASP.Net web services with answers. This covers basic and advanced concept of Web service

1. What is Service Orientated Architecture(SOA)?

A service-oriented architecture (SOA) is a group of services that communicate with each other. The process of communication involves either simple data-passing between a service provider and service consumers, or a more complicated system of two or more service providers. Intercommunication implies the need for some means of connecting two or more services to each other.

Simply, SOA describes an information technology architecture that enables distributed computing environments with many different types of computing platforms and applications.

2. What are the approaches for implementing SOA?

Web services can implement a service-oriented architecture. Implementers commonly build SOAs using Web services standards (for example, using SOAP) that have gained broad industry acceptance.

Building blocks of SOA are

  • The service provider creates a Web service and possibly publishes its interface and access information to the service registry. Each provider must decide which services to expose, how to make trade-offs between security and easy availability, how to price the services, or (if no charges apply) how to exploit them for other value.
  • The service requester or Web service client

3. When do you require doing an Update a Project Web Reference?


The application contains a Web reference to an XML Web service that has been recently modified on the server; you might need to update the reference in your project. While updating web service, it generates a new proxy for the Web service so you can access the new method.

4. What are the Components of Web service?

The componets of ASP.Net web services are

  • SOAP (Simple Object Access Protocol) is a communication protocol it is for communication between applications. Its platform and language independent. It is based on XML and also help to get from Firewall.
  • WSDL(WebService description language) is an XML format for describing network services as a set of endpoints operating on messages containing either document-oriented or procedure-oriented information. It explains Service, method, input and output parameters.
  • UDDI stands for Universal Description, Discovery, and Integration. It is like a "Yellow Pages" for Web Services and is designed to provide detailed information regarding registered Web Services for all vendors. It is maintained by companies like Microsoft, IBM etc


5. What are the different Web Services Protocols?

  • Http-Get protocol This is standard protocol that helps client to communicate with server with HTTP. When client send a request to server via HTTP request and reuired parameter are attached with the querystring.

    E.g http://dotnet/interview.aspx?param1=value1&param=value2 and we get the value from query string.
    Request.querystring("param1")
    Request.querystring("param2").

  • Http-Post is same as Http-Get but the difference is that in place of sending parameters onto the URL information is send with HTTP request message with some extra information which contains Parameters and their values. These Protocols is limited to sending name/value pairs.

  • SOAP: The only difference is that its relies on the XML as compares to Http-Get, Http-Post. SOAP can send not only the name/value pairs but also some complex object also as for example data types, class, objects. SOAP can also uses request/response model as Http-Get, Http-post but it is not limited to Request/Response it can also send types of message. Because its uses XML that is pure text and hence pass firewalls easily.

6. What is Web Service Enhancement 3.0 (WSE)?


Web Services Enhancements for .NET (WSE) is a product that enables you to build secure Web services quickly and easily.This gives wizard based approach for developing and securing web services.

  • The Web Services Enhancements for Microsoft .NET (WSE) has many features to augment applications built on Web services using the .NET Framework 2.0.
  • Securing Applications That Use Web Services
  • Integration with .NET Framework 2.0 and Visual Studio 2005
  • Sending Large Amounts of Data in a SOAP Message Using WSE


7. What are the different types of Security supported in ASP.Net Web services?

The type of Security supported in ASP.Net Web services

  • Anonymous
  • Username
  • Windows(Kerberos)
  • Certificate

8.What are the differences between ASP.net Web Service and .Net Remoting?

  • Web services support interoperability across platforms and are good for heterogeneous environments. .NET Remoting requires the clients be built using .NET or another framework that supports .NET Remoting which means a homogeneous environment.

  • Web services work in a stateless environment where each request results in a new object created to service the request. To maintain state between requests, you can either use the same techniques used by ASP.NET pages, i.e., the Session and Application objects. .NET Remoting supports state management options using Singleton and can correlate multiple calls from the same client and support callbacks.

  • Web services serialize objects through XML contained in the SOAP messages and can thus only handle items that can be fully expressed in XML. .NET Remoting relies on the existence of the common language runtime assemblies that contain information about data types. This limits the information that must be passed about an object and allows objects to be passed by value or by reference.

  • In terms of performance, the .NET Remoting plumbing provides the fastest communication when you use the TCP channel and the binary formatter. In the case of Web services, the primary issue is performance.

  • Web service Can be accessed only over HTTP where as .net Remoting Can be accessed over any protocol (including TCP, HTTP, SMTP and so on)

  • Web services are Easy-to-create and deploy where as Remoting is Complex to program

9. How to avoid timeout in .net web service?

For long running process, the ASP.Net web service may timeout. To avoid this time out error, increase the timeout in Server and client side

At Server Side
<configuration> <system.web>

<httpRuntime executionTimeout="300"/>

</system.web> </configuration>

The above configuration increases request timeout to 5 minutes

At Client side, increase the timeout of the web service proxy
Service1 proxy = new Service1 ();

proxy.Timeout = 300;

10. How to pass the client credentials to a web service using proxy?

To Pass the client credential at the client side using service proxy, write the following code using proxy credentials

// Create a new instance of the proxy class to an XML Web service method.

Service1 proxy = new Service1();

// Add the CredentialCache to the proxy class credentials.

proxy.Credentials = System.Net.CredentialCache.DefaultCredentials;

// Call the method on the proxy class.

int result = proxy.myWebMethod(5,5);

No comments: