Solved

calling a .net web service from classic ASP page

Posted on 2003-11-05
11
700 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
  • 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
 
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

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 500 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
This video teaches users how to migrate an existing Wordpress website to a new domain.
The viewer will learn how to count occurrences of each item in an array.

762 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

21 Experts available now in Live!

Get 1:1 Help Now