简体   繁体   中英

javascript http get request for web service

I'm implementing a new ftp product at work that has the ability to run adhoc ftp jobs via a web service call. The web service only has two parameters that can be passed to it, rule name and rule params. The web service returns 0 or 1 dependent upon success or failure in this format:

http://ftpwebservicesite.com>1

The web service requires authentication which I can't provide when calling from our mainframe.

I have the ability to call the web service via an http get request. The problem that I'm running into is that when using this method, the tool I'm using doesn't see the failure returned by the web service as a failure rather it see the http 200 code and marks it as a success.

Is there any way to set up a middle man web page that calls the web service via http get, parses the response and then returns an http code of 200 for 1 and a 400 http code for 0?

Its not possible by request to access any web server out of your current context. You can make an middle page, with another language server sided. (you can do it easly with php and curl) and request the data from middle page

PHP mode:

<?php
    $ch = curl_init('http://www.yahoo.com/');

    curl_exec($ch);

    if(!curl_errno($ch))
    {
        $info = curl_getinfo($ch);

        echo ( $info['total_time'] == 200 ? 1 : 0 );
    }

    curl_close($ch);
?>

Anything like this, i didn`t tested, but should work!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM