2017-02-17 94 views
0

我使用下面的代码调用Soap API在节点js但我不geting回应,但是当在java中使用此api时,我回来正确地回应与上述xml数据* .Below是我正在使用的代码。请suggst我正确的代码。我的代码如下,我使用NPM模块肥皂就可以了调用SOAP API在节点js和获取错误

var Client = require('node-rest-client').Client; 
     var client = new Client(); 

     // request and response additional configuration 
     var args = { 

      headers: { "test-header": "client-api" }, 
      data: "<xml><NMFIIService><service_request><appln_id>MFS37314 </appln_id><broker_code>ARN-37314</broker_code><password>QC1RA3CJ</password><user_type>Broker</user_type><broker_loc_code>M3</broker_loc_code><iin>5011164069</iin><sub_trxn_type>N</sub_trxn_type><poa>Y</poa><trxn_acceptance>OL</trxn_acceptance><demat_user>N</demat_user><dp_id></dp_id><bank>ICI</bank><ac_no>017701520489</ac_no><ifsc_code>ICIC0000177</ifsc_code><sub_broker_arn_code></sub_broker_arn_code><sub_broker_code></sub_broker_code><euin_opted>Y</euin_opted><euin>E049164</euin><trxn_execution>Y</trxn_execution><remarks>test</remarks><payment_mode>OL</payment_mode><billdesk_bank>ICI</billdesk_bank><instrm_bank></instrm_bank><instrm_ac_no></instrm_ac_no><instrm_no></instrm_no><instrm_amount>1</instrm_amount><instrm_date></instrm_date><instrm_branch></instrm_branch><instrm_charges></instrm_charges><micr></micr><rtgs_code></rtgs_code><neft_ifsc></neft_ifsc><advisory_charge></advisory_charge><dd_charge></dd_charge><cheque_deposit_mode></cheque_deposit_mode><debit_amount_type></debit_amount_type><nominee_flag>C</nominee_flag><no_of_nominee>1</no_of_nominee><nominee1_name>BHAVNA KHATRI</nominee1_name><nominee1_dob></nominee1_dob><nominee1_addr1>C-5/5 SCOND FLOOR ARCEE CITY SECTOR 52 GURGAON</nominee1_addr1><nominee1_addr2></nominee1_addr2><nominee1_addr3></nominee1_addr3><nominee1_city>GURGAON</nominee1_city><nominee1_state></nominee1_state><nominee1_pincode></nominee1_pincode><nominee1_relation>SPOUSE</nominee1_relation><nominee1_percent>100</nominee1_percent><nominee1_guard_name></nominee1_guard_name><nominee1_guard_pan></nominee1_guard_pan><nominee2_name></nominee2_name><nominee2_dob></nominee2_dob><nominee2_relation></nominee2_relation><nominee2_percent></nominee2_percent><nominee2_guard_name></nominee2_guard_name><nominee2_guard_pan></nominee2_guard_pan><nominee3_Name></nominee3_Name><nominee3_dob></nominee3_dob><nominee3_relation></nominee3_relation><nominee3_percent></nominee3_percent><nominee3_guard_name></nominee3_guard_name><nominee3_guard_pan></nominee3_guard_pan><sip_paymech></sip_paymech><sip_micr_no></sip_micr_no><sip_bank></sip_bank><sip_branch></sip_branch><sip_instrm_no></sip_instrm_no><sip_acc_no></sip_acc_no><sip_ac_type></sip_ac_type><sip_ifsc_code></sip_ifsc_code><umrn></umrn><ach_amt></ach_amt><ach_fromdate></ach_fromdate><ach_enddate></ach_enddate><until_cancelled></until_cancelled><Return_paymnt_flag>Y</Return_paymnt_flag><Client_callback_url>http://m.investwell.in/hcver3b/pages/netbanking.jsp</Client_callback_url><trans_count>1</trans_count></service_request><childtrans><amc>128</amc><folio></folio><product_code>EFGPGGR</product_code><reinvest>Z</reinvest><amount>1</amount><sip_from_date></sip_from_date><sip_end_date></sip_end_date><sip_freq></sip_freq><sip_amount>1</sip_amount><sip_period_day></sip_period_day></childtrans></NMFIIService></xml>", 
       requestConfig: { 
       timeout: 1000, //request timeout in milliseconds 
       noDelay: true, //Enable/disable the Nagle algorithm 
       keepAlive: true, //Enable/disable keep-alive functionalityidle socket. 
       keepAliveDelay: 1000 //and optionally set the initial delay before the first keepalive probe is sent 
      }, 
      responseConfig: { 
       timeout: 1000 //response timeout 
      } 
     }; 


     client.get("https://www.nsenmf.com/NMFIITrxnService/NMFTrxnService/PURCHASETRXN", args, function (data, response) { 
      // parsed response body as js object 
      console.log(data); 
      // raw response 
      console.log(response); 
     }); 

工作**,我没有得到从他们的网站响应哪种方法我应该尝试请建议我 和我我得到以下错误 **

<Buffer ef bb bf 3c 3f 78 6d 6c 20 76 65 72 73 69 6f 6e 3d 22 31 2e 30 22 20 65 6e 63 6f 64 69 6e 67 3d 22 75 74 66 2d 38 22 3f 3e 0d 0a 3c 21 44 4f 43 54 59 ... > 
IncomingMessage { 
    _readableState: 
    ReadableState { 
    objectMode: false, 
    highWaterMark: 16384, 
    buffer: BufferList { head: null, tail: null, length: 0 }, 
    length: 0, 
    pipes: null, 
    pipesCount: 0, 
    flowing: true, 
    ended: true, 
    endEmitted: true, 
    reading: false, 
    sync: false, 
    needReadable: false, 
    emittedReadable: false, 
    readableListening: false, 
    resumeScheduled: false, 
    defaultEncoding: 'utf8', 
    ranOut: false, 
    awaitDrain: 0, 
    readingMore: false, 
    decoder: null, 
    encoding: null }, 
    readable: false, 
    domain: null, 
    _events: 
    { end: [ [Function: responseOnEnd], [Function] ], 
    timeout: [Function], 
    data: [Function], 
    error: [Function] }, 
    _eventsCount: 4, 
    _maxListeners: undefined, 
    socket: 
    TLSSocket { 
    _tlsOptions: 
     { pipe: null, 
     secureContext: [Object], 
     isServer: false, 
     requestCert: true, 
     rejectUnauthorized: true, 
     session: undefined, 
     NPNProtocols: undefined, 
     ALPNProtocols: undefined, 
     requestOCSP: undefined }, 
    _secureEstablished: true, 
    _securePending: false, 
    _newSessionPending: false, 
    _controlReleased: true, 
    _SNICallback: null, 
    servername: null, 
    npnProtocol: undefined, 
    alpnProtocol: false, 
    authorized: true, 
    authorizationError: null, 
    encrypted: true, 
    _events: 
     { close: [Object], 
     end: [Object], 
     finish: [Function: onSocketFinish], 
     _socketEnd: [Function: onSocketEnd], 
     secure: [Function], 
     free: [Function: onFree], 
     agentRemove: [Function: onRemove], 
     drain: [Function: ondrain], 
     error: [Function: socketErrorListener], 
     timeout: [Object] }, 
    _eventsCount: 10, 
    connecting: false, 
    _hadError: false, 
    _handle: null, 
    _parent: null, 
    _host: 'www.nsenmf.com', 
    _readableState: 
     ReadableState { 
     objectMode: false, 
     highWaterMark: 16384, 
     buffer: [Object], 
     length: 0, 
     pipes: null, 
     pipesCount: 0, 
     flowing: true, 
     ended: false, 
     endEmitted: false, 
     reading: true, 
     sync: false, 
     needReadable: true, 
     emittedReadable: false, 
     readableListening: false, 
     resumeScheduled: false, 
     defaultEncoding: 'utf8', 
     ranOut: false, 
     awaitDrain: 0, 
     readingMore: true, 
     decoder: null, 
     encoding: null }, 
    readable: false, 
    domain: null, 
    _maxListeners: undefined, 
    _writableState: 
     WritableState { 
     objectMode: false, 
     highWaterMark: 16384, 
     needDrain: false, 
     ending: true, 
     ended: true, 
     finished: true, 
     decodeStrings: false, 
     defaultEncoding: 'utf8', 
     length: 0, 
     writing: false, 
     corked: 0, 
     sync: false, 
     bufferProcessing: false, 
     onwrite: [Function], 
     writecb: null, 
     writelen: 0, 
     bufferedRequest: null, 
     lastBufferedRequest: null, 
     pendingcb: 0, 
     prefinished: true, 
     errorEmitted: false, 
     bufferedRequestCount: 0, 
     corkedRequestsFree: [Object] }, 
    writable: false, 
    allowHalfOpen: false, 
    destroyed: true, 
    _bytesDispatched: 3021, 
    _sockname: null, 
    _pendingData: null, 
    _pendingEncoding: '', 
    server: undefined, 
    _server: null, 
    ssl: null, 
    _requestCert: true, 
    _rejectUnauthorized: true, 
    parser: null, 
    _httpMessage: 

    responseUrl: 'https://www.nsenmf.com', 
    read: [Function] } 


I am not trying other code . Please suggest me right way to achieve it 

回答

0

你正在做一个GET,这意味着你的身体设置的任何数据不会被传递到您呼叫的服务器。尝试切换到client.post而不是client.get

欲了解更多信息,请参阅the documentation for node-rest-client

此外,你要调用使用REST组件SOAP服务。尽管仍然有可能,但传统上您需要添加诸如SOAPAction之类的东西并自己构建您的SOAP信封,而使用专用的SOAP组件(如node-soap)将意味着您可以专注于使用服务而不必担心太多的请求结构。

+0

主席先生,我也试过这一个。但同样的错误发生 –

+0

不知道更多关于你打电话的服务,很难知道你去哪里错了,除非你一定需要执行POST,而不是GET 。 您正在使用REST客户端来调用SOAP服务,因此如果需要SOAPAction标头,那么您需要添加标签,可能外部标签不是必需的,也许还有其他标头需要。 将您正在使用的组件切换到SOAP节点(例如[node-soap](https://github.com/vpulim/node-soap)),并从那里开始并不是一个坏主意。 –