[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

Consuming WCF service from Classic ASP

Posted on 2010-04-08
7
Medium Priority
?
1,309 Views
Last Modified: 2013-11-19
Need a working code snippet to call  WCF service from classic ASP 3.0, Thanks
0
Comment
Question by:humer2000
  • 3
  • 2
  • 2
7 Comments
 
LVL 9

Expert Comment

by:blandyuk
ID: 30151333
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
 
LVL 1

Author Comment

by:humer2000
ID: 30184201
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
 
LVL 9

Expert Comment

by:blandyuk
ID: 30204123
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
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
LVL 13

Expert Comment

by:Ashok
ID: 30332920
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
 
LVL 13

Expert Comment

by:Ashok
ID: 30332963
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
 
LVL 13

Accepted Solution

by:
Ashok earned 1000 total points
ID: 30333387
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
 
LVL 1

Author Closing Comment

by:humer2000
ID: 32335652
Not so clear response I found another solution
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
Suggested Courses

640 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question