soap request and response example in

  • Every SOAP request and response are made up of SOAPEnvelope. SOAPEnvelope has SOAPHeader, SOAPBody, SOAPFault.
  • SOAP always uses Http Post method and the SOAPEnvelope is submitted as MessageBody.
  • o A Webservice developed in .Net can be used by an Http Client also. Here the method name is submitted as the PathInfo and the parameters are posted as a string of Name-Value pairs.

http:// ServerName/ApplicationName/ DemoService.asmx/ MethodName

SOAP Request

POST /DecWebServices/DemoService.asmx HTTP/1.1

Host: localhost

Content-Type: text/xml; charset=utf-8

Content-Length: length

SOAPAction: “”

<?xml version=”1.0″ encoding=”utf-8″?>

<soap:Envelope xmlns:xsi=”” xmlns:xsd=”” xmlns:soap=””>


<Add xmlns=””>






SOAP Response

HTTP/1.1 200 OK

Content-Type: text/xml; charset=utf-8

Content-Length: length

<?xml version=”1.0″ encoding=”utf-8″?>

<soap:Envelope xmlns:xsi=””xmlns:xsd=”” xmlns:soap=””>


<AddResponse xmlns=””>





Note: To view the WSDL document we can use the following URL

Client Application: (In New Instance of VS.NET)

Step 3: File –> New Project –> Windows Application
Step 4: In the Solution Explorer –> References –> Right Click –> Add Service Reference –> In URL give the Url of Web Service(can copy from browser where we can see the webservice methods) –> Click on Go.
Step 5: In the same dialog: Namespace = localhost (name of domain on which the webservice is hosted is used) –> Click on Add Reference
Note: When a WebService reference is added in VS.Net that is using add Web reference it automatically creates a proxy class in the current project using a utility program called asWSDL.EXE. The same can be viewed by opening the file Reference.cs. (Before this click on Show All Files in Solution Explorer).
Step 6:
using WebServiceClientAppName.localhost
private void btnDemo_Click(object sender, EventArgs e)
DemoServiceSoapClient ds = new DemoServiceSoapClient();
MessageBox.Show(ds.Add(20, 50).ToString());

Step 7: Run the Client Application
Note: If a new method is added to the webservice class, right click on web reference of the webservice and select Update ervice Reference to reflect the new method in the proxy class.

distributed computing framework in .net

Distributed Computing Architecture

  1. Proxy is a client side representative of the actual object on server. It implements the same set of interfaces as the actual object implements.
  2. When the client requests for an instance of a remote object, the underlying services (Framework) creates the actual object in the server process and the proxy object in the client process, the client gets the reference to the local proxy object.
  3. Along with the actual object a “stub” object is created on server. The proxy and stub are connected with each other over a socket and communicates with each other using a common protocol.
  4. Whenever the client calls the method of the proxy, the implementation in Proxy serializes all the parameters of the method and transports them to Stub i.e. proxy marshals the request to stub.
  5. On Server, Stub deserializes the request and passes the references of the objects as parameters to the actual method in actual object.
  6. Server method returns data to Stub, which serializes the data and return to proxy, proxy deserializes and return the data to the client object.

SUN (Stanford University Network – RMI (Remote Method Invocation) – JRMP(Java RMI Protocol) OMG (Object Management Group) – CORBA Common Object Request Broker Arch. -IIOP (Internet Interoperable Protocol MS (Microsoft) – DCOM (Distributed Component Object Model) – DEC – Object RPC(Distributed Computing Environment)

Problem: Because the proxy and the stub are tightly coupled to each other they must use the common protocol for communication. As the protocols used by RMI, COBRA and DCOM are native protocols they lack Interoperability.


A WebService is a business object running on a Web Server and providing its functionality to any type of application / client which supports “SOAP” (Simple Object Access Protocol) protocol.

SOAP = XML + HTTP. SOAP is a specification by W3C. – Its an architectural neutral protocol.

In .Net WebSevices are managed by ASP.NET Framework. They are mostly used for developing B-B (Business to Business) services/application. Any kind of application which we can develop in MS.NET can be a client to WebService.

WSDL (Web Service Description Language):

It is an XML based document containing complete information of the webservice including methods and their parameters, the URL etc…

For every webservice developed, the corresponding WSDL document is distributed to the clients. The clients using a native utility program generates a proxy class from a WSDL document. This proxy class then can be used by client application for invoking the functionality / methods of the webservice without worrying about the existence of SOAP protocol.

Steps for Developing WebService:

File–>New Web Site  ASP.NET Web Service and rename Service.asmx to DemoService.asmx

In DemoService.asmx:

  • A webservice class autogenerated by studio has the attribute [WebService] and is also inherited from System.Web.Services.WebService class. BOTH ARE OPTIONAL REQUIREMENTS. i.e. any public class linked through file with extension ASMX and deployed in the webapplication can treated as a WebService.
  • All the methods of a webservice class to be used by the clients on internet must be marked as “WebMethod” ( attribute)

Step 2 [WebMethod]
public int Add(int a, int b)
return a + b;

Step by step procedure Implementing about JavaScript Timer

Timer Demo:

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “”>

<html xmlns=””>


<title>Validation On Submit</title>

<script language=”JavaScript”>

function showClientTime() {

var dt = new Date()

spnTime.innerHTML = dt.toLocaleTimeString();

setTimeout(“showClientTime ()”, 1000);




<body onload=”showClientTime()”>

<span id=”spnTime”></span>



To show and close window:

<script type=”text/JavaScript”>

var win;

function ShowWindow() {

win =“JS1.htm”, “win1”, “menubar=no,scrollbars=no,width=400,height=500,location=no,resizable=yes”)


function CloseWindow() {





Code for displaying time

document.write(“<span id=’spnTime’></span>”)

function setClientTime() {

document.getElementById(“spnTime”).innerHTML = new Date().toTimeString();

setTimeout(“setClientTime()”, 1000)



In any HTML Page, add the following to show System time:

<script type=”text/JavaScript” src=”ShowTime.js”></script>