Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calling a web service using ASP

Status
Not open for further replies.

TomBarrand

Programmer
Aug 9, 2000
162
GB
Hi,

I need to call a web service from an ASP page. I don't mean ASP.net, just ASP. It seems possible using the SOAP toolkit, but I can't get it working at the momment.

Anyone know of any good articles on the web?

Cheers
 
i've been looking at this, and came to the conclusion that it is far easier using .net!! ( using visual studio .net - does alot of it for you!! :) )

I found some scripts using classic asp, but they used the asp.net engine... (wierd and didn't seem to work too well (can't seem to find the url tho), all of then use XMLHTTP, but can be abit cumbersome as you have to have all you soap messages as variables, load them up and send them..

but a quick google brings up a number of starters.

the buzz word is 'consuming' web services.



 
the global.asa
Code:
<SCRIPT LANGUAGE=VBScript RUNAT=Server>

Sub Application_OnStart
    Dim ASPNETResources

    ASPNETResources = GetASPNetResources()   
    Application("ASPNETExpires") = 12    'set the content to expire in 12 hours.
    If Len(ASPNETResources) >0 then    'populate the application level variables
        Application.Lock
       
        Application("ASPNETResourcesUpdated")=Now()
        Application("ASPNETResourceList")=ASPNETResources
        Application.UnLock
    End if

End Sub
</script>
<!-- #include file="i_soapcall.asp" -->

i_soap.asp
Code:
<script language="vbscript" runat="server">
Function GetASPNetResources()   
    Dim returnString
    Dim myXML
    Dim SoapRequest
    Dim SoapURL

    Set SoapRequest = Server.CreateObject("MSXML2.XMLHTTP")
    Set myXML =Server.CreateObject("MSXML.DOMDocument")

    myXML.Async=False
    SoapURL = "[URL unfurl="true"]http://64.85.12.73/WebSvc/whatsnew123apx_ds.asmx/GetNew123aspXResources?"[/URL]
    SoapRequest.Open "GET",SoapURL , False
    SoapRequest.Send()

    if Not myXML.load(SoapRequest.responseXML) then 'an Error loading XML
        returnString = ""
    Else    'parse the XML

        Dim nodesURL
        Dim nodesName
        Dim nodesDateUpdated
        Dim nodesDomain
        Dim NumOfNodes
        Dim ResourceList
        Dim i

        REM -- The XML Nodes are CASE SENSITIVVE!
        Set nodesURL=myXML.documentElement.selectNodes("//URL")
        Set nodesName=myXML.documentElement.selectNodes("//Name")

        REM -- uncomment the following lines if we want to access the DataUpdated and the Domain Nodes
        REM --Set nodesDateUpdated = myXML.documentElement.selectNodes("//DateUpdated")
        REM --Set nodesDomain = myXML.documentElement.selectNodes("//Domain")

        REM -- the number of nodes in the list
        NumOfNodes = nodesURL.Length
        ResourceList = "<font face=verdana size=2>Latest ASP.NET Resources</font><ul>"

        For i = 0 to NumOfNodes -1
            ResourceList = ResourceList & "<li><a href=" & nodesURL(i).text & "><font face=verdana size=2>" & nodesName(i).text & "</font></a></li>"
        next

        ResourceList =ResourceList & "</ul>"
       
        returnString = ResourceList
   
        Set nodesURL = Nothing
        Set nodesName = Nothing
    End If
   
    Set SoapRequest = Nothing
    Set myXML = Nothing
   
   
    GetASPNetResources = returnString
End Function
</script>

and finally soap.asp
Code:
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
</HEAD>
<BODY>
<%
Dim     ASPNETResources   
If len( Application("ASPNETResourceList") )>0 then    'we have our latest resources

    REM -- check to see if they expired
    If DateDiff("h",Now(),Application("ASPNETResourcesUpdated")) > Application("ASPNETExpires") Then   
        REM -- we need to update the latest resurces
        ASPNETResources = GetASPNetResources()
        Application.Lock
        Application("ASPNETResourcesUpdated")=Now()
        Application("ASPNETResourceList")=ASPNETResources
        Application.UnLock
    End if 'datediff...

Else    'for some reason the application level variable is empty, fill it.
    ASPNETResources = GetASPNetResources()
    Application.Lock
    Application("ASPNETResourcesUpdated")=Now()
    Application("ASPNETResourceList")=ASPNETResources
    Application.UnLock

End if 'len(..

Response.Write     Application("ASPNETResourceList")

%>
<P>&nbsp;</P>

</BODY>
</HTML>

to be honest it didn't really help me alot, but gives you an idea of what needs to done in classic asp.

hope it helps
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top