php - 调用fedex服务时出现Nodejs Soap模块问题

标签 php node.js soap fedex

我正在使用 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, function (err, result) {
        if (err)throw err;
        res.send(result);
    });
});

但是当我用低于 1 的 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 中工作,但在 Nodejs 中不工作。请告诉我问题出在哪里?

最佳答案

您可以尝试使用 node-shipping-fedex 模块而不是直接使用soap。 https://github.com/typefoo/node-shipping-fedex

关于php - 调用fedex服务时出现Nodejs Soap模块问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23086487/

相关文章:

java - Axis 代理连接超时: connect

java - 从 soap header 中删除 mustUnderstand 属性

c# - RegEx 字表现 :\w vs [a-zA-Z0-9_]

javascript - AJAX 调用在 header /表单数据中返回未定义

PHP MySQL 查询返回错误字符

node.js - Websocket - 等待 http 请求回调在下一个推送事件之前执行

javascript - 如何完善地址栏 php、.htaccess 或 javascript 中的 url

node.js - 如何在 webpack 中热重载 sass?

node.js - Mongoose 错误 : Arguments must be aggregate pipeline operators

php - 如何在 REDHAT 5 上安装 PHP SOAP