Link to home
Start Free TrialLog in
Avatar of humer2000
humer2000

asked on

Consuming WCF service from Classic ASP

Need a working code snippet to call  WCF service from classic ASP 3.0, Thanks
Avatar of blandyuk
blandyuk
Flag of United Kingdom of Great Britain and Northern Ireland image

I've found this article which should be what your looking for:

http://code.msdn.microsoft.com/CallWCFfromASP

Uses the "MSXML2.ServerXMLHTTP" object to request the data.
Avatar of humer2000
humer2000

ASKER

I downloaded the sample, there is no asp code inside !!! It's a C# Winform stuff.
I need an asp sample of callinng service contract from asp code
thanks for reply
See if the below helps you, its how to use the object as specified above. You can change it to adTypeText to get plain text from the object:
Function DownloadDatafeed(ByVal sURL)
	Dim objXMLHTTP
	Dim objStream
	Const adTypeBinary = 1
	Const adTypeText = 2
	
	DownloadDatafeed = ""
	
	Set objXMLHTTP = Server.CreateObject("MSXML2.ServerXMLHTTP")
	Set objStream = Server.CreateObject("ADODB.Stream")
	
	objXMLHTTP.Open "GET", sURL, False
	objXMLHTTP.SetRequestHeader "Content-type", "text/html"
	'On Error Resume Next
	objXMLHTTP.Send
	If Err.Number <> 0 Then
		DownloadDatafeed = "Error: " & Err.Description
	Else
		'sDatafeed = objXMLHTTP.ResponseBody
		sFilename = "Datafeed_" & Replace(Date, "/", "-") & ".txt"
		objStream.Open
		objStream.Type = adTypeBinary
		objStream.Write objXMLHTTP.ResponseBody
		objStream.SaveToFile Server.MapPath(sFilename)
		objStream.Close
	End If
	
	Set objStream = Nothing
	Set objXMLHTTP = Nothing
	On Error Goto 0
End Function

Open in new window

Do you need code in C# or VB.NET?

C#
=====
ServiceReference.HelloCustomerClient ws = new ServiceReference.HelloCustomerClient();
ServiceReference.Customer cust = new ServiceReference.Customer();
cust.Firstname = "Bill";
cust.Lastname = "Smith";

Response.Write(ws.HelloFullName(cust);
ws.Close();

HTH
Ashok
Do you need code in C# or VB.NET?

C#
=====
ServiceReference.HelloCustomerClient ws = new ServiceReference.HelloCustomerClient();
ServiceReference.Customer cust = new ServiceReference.Customer();
cust.Firstname = "Bill";
cust.Lastname = "Smith";

Response.Write(ws.HelloFullName(cust));
ws.Close();

HTH
Ashok
ASKER CERTIFIED SOLUTION
Avatar of Ashok
Ashok
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Not so clear response I found another solution