Solved

Consume WCF Service from Classic ASP.

Posted on 2013-06-21
3
1,974 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 53

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 53

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

Don't Cry: How Liquid Web is Ensuring Security

WannaCry is just the start. Read how Liquid Web is protecting itself and its customers against new threats.

Question has a verified solution.

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

I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
New Relic recently released its Synthetics product that allows for the creation of performance monitors that periodically test a site's performance. If you wish to test an interactive workflow New Relic employs Selenium WebDriverJS to run those test…
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…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

691 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