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');
});
6
  • You're sure port 9000 is free, did you try another port? Commented Jan 21, 2016 at 5:34
  • I have no problem with port 9000. My problem is that my request cannot read the soap that I pass. Commented Jan 21, 2016 at 5: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. Commented Jan 21, 2016 at 5:47
  • Okay, that makes sense. I've been using the same port in one of my APIs. Commented Jan 21, 2016 at 6:16
  • @adeneo I already changed the port 9000 to 9001, I got the same error. Commented Jan 21, 2016 at 6:49

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.