Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

calling a .net web service from classic ASP page

Posted on 2003-11-05
11
Medium Priority
?
709 Views
Last Modified: 2008-03-10
How can i can call a .net web service from an ASP page? are there any sites/sources that i can check this out on?

I need to see how this is done via ASP(preferably in vbscript), not ASP.net. I can only find samples on th einternet using ASP.net. I am much more familiar with using using web services in vb.net, but not aware of how to do this using classic ASP.

Any help appreciated thanks

0
Comment
Question by:mikeandbee
[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
  • 3
  • 2
  • 2
  • +3
11 Comments
 
LVL 4

Expert Comment

by:1mak
ID: 9685427
Here's an article that takes you through the process...

Basically, you open the webservice, passing your parameters as a querystring, and parse the resultant XML all using the Microsoft XMLHTTP class.
0
 

Author Comment

by:mikeandbee
ID: 9685560
i think you forgot to paste the actual article in your comment, not? Could you please re-post.

thanks
0
 

Author Comment

by:mikeandbee
ID: 9686137
i need to see that article, i presume it shows the code behind how to do this in vbscript?
0
Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

 
LVL 4

Expert Comment

by:1mak
ID: 9686681
Really sorry mikeandbee, rookie mistake...

http://www.aspfree.com/articles/576,1/articles.aspx
0
 
LVL 17

Expert Comment

by:Squeebee
ID: 9690867
I don't use ASP, but PocketSOAP works extremely well for me in plain old VB-land.

http://www.pocketsoap.com/pocketsoap/
0
 

Author Comment

by:mikeandbee
ID: 9693205
i really need an example where I can send an XML request to the web service. The example given just sends a request like so:
SoapRequest.Open "GET",SoapURL , False
SoapRequest.Send()
But I actually want to send an XML string inside this request. Can you show me an example fo this? And how would i handle the response?
thanks
0
 
LVL 1

Accepted Solution

by:
rychs earned 2000 total points
ID: 9695042
Hello
  Here is an example using Google's beta search service. This code is for client-side but it could easily be switched to server-side using JScript.

<script language="JavaScript">
function searchFor(arg)
{      
      objHTTP = new ActiveXObject("Microsoft.XMLHTTP");
      try
      {
            objHTTP.open("post", "http://api.google.com/search/beta2", false);
      }
      catch(error)
      {
            if(error.description == "Permission denied" || error.description == "Access is denied")
            {
                  var msg = "Your current security settings prevent access to this web service.<br>"
                  msg = msg + "To enable this service:<br>1. Go to the Tools menu and select Internet Options<br>"
                  msg = msg + "2. Click the security tab at the top of the page<br> 3. Click the Custom Level button<br>"
                  msg = msg + "3. Find the topic 'Access Data Sources Across Domains' and set it to prompt<br>"
                  msg = msg + "4. Click OK and then OK again and you will be able to access the web service<br><br>"
                  msg = msg + "OR <a style='cursor:hand;text-decoration:underline;' onclick='window.open(\"GoogleWebService.asp?arg=" + arg + "\", \"\", \"width=300,height=300,toolbar=no,scrollbars=yes\")'>"
                  msg = msg + "Click here</a> to view the results in a new window<br><br>"
                  msg = msg + "<a style='cursor:hand' onclick=google.style.display='none';return false;>Close Window</a>"
                  
                  google.innerHTML = msg;
                  google.style.top =  document.body.scrollTop + 10
                  google.style.display = "block";
                  
            }
            return false;
      }
      objHTTP.setRequestHeader("Content-Type", "text/xml");
      
      strEnvelope = "<?xml version='1.0' encoding='UTF-8'?>";
      strEnvelope = strEnvelope + "<SOAP-ENV:Envelope xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/' ";
      strEnvelope = strEnvelope + "xmlns:xsi='http://www.w3.org/1999/XMLSchema-instance' ";
      strEnvelope = strEnvelope + "xmlns:xsd='http://www.w3.org/1999/XMLSchema'>";
      strEnvelope = strEnvelope + "<SOAP-ENV:Body>";
      strEnvelope = strEnvelope + "<ns1:doGoogleSearch xmlns:ns1='urn:GoogleSearch' ";
      strEnvelope = strEnvelope + "SOAP-ENV:encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'>";
      strEnvelope = strEnvelope + "<key xsi:type='xsd:string'></key>";
      strEnvelope = strEnvelope + "<q xsi:type='xsd:string'>" + arg + "</q>";
      strEnvelope = strEnvelope + "<start xsi:type='xsd:int'>0</start>";
      strEnvelope = strEnvelope + "<maxResults xsi:type='xsd:int'>10</maxResults>";
      strEnvelope = strEnvelope + "<filter xsi:type='xsd:boolean'>true</filter>";
      strEnvelope = strEnvelope + "<restrict xsi:type='xsd:string'></restrict>";
      strEnvelope = strEnvelope + "<safeSearch xsi:type='xsd:boolean'>false</safeSearch>";
      strEnvelope = strEnvelope + "<lr xsi:type='xsd:string'></lr>";
      strEnvelope = strEnvelope + "<ie xsi:type='xsd:string'>latin1</ie>";
      strEnvelope = strEnvelope + "<oe xsi:type='xsd:string'>latin1</oe>";
      strEnvelope = strEnvelope + "</ns1:doGoogleSearch>";
      strEnvelope = strEnvelope + "</SOAP-ENV:Body>";
      strEnvelope = strEnvelope + "</SOAP-ENV:Envelope>";
      
      //********** Google **********************
      objHTTP.send(strEnvelope);
      xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
      var temp = unescape(objHTTP.responseText)
      xmlDoc.loadXML(temp);
      titleNodes = xmlDoc.getElementsByTagName("title");
      urlNodes = xmlDoc.getElementsByTagName("URL");

      var holder = "<span style='cursor:hand;position:absolute;left:100;' onClick=google.style.display='none';>Close Window</span><br>"
      for(i=0;i < urlNodes.length;i++)
      {
            holder = holder + (i + 1) + ".<a href='" + urlNodes.item(i).text + "' target='_blank'>&nbsp;"
            holder = holder + titleNodes.item(i).text + "</a><br>"
      }
      google.innerHTML = holder;
      google.style.top =  document.body.scrollTop + 10
      google.style.display = "block";
}
</script>

It won't work because I removed the key value that google gave me. If you want to test it, request a key from google's site.

Hope this helps
0
 
LVL 1

Expert Comment

by:stephenmmitchell
ID: 10786418
Below is a link to a text file called SoapTools.asp.

You can include that script into your asp file and use the example code at the bottom to send an XML request and how to pull the information coming back.

The Example Code is the big commented section at the bottom of the SoapTools.asp.

You can ignore all the code above that, it will not need to change only included in your asp file.

http://www.vermeeralabama.com/SoapTools.asp

I hope this helps.
0
 
LVL 1

Expert Comment

by:stephenmmitchell
ID: 10786423
Sorry about that link, it was incorrect.  Try this one

http://www.vermeeralabama.com/SoapTools.txt

-Stephen
0
 
LVL 21

Expert Comment

by:pinaldave
ID: 11394724
No comment has been added to this question in more than 21 days, so it is now classified as abandoned..
I will leave the following recommendation for this question in the Cleanup topic area:

"Accept rychs  comment as answer."

Any objections should be posted here in the next 4 days. After that time, the question will be closed.

Pinal Dave
EE Cleanup Volunteer
0

Featured Post

Survive A High-Traffic Event with Percona

Your application or website rely on your database to deliver information about products and services to your customers. You can’t afford to have your database lose performance, lose availability or become unresponsive – even for just a few minutes.

Question has a verified solution.

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

Color can increase conversions, create feelings of warmth or even incite people to get behind a cause. If you want your website to really impact site visitors, then it is vital to consider the impact color has on them.
This is a fine trick which I've found useful many times, when you just don't want to accidentally run a batch script or the commands needs administrator rights.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).
Suggested Courses

688 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