Calling a webservice from an asp page

Say we have created a simple web service like this

public string Hello(String name) {
return “Hello “+name ;

Now we want to call the web service from inside our asp page,

for this we can make use of the following code

Dim myPostData
Dim name
name=”Mickey Mouse”
myPostData=”name=” & name
Dim xmlhttp
Dim postUrl
postUrl = “http://servername/MyService/Service.asmx/Hello&#8221;
Set xmlhttp = server.Createobject(“MSXML2.XMLHTTP”)
xmlhttp.Open “POST”,postUrl,false
xmlhttp.setRequestHeader “Content-Type”,”application/x-www-form-urlencoded”
xmlhttp.send strWebServideDetails
Response.Write(“<b>This is the message i recieved</b>” +xmlhttp.responseText)



%d bloggers like this: