php – 调用fedex服务时Nodejs Soap模块的问题

前端之家收集整理的这篇文章主要介绍了php – 调用fedex服务时Nodejs Soap模块的问题前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在使用nodejs soap模块来调用fedex服务,但是得到一个错误
{
   "HighestSeverity": "ERROR","Notifications": [
         {
         "Severity": "ERROR","Source": "prof","Code": "1000","Message": "Authentication Failed"
         }
    ],"Version": {
    "ServiceId": {},"Major": {},"Intermediate": {},"Minor": {}
  }
}

下面是我的nodejs代码

var data = {};

data["WebAuthenticationDetail"] = {
    "UserCredential": {
        "Key": developer_key,//getProperty('key');
        "Password": password
    }
};

//console.log(JSON.stringify(data));

data['ClientDetail'] = {
    'AccountNumber': account_number,//getProperty('shipaccount');
    'MeterNumber': meter_number//getProperty('meter');
};

data['Version'] = {
    'ServiceId': 'crs','Major': 14,'Intermediate': 0,'Minor': 0

};

var soap = require('soap');
var path = require('path');
var path_to_wsdl = path.resolve(__dirname + '/wsdl/RateService_v14.wsdl');

soap.createClient(path_to_wsdl,function (err,client) {
    if (err)throw err;
    client.getRates(data,result) {
        if (err)throw err;
        res.send(result);
    });
});

但是当我发送这个数据在PHP下面一个,那么它的工作.

$path_to_wsdl = "wsdl-testing/RateService_v14.wsdl";

ini_set("soap.wsdl_cache_enabled","0");

$client = new SoapClient($path_to_wsdl /*,array('trace' => 1) */);

$request['WebAuthenticationDetail'] = array(
      'UserCredential' => array(
                   'Key' => $developer_key,'Password' => $password
  ) );

 $request['ClientDetail'] = array(
                       'AccountNumber' => $account_number,'MeterNumber' => $meter_number,);

$request['Version'] = array(
                          'ServiceId' => 'crs','Major' => '14','Intermediate' => '0','Minor' => '0');
$response = $client -> getRates($request);

Logger::info('here is the response====',$response);

相同的代码PHP中工作,但不在Nodej中.请让我知道问题在哪里?

我的猜测是,您正在使用PHP中的测试网址,但在node.js.中的实时网址.在您的PHP代码中,您可以使用wsdl-test /,并在您的node.js代码中使用wsdl /.如果您确实在PHP中使用测试的WSDL文件,那么我认为您最终会在https://wsbeta.fedex.com:443/web-services/rate中解析,而在node.js中您正在解析为https ://ws.fedex.com:443 / web-services / rate你可能还没有现场访问.
原文链接:https://www.f2er.com/php/140219.html

猜你在找的PHP相关文章