【问题标题】:Call Soap Service from Firebase Cloud function Error从 Firebase Cloud 函数调用 Soap 服务错误
【发布时间】:2019-03-22 15:45:38
【问题描述】:

我想从我的 firebase 云函数中调用一个肥皂服务 url

  1. 我已经启用了计费,并且可以从我的云函数中调用其他 api。

  2. 我可以在邮递员上调用这个soap函数,它可以工作。

但是,从我的云函数调用它会给我以下错误。

XMLHttpRequest 错误:

"Message": "Error: connect ECONNREFUSED 127.0.0.1:80\n    at Object.exports._errnoException (util.js:1020:11)\n    at exports._exceptionWithHostPort (util.js:1043:20)\n    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1105:14)"

代码

  var XMLHttpRequest = require("xmlhttprequest").XMLHttpRequest;
        var xmlhttp = new XMLHttpRequest();

        //replace second argument with the path to your Secret Server webservices
        xmlhttp.open('POST', 'xxxxx/SiloFunctions.asmx');

        //create the SOAP request
        var sr =
            '<soapenv:Envelope ' +
            'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"' +
            'xmlns:xsd="http://www.w3.org/2001/XMLSchema"' +
            'xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">' +
            '<soap:Body>' +
            '<Request xmlns="http://tempuri.org/">' +
            '<Password>xxxx</Password>' +
            '<Latitude>123</Latitude>' +
            '<Longitude>123</Longitude>' +
            '<ClientName>123</ClientName>' +
            '<ClientSurname>123</ClientSurname>' +
            '<MSISDN>123123</MSISDN>' +
            '</Request>' +
            '</soap:Body>' +
            '</soapenv:Envelope>';


        //specify request headers
        xmlhttp.setRequestHeader('Content-Type', 'text/xml; charset=utf-8');

        //FOR TESTING: display results in an alert box once the response is received
        xmlhttp.onreadystatechange = function () {
            if (xmlhttp.readyState == 4) {
                res.status(200).send(
                    {
                        "Message": xmlhttp.responseText,
                    })
            }
        };

        //send the SOAP request
        xmlhttp.send(sr);

为什么yyyyy?

【问题讨论】:

  • 您采用哪种付款计划?免费的“Spark”计划允许仅向 Google 拥有的服务发出出站网络请求。您需要参加“火焰”或“火焰”计划。见firebase.google.com/pricing
  • 是的,我在 Blaze
  • xxxxx 在这里很重要。你能告诉我你在里面放了什么吗?
  • @DougStevenson 那将是 someUrl.com/API/SiloFunctions.asmx
  • 格式是这样的吗?

标签: firebase soap google-cloud-functions


【解决方案1】:

您应该使用完整的 URL,而不是部分 URL。它可能以https:// 开头。由于您没有使用它,因此您使用的 HTTP 库假定为 localhost (127.0.0.1),这显然无法正常工作。

【讨论】:

  • 就是这样。谢谢! (作为奖励,他们在 http:// 而不是 https:// 上运行它,所以这也被阻止了。
猜你喜欢
  • 2020-07-24
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-02-09
相关资源
最近更新 更多