Solved

Consume WCF Service from Classic ASP.

Posted on 2013-06-21
3
1,848 Views
Last Modified: 2013-06-25
I have a WCF Service and a Classic ASP web application.

I need to consume this WCF Service in Classic ASP. I got some links and information on the net when searched for this.  But, I couldn't get a concrete example of how a complex object, for example a Customer object, with multiple addresses as a array of address objects as one of the attributes of this customer object, I need to pass such an object as a parameter to the WCF method. Please let me know if any of you have any pointers or examples, or links to information.

Thanks
sprao
0
Comment
Question by:spraocs
  • 2
3 Comments
 
LVL 52

Accepted Solution

by:
Scott Fell,  EE MVE earned 500 total points
ID: 39266492
I have used classic asp to consume webservices although never a  WCF but it will be similar.  In short, you need to build the xml/soap envelope to a string.

<xml>
<node1>stuff</node1>
</xml>

Open in new window

becomes
strRequest="<xml>"
strRequest=strRequest&"<node1>stuff</node1>"
strRequest=strRequest&"</xml>"

Open in new window

Next you need to send
dim objXMLHTTP
set objXMLHTTP = Server.CreateObject("MSXML2.ServerXMLHTTP.3.0")
strURL = "https://www.somesite/endpoint"
objXMLHTTP.setTimeouts 10000, 60000 , 60000, 360000 
   objXMLHTTP.open "POST", "" & strURL & "" , False
   objXMLHTTP.setRequestHeader "Content-Type", "text/xml; charset=utf-8"
   objXMLHTTP.setRequestHeader "Content-Length", Len(strRequest)
   objXMLHTTP.send(strRequest)

   'strResult = objXMLHTTP.responseText
    ' Here you could response.write strResult to see the raw response
    Set objReturn = CreateObject("MSXML2.DOMDocument.3.0")
    objReturn.loadXML objXMLHTTP.responseText

Open in new window

Finally you need to loop through the response and deal with the data.  For an xml response, I would something like this for each node.
if not objReturn.getElementsByTagName("variable_1").Item(0) is Nothing  then
	variable_1=objReturn.getElementsByTagName("variable_1").Item(0).text
	else
	variable_1="0"
end if

Open in new window

0
 
LVL 1

Author Closing Comment

by:spraocs
ID: 39276191
Thanks for the response.

Though the answer helped me in some way, that was not the exact answer I was looking for. I got it in a different way. We had a test windows application that did the wcf calls. I used fiddler tool to view the soap message format for the call.. The syntax for the object parameter in the method call was available in that. Anyway, the response helped me to figure out the parsing of the response. Thanks.
0
 
LVL 52

Expert Comment

by:Scott Fell, EE MVE
ID: 39276267
I'm glad it helped.  Your question was vague though so I could only give you a demo sample.  

>I used fiddler tool to view the soap message format for the call.. The syntax for the object parameter in the method call was available in that

Had you provided this information, I could have given you a more realistic answer. The key to getting a great answer is a great question.  Sometimes making the question is harder then answering the question.  This sounds like the case where you figured out the details using fiddler which helped answer.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
The purpose of this video is to demonstrate how to set up the WordPress backend so that each page automatically generates a Mailchimp signup form in the sidebar. This will be demonstrated using a Windows 8 PC. Tools Used are Photoshop, Awesome…
This video discusses moving either the default database or any database to a new volume.

758 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now