2017-02-17 9 views
0

私は以下のコードを使ってSoap APIを呼び出しています。ノードjsでも応答は返っていませんが、このAPIをjavaで使用すると、上記のxmlデータ*私が使用しているコードです。右のコード.MYコードは以下の通りです、私に そして私を提案してください、私は**それ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); 
     }); 

上で動作するようにNPMモジュールの石鹸を使用していると私は私が試してみてくださいどのメソッド自分のサイトからの応答を取得していない午前私をsuggstください。あなたは体のために設定されているデータは、あなたが呼び出しているサーバーに渡されないことを意味GETをやっている**

<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

エラー の下に取得しています。詳細については、client.post代わりのclient.get

に切り替えてみてくださいまた、あなたはRESTコンポーネントを使用してSOAPサービスを呼び出すためにしようとしているthe documentation for node-rest-client

を参照してください。それでもなお可能ですが、伝統的にSOAPActionなどの要素を追加してSOAPエンベロープを自分で作成する必要がありますが、専用のSOAPコンポーネント(node-soapなど)を使用すると、リクエスト構造についてあまり心配する必要がなくなります。

+0

私はこれも試してみましたが、同じエラーが発生します –

+0

あなたが電話しているサービスについて詳しく知りませんが、GETではなくPOSTを実行する必要がある以外に間違っている場所を知るのは難しい。 SOAPサービスを呼び出すためにRESTクライアントを使用しているので、SOAPActionヘッダーが必要な場合は追加する必要があります。外側のタグは必要ないかもしれません。必要なヘッダーがある可能性があります。 使用しているコンポーネントを[node-soap](https://github.com/vpulim/node-soap)などのSOAPに切り替えてそこから移動することは悪い考えではないかもしれません。 –

関連する問題