0

I am having some trouble in posting using node js in apigee.

the response I get is a blank []. Now if push the error, the error I get is [Error: connect EINVAL]

I guess it can't read the soap when I call it. I used this post as a reference, but it doesn't seem to work.

var http = require('http');
var request = require('request');
var async = require('async');
var querystring = require('querystring');


var body = '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:over="http://oversea.interfaceBOSS.iptv.sample.com" xmlns:over1="http://oversea.common.iptv.sample.com" xmlns:bean="http://bean.oversea.interfaceBOSS.iptv.sample.com">'+
   '<soapenv:Header/>'+
   '<soapenv:Body>'+
      '<over:changeOrderInfo>'+
     '<over:changeOrderInfoReq>'+
       ' <!--Optional:-->'+
        '<over1:extensionInfo>'+
          ' <!--Optional:-->'+
           '<over1:namedParameters>'+
             ' <!--Zero or more repetitions:-->'+
              '<over:item>'+
               '  <!--Optional:-->'+
                ' <over1:key>?</over1:key>'+
                ' <!--Optional:-->'+
                ' <over1:value>?</over1:value>'+
              '</over:item>'+
           '</over1:namedParameters>'+
        '</over1:extensionInfo>'+
        '<!--Optional:-->'+
        '<over1:sequenceID>?</over1:sequenceID>'+
        '<!--Optional:-->'+
        '<over1:version>?</over1:version>'+
        '<!--You may enter ANY elements at this point-->'+
        '<!--Optional:-->'+
        '<bean:subscriberID>?</bean:subscriberID>'+
        '<!--Optional:-->'+
        '<bean:orderBean>'+
           '<!--Optional:-->'+
           '<over1:extensionInfo>'+
             ' <!--Optional:-->'+
              '<over1:namedParameters>'+
                ' <!--Zero or more repetitions:-->'+
                 '<over:item>'+
                   ' <!--Optional:-->'+
                    '<over1:key>?</over1:key>'+
                    '<!--Optional:-->'+
                    '<over1:value>?</over1:value>'+
                 '</over:item>'+
              '</over1:namedParameters>'+
           '</over1:extensionInfo>'+
           '<!--Optional:-->'+
           '<bean:productID>?</bean:productID>'+
           '<!--Optional:-->'+
           '<bean:terminalID>?</bean:terminalID>'+
           '<bean:operationType>?</bean:operationType>'+
           '<!--You may enter ANY elements at this point-->'+
        '</bean:orderBean>'+
     '</over:changeOrderInfoReq>'+
      '</over:changeOrderInfo>'+
   '</soapenv:Body>'+
'</soapenv:Envelope>"';

var svr = http.createServer(function(req, resp) {
   var response = [];
   var calls = [];
   var myJSONObject = { "msisdn":"9177440311"};

    var buffer = "";

   calls.push(function(callback){
      request.post({
            url:'http://10.23.22.104',
            method: 'POST',
            port:'8080',
            path:"/mockOverseaBossServiceSoapBinding",
        headers:{
            'Cookie': "cookie",
             'Content-Type': 'text/xml',
             'Content-Length': Buffer.byteLength(body)
        },

        }, function(error,res,body){
            response.push(body);
        callback(); 
        });

  }); 


 async.parallel(calls, function(){
    resp.end("[" + response.toString() + "]");
   //response = [];
    //for(var i=0; i<response.length; i++){
    //  response.pop();
  //  }
  });

});



svr.listen(9000, function() {
    console.log('Node HTTP server is listening');
});
Community
  • 1
  • 1
Aaron
  • 2,591
  • 4
  • 27
  • 45
  • You're sure port 9000 is free, did you try another port? – adeneo Jan 21 '16 at 05:34
  • I have no problem with port 9000. My problem is that my request cannot read the soap that I pass. – Aaron Jan 21 '16 at 05:43
  • Okay, just noting that `EINVAL` usually means the socket is already connected, the socket is busy, socket is closed, port is in use by some other process etc. not that the data is invalid. – adeneo Jan 21 '16 at 05:47
  • Okay, that makes sense. I've been using the same port in one of my APIs. – Aaron Jan 21 '16 at 06:16
  • @adeneo I already changed the port 9000 to 9001, I got the same error. – Aaron Jan 21 '16 at 06:49
  • @adeneo apparently, you were right. I deployed the url in the cloud and it worked. – Aaron Jan 21 '16 at 09:16

0 Answers0