Apigee 中未定义 NodeJS 异步 http 请求 ArrayBuffer
NodeJS async http request ArrayBuffer not defined in Apigee
这是我在 nodeJS 中的代码。当我将它部署到我的本地时,它总是 运行 没问题,但是当我将它部署到生产环境时,我总是遇到错误 "ArrayBuffer not defined"。有人能告诉我这是什么原因造成的吗?我会尝试添加 ArrayBuffer 但我得到了同样的错误。谢谢
var svr = http.createServer(function(req, resp) {
var response = [];
var calls = [];
var windowLiveId;
var huaweiReturnCode;
var serviceId = apigeeAccess.getVariable(req,'subscription.serviceid');
var ericssonRequestBody = {"offerId":serviceId,"generateBillingRecord":true };
calls.push(function(callback) {
http.get('http://butcha-test.apigee.net/v1/accounts/', function (resource) {
resource.setEncoding('binary');
resource.on('data', function (data) {
windowLiveId = JSON.parse(data).AccountId;
request.post({
url:'http://butcha-test.apigee.net/v1/erickson/'+windowLiveId,
method: 'POST',
headers:{
'Content-Type': 'application/json'
},
body: JSON.stringify(ericssonRequestBody)
}, function(error,res,body){
apigeeAccess.setVariable(req,"ericsonStatus",(/2[0-9][0-9]/.test(res.statusCode)) ? "success":"fail");
apigeeAccess.setVariable(req,"ericsonStatusCode",res.statusCode);
callback();
});
});
});
});
calls.push(function(callback){
request.post({
url:'http://morning-sea-3467.getsandbox.com/mockOverseaBossServiceSoapBinding',
method: 'POST',
headers: {'content-type' : 'application/xml'},
body: huaweiSoapRequest
}, function(error,res,body){
response.push(body);
var tag = "<bean:returnCode>";
var x = body.indexOf(tag) + tag.length;
huaweiReturnCode = body.substring(x, (x+1));
apigeeAccess.setVariable(req,"huaweiReturnCode",huaweiReturnCode);
apigeeAccess.setVariable(req,"huaweiStatusResult",(huaweiReturnCode =="0")? "success":"fail");
callback();
});
});
async.parallel(calls, function(){
resp.end(str2ab(response.toString));
});
});
可能是因为您的 Apigee 版本?因为旧版本的 Apigee 不支持 nodeJs
这是我在 nodeJS 中的代码。当我将它部署到我的本地时,它总是 运行 没问题,但是当我将它部署到生产环境时,我总是遇到错误 "ArrayBuffer not defined"。有人能告诉我这是什么原因造成的吗?我会尝试添加 ArrayBuffer 但我得到了同样的错误。谢谢
var svr = http.createServer(function(req, resp) {
var response = [];
var calls = [];
var windowLiveId;
var huaweiReturnCode;
var serviceId = apigeeAccess.getVariable(req,'subscription.serviceid');
var ericssonRequestBody = {"offerId":serviceId,"generateBillingRecord":true };
calls.push(function(callback) {
http.get('http://butcha-test.apigee.net/v1/accounts/', function (resource) {
resource.setEncoding('binary');
resource.on('data', function (data) {
windowLiveId = JSON.parse(data).AccountId;
request.post({
url:'http://butcha-test.apigee.net/v1/erickson/'+windowLiveId,
method: 'POST',
headers:{
'Content-Type': 'application/json'
},
body: JSON.stringify(ericssonRequestBody)
}, function(error,res,body){
apigeeAccess.setVariable(req,"ericsonStatus",(/2[0-9][0-9]/.test(res.statusCode)) ? "success":"fail");
apigeeAccess.setVariable(req,"ericsonStatusCode",res.statusCode);
callback();
});
});
});
});
calls.push(function(callback){
request.post({
url:'http://morning-sea-3467.getsandbox.com/mockOverseaBossServiceSoapBinding',
method: 'POST',
headers: {'content-type' : 'application/xml'},
body: huaweiSoapRequest
}, function(error,res,body){
response.push(body);
var tag = "<bean:returnCode>";
var x = body.indexOf(tag) + tag.length;
huaweiReturnCode = body.substring(x, (x+1));
apigeeAccess.setVariable(req,"huaweiReturnCode",huaweiReturnCode);
apigeeAccess.setVariable(req,"huaweiStatusResult",(huaweiReturnCode =="0")? "success":"fail");
callback();
});
});
async.parallel(calls, function(){
resp.end(str2ab(response.toString));
});
});
可能是因为您的 Apigee 版本?因为旧版本的 Apigee 不支持 nodeJs