Calling REST web services from a classic asp page

前端 未结 7 1746
既然无缘
既然无缘 2020-12-01 01:16

I\'d like to start moving our application business layers into a collection of REST web services. However, most of our Intranet has been built using Classic ASP and most of

相关标签:
7条回答
  • 2020-12-01 01:31

    Here are a few articles describing how to call a web service from a class ASP page:

    • Integrating ASP.NET XML Web Services with 'Classic' ASP Applications
    • Consuming XML Web Services in Classic ASP
    • Consuming a WSDL Webservice from ASP
    0 讨论(0)
  • 2020-12-01 01:33

    Another possibility is to use the WinHttp COM object Using the WinHttpRequest COM Object.

    WinHttp was designed to be used from server code.

    0 讨论(0)
  • 2020-12-01 01:37

    You could use a combination of JQuery with JSON calls to consume REST services from the client

    or

    if you need to interact with the REST services from the ASP layer you can use

    MSXML2.ServerXMLHTTP

    like:

    Set HttpReq = Server.CreateObject("MSXML2.ServerXMLHTTP")
    HttpReq.open "GET", "Rest_URI", False
    HttpReq.send
    
    0 讨论(0)
  • 2020-12-01 01:37

    All you need is an HTTP client. In .Net, WebRequest works well. For classic ASP, you will need a specific component like this one.

    0 讨论(0)
  • 2020-12-01 01:49

    @KP

    You should actually use MSXML2.ServerXMLHTTP from ASP/server side applications. XMLHTTP should only be used client side because it uses WinInet which is not supported for use in server/service apps.

    See http://support.microsoft.com/kb/290761, questions 3, 4 & 5 and

    http://support.microsoft.com/kb/238425/.

    This is quite important, otherwise you'll experience your web app hanging and all sorts of strange nonsense going on.

    0 讨论(0)
  • 2020-12-01 01:50

    A number of the answers presented here appear to cover how ClassicASP can be used to consume web-services & REST calls.

    In my opinion a tidier solution may be for your ClassicASP to just serve data in REST formats. Let your browser-based client code handle the 'mashup' if possible. You should be able to do this without incorporating any other ASP components.

    So, here's how I would mockup shiny new REST support in ClassicASP:

    1. provide a single ASP web page that acts as a landing pad
    2. The landing pad will handle two parameters: verb and URL, plus a set of form contents
    3. Use some kind of switch block inspect the URL and direct the verb (and form contents) to a relevant handler
    4. The handler will then process the verb (PUT/POST/GET/DELETE) together with the form contents, returning a success/failure code plus data as appropriate.
    5. Your landing pad will inspect the success/failure code and return the respective HTTP status plus any returned data

    You would benefit from a support class that decodes/encodes the form data from/to JSON, since that will ease your client-side implementation (and potentially streamline the volume of data passed). See the conversation here at Any good libraries for parsing JSON in Classic ASP?

    Lastly, at the client-side, provide a method that takes a Verb, Url and data payload. In the short-term the method will collate the parameters and forward them to your landing pad. In the longer term (once you switch away from Classic ASP) your method can send the data to the 'real' url.

    Good luck...

    0 讨论(0)
提交回复
热议问题