Web Services .Net

How a WebService is processed in .NET?

How a C# WebService is getting executed in .NET?

The Answer is :
First Client(end user) will request the Web Service in Form of (URI).

Then the DNS will resolve the URI and identifies the ip and route the HTTP request to the corresponding web server (which has the C# WebService ).

Then IIS which is responsible to hold the WebServices and web application identifies that the application is a .NET and map the ASP.NET ISAPI to receive the request.

(Note : IIS can find that a ISAPI is ASP.NET but it cant find it is a WebService or WebApplication in .NET)

Now, the ASP.NET ISAPI will identify that this is a WebService in .NET and forward the request again to .NET HTTPRuntime.
(This process will change unmanage code to manage code)

HTTPRunTime will also can identify a request as an application .

So, as
HTTPRunTime identifies that the request is a WebService .NET request , this delegate the SOAP request(converted in previous step) to .Net WebServiceHandlerFactory.

.Net WebServiceHandlerFactory deserialize the SOAP payload and executes.
(Payload is networking term which contains the actual body of the message) and also execute the request for the WebService.

Again, to display the Response to client as HTML, HTTPRunTime takes the result and serialize to SOAP message and add as SOAP payload of HTTPRunTime.

When HTTPRunTime delegate the response, .NET ISAPI will take and send back to the IIS which in turn returns the response and the Client gets SOAP Message.

Hence the receiving end(Consumer application which grabs the .NET WebService has to deform it and display the HTML response to user.

posted by TechieLion @ 1:02 AM, links to this post

kick it on DotNetKicks.com

Object reference not set to an instance of an object

Object reference not set to an instance of an object.

In Asp.Net this error is so common.

When you are trying to access a member of a class without instance object you will get Object reference not set to an instance of an object error.

So ensure that you are accessing the members with the instance of the class.


Cause of error:

public class ABC{
public void function xyz{....}

public class DEF{
ABC obj1;

The highlighted line indicates that you have declared a variable of type ABC, but not the object reference or you just have created Object instance.

We can call methods or member variables only if we get reference to the instance of a object.

More technically,
ABC obj1; will not create any reference in memory.

After the line ABC obj1 or in the same line itself ,

obj1=new ABC();

the keyword new will allot memory for the instance obj1 and assign the object reference to the instance of the object.

Other lines would be normal and kept unchanged.


Even after this if you are getting the same error Object reference not set to an instance of an object, it means that you have to initialize some member variables.


string example;

Obviously this error would come.
since we failed to initialize this variable no reference would have have got.
So before checking any variable comparison, kindly make ensure to add these lines


So that you can avoid comparing a null object(for which reference not been set) as well as the
above said error Object reference not set to an instance of an object.

Same discussion is available in Object reference not set to an instance of an object.

posted by TechieLion @ 9:19 PM, , links to this post

kick it on DotNetKicks.com