Solved

Consume WCF Service from Classic ASP.

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
CSS Question.. 3 77
Classic ASP - x-editable save to SQL 3 80
Classic ASP, Search Recordset on pick list change 1 52
SP to delete duplicates 15 61
When coding a Webservice to provide data, the normal way is to create a method that returns a Dataset object.   But a Dataset cannot be used easily from another platform, such as PHP,  FLAS (FLEX) , etc. Solution : Return a XML Document instea…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
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 Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.

911 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

22 Experts available now in Live!

Get 1:1 Help Now