free ebooks

 

 

 Home
105 Computers & InternetProgramming > Java  
Xml Web Services And Soap

Introduction to Web Services

 

We embark upon our subject of Web Services with the primary assumption that you have read either our book on ASP.NET, or any one of the innumerable others, strewn all over the market. So, we will not submerge ourselves into every microscopic detail about either the C# programming language or ASP.NET. This book is fully dedicated to the understanding and building of Web Services, since Microsoft has precluded all the other options for building commercial applications for the Net. A Web Service is a piece of program code placed on the Server, such that it can thereon be accessed or executed by the entire world.

 

Create a file named a.asmx in the folder c:inetpubwwwroot, with the contents laid down below. IIS, the web server on our machine, makes this directory the root or home directory.

 

a.asmx

public class zzz

{

public string abc()

{

return "vijay";

}

}

 

Enter the following URL in Internet Explorer:

 

http://localhost/a.asmx

 

On doing so, an error will be displayed with the following message:

 

Output

Parser Error Message: The page must have a <%@ webservice class="MyNamespace.MyClass" ... %> directive.

 

Before we advance any further, a few fundamental concepts need to be addressed immediately. Even though the file has the extension of asmx, it has a striking resemblance to a C# program. The error is a fitting testimony to the fact that the IIS web server is capable of recognizing and handling files that have the asmx extension. Hence, it seeks out the WebService directive. This WebService directive provides information to the web server about the class that represents the functioning of a WebService. And, since every asmx file must commence with this directive, we incorporate this directive into the asmx file.

 

a.asmx

<%@ WebService Language="C#" Class="zzz" %>

public class zzz

{

public string abc()

{

return "vijay";

}

}

 

In C#, all the code is encompassed in classes. The class named zzz contains a function named abc, which returns a simple string of 'vijay'. On entering the URL of http://localhost/a.asmx in Internet Explorer, a page bursting with information gets displayed. However, there is no function by the name of abc for execution.

 

IIS is cognizant of the fact that an asmx file encloses code that others may call remotely. Therefore, on stumbling upon a file with the extension of asmx, it displays the following large html page:

Read More

 Additional Info
 
 No. 223
 Posted on 8 June, 2006
 
218
 
 
Bookmark This Page
Facebook Twitter stumbleupon

Share
Email
Google

Link to us from your website or blog by using the code below in your html
   
@2008 ebooklobby privacy policy email: info [at] goaheadweb.co.uk