0

我正在尝试使用node-soap向 FedEx API 发出简单的费率请求。我已经阅读了文档和 WSDL 以包含所有必需的信息,但我得到的只是一个空对象作为响应。

由于我没有收到任何错误,我不确定我做错了什么,或者我是否错过了一些步骤。

这是我的代码:

var express = require('express');
var app = express();
var port = process.env.PORT || 7000;
var path = require('path');
var soap = require('soap');

var url = path.join(__dirname, 'wsdl', 'RateService_v20.wsdl');

var params = {
      WebAuthenticationDetail: {
        UserCredential: {
          Key: 'the key I was given by FedEx',
          Password: 'the password I was given'
        }
      },
      ClientDetail: {
        AccountNumber: 'the acc number I was given',
        MeterNumber: 'the meter number I was given',
        Localization: {
            LanguageCode: 'EN'
        }
      },
      Version: {
        ServiceId: 'crs',
        Major: '20', 
        Intermediate: '0',
        Minor: '0'
      },
      RateRequest: {  
        ReturnTransitAndCommit: true,
        RequestedShipment: {
            DropoffType: 'REGULAR_PICKUP',
            PackagingType: 'FEDEX_10KG_BOX',
            RateRequestTypes: 'LIST',
            PackageCount: '1',
            Shipper: {
                Contact: {
                    PersonName: 'Sender Name',
                    CompanyName: 'Company Name',
                    PhoneNumber: '5555555555'
                },
                Address: {
                    StreetLines: [
                    'Address Line 1'
                    ],
                    City: 'Collierville',
                    StateOrProvinceCode: 'TN',
                    PostalCode: '38017',
                    CountryCode: 'US'
                }
            },
            Recipient: {
                Contact: {
                    PersonName: 'Recipient Name',
                    CompanyName: 'Company Receipt Name',
                    PhoneNumber: '5555555555'
                },
                Address: {
                    StreetLines: [
                    'Address Line 1'
                    ],
                    City: 'Charlotte',
                    StateOrProvinceCode: 'NC',
                    PostalCode: '28202',
                    CountryCode: 'US'
                }
            }
        }
    }
};

app.get('/describe',function(req,res){
    soap.createClient(url, function(err, client) {
        if (err) throw err; 
        res.send(client.describe());
    });
});

app.get('/test',function(req,res){
    soap.createClient(url, function(err, client) {
        if (err) throw err; 
        client.RateService.RateServicePort.getRates(params, function(err, result) {
          res.send(result);
      });
    });
})

app.listen(port, function(){
    console.log('app listening on port '+ port);
})
4

1 回答 1

1

客户详细信息帐号应该是联邦快递公司访问其 API 时提供的凭据

于 2017-06-30T07:16:47.257 回答