2017-02-17 95 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)),並從那裏開始並不是一個壞主意。 –