简体   繁体   English

javascript http获取Web服务请求

[英]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. 我正在实施一个新的ftp产品,该产品具有通过网络服务调用运行临时ftp作业的能力。 The web service only has two parameters that can be passed to it, rule name and rule params. Web服务只有两个可以传递给它的参数:规则名称和规则参数。 The web service returns 0 or 1 dependent upon success or failure in this format: Web服务以以下格式返回0或1,取决于成功或失败:

http://ftpwebservicesite.com>1 http://ftpwebservicesite.com> 1

The web service requires authentication which I can't provide when calling from our mainframe. Web服务需要身份验证,从主机调用时我无法提供身份验证。

I have the ability to call the web service via an http get request. 我可以通过http get请求调用Web服务。 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. 我遇到的问题是,使用此方法时,我使用的工具不会将Web服务返回的失败视为失败,而是看到了http 200代码并将其标记为成功。

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? 有什么方法可以建立一个中间人网页,该人通过http get调用Web服务,解析响应,然后返回200的1的http代码和0的400 http代码?

Its not possible by request to access any web server out of your current context. 无法通过请求访问当前上下文之外的任何Web服务器来实现。 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和curl轻松完成此操作),并从中间页请求数据

PHP mode: PHP模式:

<?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! 像这样的东西,我没有测试,但应该可以!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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