Consuming WCF service from Classic ASP

Need a working code snippet to call  WCF service from classic ASP 3.0, Thanks
LVL 1
humer2000Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

blandyukCommented:
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.
0
humer2000Author Commented:
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
0
blandyukCommented:
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

0
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

AshokSr. Software EngineerCommented:
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
0
AshokSr. Software EngineerCommented:
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
0
AshokSr. Software EngineerCommented:
using System.Runtime.Serilization;
using System.Service.Model;

[DataContract]
public class Customer
{
   [DataMember]
   public string FirstName;

   [DataMember]
   public string Lastname;

}

[ServiceContract] IHelloCustomer
public interface IWithContract
{
  [OperationContract]
  string HelloFirstName(Customer cust);

  [OperationContract]
  string HelloFullName(Customer cust);  
}

Implementing interface
==============
public class HelloCustomer: IHelloCustomer
{
  public string HelloFirstName(Customer cust)
  {
      return "Hello " + cust.Firstname;
   }
  public string HelloFullName(Customer cust)
  {
      return "Hello " + cust.Firstname + " " + cust.Lastname;
   }
}

HTH
Ashok
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
humer2000Author Commented:
Not so clear response I found another solution
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Languages and Standards

From novice to tech pro — start learning today.