NodeJs等价实现简单的SOAP

时间:2016-07-31 21:39:35

标签: javascript node.js soap

下面的代码是我的PHP解决方案,使用SOAP并且工作正常,现在我想在NodeJs上实现,但是我不能在用/sendsms打开网址之后没有任何结果。这个肥皂用于发送短信,在得到空的结果后,我没有得到任何短信

public static function SendREST($username, $password, $Source, $Destination, $MsgBody, $Encoding)
{
    $URL = "http://URL/sendsms";
    $msg = urlencode(trim($MsgBody));
    $url = $URL . '?username=' . $username . '&password=' . $password . '&source=' . $Source . '&destination=' . $Destination . '&message=' . $msg;

    $headers[] = 'Accept: text/html';
    $headers[] = 'Connection: Keep-Alive';
    $headers[] = 'Content-type: application/x-www-form-urlencoded;charset=UTF-8';
    $process = curl_init($url);

    curl_setopt($process, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($process, CURLOPT_HEADER, 0);
    curl_setopt($process, CURLOPT_TIMEOUT, 30);
    curl_setopt($process, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($process, CURLOPT_FOLLOWLOCATION, 1);

    return curl_exec($process);

    try {
        $return = curl_exec($process);
        if ($return) {
            return true;
        }
    } catch (Exception $ex) {
        return false;
    }
}

我的NodeJs解决方案(数据是假的):

var soap           = require('soap');
var url = 'http://URL/sendsms';
var args = {username: '5280',password:'3310AZa',source:'08888735280',destination:'97823036569',message:'SHOOOOOOT !!'};

app.get('/sendsms', function (req, res) {
    soap.createClient(url, function (err, client) {
    });
});

0 个答案:

没有答案