Remoting & Web Services

Do webservice have state ?

Twist :- How can we maintain State in Webservices ?

Webservices as such do not have any mechanism by which they can maintain state. Webservices can access ASP.NET intrinsic objects like Session, application and so on if they inherit from “WebService” base class.

<%@ Webservice %> Imports System.Web.Services

Public class TestWebServiceClass Inherits WebService

<WebMethod> Public Sub SetSession(value As String) session(“Val”) = Value

End Sub

end class

Above is a sample code which sets as session object called as “val”. TestWebserviceClass is inheriting from WebService to access the session and application objects.

What are the steps to create a webservice and consume it ?

Note :- For this question this book will make a attempt by creating a simple webservice and explaining steps to acheive it. A simple webservice will be created which takes two number and gives addition result of the two number. In CD sample webservice project with folder name “MathsWebService” is provided and same will be explained below. Definitely the interviewer will not expect such a detail answer but this book will explain you in detail so that you are on right track during interview.

This webservice will add two numbers and give to the calling client.All the below steps are according to More >

What is file extension of Webservices ?

.ASMX is extension for Webservices.

Note :- After this we are going to deal with a sample of webservice. In VS2005 webproject is created from the menu itself as compared to 2003 where it was present in the explorer.

Which attribute is used in order that the method can be used as WebService ?

WebMethod attribute has to be specified in order that the method and property can be treated as WebService

What the different phase/steps of acquiring a proxy object in Webservice ?

Following are the different steps needed to get a proxy object of a webservice at the client side :-

?   Client communicates to UDI node for WebService either through browser or UDDI’s public web service.

?   UDII responds with a list of webservice.

?   Every service listed by webservice has a URI pointing to DISCO or WSDL document.

?   After parsing the DISCO document, we follow the URI for the WSDL document related to the webservice which we need.

?   Client then parses the WSDL document and builds a proxy object which can communicate with Webservice.

What is WSDL?

Web Service Description Language (WSDL)is a W3C specification which defines XML grammar for describing Web Services.XML grammar describes details such as:-

?   Where we can find the Web Service (its URI)?

?   What are the methods and properties that service supports? ?   Data type support.

?   Supported protocols

In short its a bible of what the webservice can do.Clients can consume this WSDL and build proxy objects that clients use to communicate with the Web Services. Full WSDL specification is available at http://www.w3.org/TR/wsdl.

What is DISCO ?

DISCO is the abbreviated form of Discovery. It is basically used to club or group common services together on a server and provides links to the schema documents of the services it describes may require.

What is UDDI ?

Full form of UDDI is Universal Description, Discovery and Integration. It is a directory that can be used to publish and discover public Web Services. If you want to see more details you can visit the http://www.UDDI.org .

What is a Web Service ?

Web Services are business logic components which provide functionality via the Internet using standard protocols such as HTTP.

Web Services uses  Simple Object Access Protocol (SOAP) in order to expose the business functionality.SOAP defines a standardized format in XML which can be exchanged between two entities over standard protocols such as HTTP. SOAP is platform independent so the consumer of a Web Service is therefore completely shielded from any implementation details about the platform exposing the Web Service. For the consumer it is  simply a black box of send and receive XML over HTTP. So any web service hosted on windows More >

What is ObjRef object in remoting ?

All Marshal() methods return ObjRef object.The ObjRef is serializable because it implements the interface ISerializable, and can be marshaled by value. The ObjRef knows about :-

?   location of the remote object ?   host name

?   port number ?   object name.