Solved

Consume WCF Service from Classic ASP.

Posted on 2013-06-21
3
1,876 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
Online collaboration is quickly becoming embedded in the workplace, and its benefits are tangible. See what the current landscape looks like and what the future holds for collaboration tools and the future of work.
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 is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

816 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

10 Experts available now in Live!

Get 1:1 Help Now