Solved

Consume WCF Service from Classic ASP.

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Save ms data to server side. 19 59
VBScript on Html 15 55
ASP exit 10 26
Dll Created For Access App cannot locate web services configuration info in App.config file 19 19
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 …
These instructions are based on installing Owncloud on your new raspberry pi connected with a usb HDD. What do you need Part A? A Raspberry Pi, model B. A boot SD card for the Raspberry Pi. A usb HDD An Ethernet cable to connect to the lo…
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…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

685 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