2015-06-02 94 views
0

我無法從Connect獲取的響應中提取數據。我可以看到終端正在獲得兩個POST,但我沒有看到數據,因爲console.log(req)報告了所有內容,而且我找不到這些信息。DocuSign與NodeJS連接w/Express

我正在使用ngrok公開我的端點,並且我已將Connect配置爲使用信封簽名上的XML更新發送文檔。

要說明這個問題,您將如何從請求中提取文檔?

在此先感謝。

編輯: 我使用util來輸出整個req,但仍然無法找到XML和文檔字節所在的對象。它當然不是主體。

{ _readableState: 
    { highWaterMark: 16384, 
    buffer: [], 
    length: 0, 
    pipes: null, 
    pipesCount: 0, 
    flowing: false, 
    ended: false, 
    endEmitted: false, 
    reading: false, 
    calledRead: false, 
    sync: true, 
    needReadable: false, 
    emittedReadable: false, 
    readableListening: false, 
    objectMode: false, 
    defaultEncoding: 'utf8', 
    ranOut: false, 
    awaitDrain: 0, 
    readingMore: false, 
    decoder: null, 
    encoding: null }, 
    readable: true, 
    domain: null, 
    _events: {}, 
    _maxListeners: 10, 
    socket: 
    { _connecting: false, 
    _handle: 
     { fd: null, 
     writeQueueSize: 0, 
     owner: [Circular], 
     onread: [Function: onread], 
     reading: true }, 
    _readableState: 
     { highWaterMark: 16384, 
     buffer: [], 
     length: 0, 
     pipes: null, 
     pipesCount: 0, 
     flowing: false, 
     ended: false, 
     endEmitted: false, 
     reading: true, 
     calledRead: true, 
     sync: false, 
     needReadable: true, 
     emittedReadable: false, 
     readableListening: false, 
     objectMode: false, 
     defaultEncoding: 'utf8', 
     ranOut: false, 
     awaitDrain: 0, 
     readingMore: false, 
     decoder: null, 
     encoding: null }, 
    readable: true, 
    domain: null, 
    _events: 
     { end: [Object], 
     finish: [Function: onSocketFinish], 
     _socketEnd: [Function: onSocketEnd], 
     drain: [Object], 
     timeout: [Function], 
     error: [Function], 
     close: [Object] }, 
    _maxListeners: 10, 
    _writableState: 
     { highWaterMark: 16384, 
     objectMode: false, 
     needDrain: false, 
     ending: false, 
     ended: false, 
     finished: false, 
     decodeStrings: false, 
     defaultEncoding: 'utf8', 
     length: 0, 
     writing: false, 
     sync: false, 
     bufferProcessing: false, 
     onwrite: [Function], 
     writecb: null, 
     writelen: 0, 
     buffer: [], 
     errorEmitted: false }, 
    writable: true, 
    allowHalfOpen: true, 
    onend: [Function], 
    destroyed: false, 
    bytesRead: 32864, 
    _bytesDispatched: 25, 
    _pendingData: null, 
    _pendingEncoding: '', 
    server: 
     { domain: null, 
     _events: [Object], 
     _maxListeners: 10, 
     _connections: 2, 
     connections: [Getter/Setter], 
     _handle: [Object], 
     _usingSlaves: false, 
     _slaves: [], 
     allowHalfOpen: true, 
     httpAllowHalfOpen: false, 
     timeout: 120000, 
     _connectionKey: 'ip' }, 
    _idleTimeout: 120000, 
    _idleNext: 
     { _connecting: false, 
     _handle: [Object], 
     _readableState: [Object], 
     readable: true, 
     domain: null, 
     _events: [Object], 
     _maxListeners: 10, 
     _writableState: [Object], 
     writable: true, 
     allowHalfOpen: true, 
     onend: [Function], 
     destroyed: false, 
     bytesRead: 1246, 
     _bytesDispatched: 751, 
     _pendingData: null, 
     _pendingEncoding: '', 
     server: [Object], 
     _idleTimeout: 120000, 
     _idleNext: [Object], 
     _idlePrev: [Circular], 
     _idleStart: 1433278153744, 
     parser: [Object], 
     ondata: [Function], 
     _paused: false, 
     _httpMessage: null }, 
    _idlePrev: { _idleNext: [Circular], _idlePrev: [Object] }, 
    _idleStart: 1433278184434, 
    parser: 
     { _headers: [], 
     _url: '', 
     onHeaders: [Function: parserOnHeaders], 
     onHeadersComplete: [Function: parserOnHeadersComplete], 
     onBody: [Function: parserOnBody], 
     onMessageComplete: [Function: parserOnMessageComplete], 
     socket: [Circular], 
     incoming: [Circular], 
     maxHeaderPairs: 2000, 
     onIncoming: [Function] }, 
    ondata: [Function], 
    _paused: false, 
    _httpMessage: 
     { domain: null, 
     _events: [Object], 
     _maxListeners: 10, 
     output: [], 
     outputEncodings: [], 
     writable: true, 
     _last: false, 
     chunkedEncoding: false, 
     shouldKeepAlive: true, 
     useChunkedEncodingByDefault: true, 
     sendDate: true, 
     _headerSent: false, 
     _header: '', 
     _hasBody: true, 
     _trailer: '', 
     finished: false, 
     _hangupClose: false, 
     socket: [Circular], 
     connection: [Circular], 
     _expect_continue: true, 
     _sent100: true, 
     _headers: [Object], 
     _headerNames: [Object], 
     req: [Circular], 
     locals: {} } }, 
    connection: 
    { _connecting: false, 
    _handle: 
     { fd: null, 
     writeQueueSize: 0, 
     owner: [Circular], 
     onread: [Function: onread], 
     reading: true }, 
    _readableState: 
     { highWaterMark: 16384, 
     buffer: [], 
     length: 0, 
     pipes: null, 
     pipesCount: 0, 
     flowing: false, 
     ended: false, 
     endEmitted: false, 
     reading: true, 
     calledRead: true, 
     sync: false, 
     needReadable: true, 
     emittedReadable: false, 
     readableListening: false, 
     objectMode: false, 
     defaultEncoding: 'utf8', 
     ranOut: false, 
     awaitDrain: 0, 
     readingMore: false, 
     decoder: null, 
     encoding: null }, 
    readable: true, 
    domain: null, 
    _events: 
     { end: [Object], 
     finish: [Function: onSocketFinish], 
     _socketEnd: [Function: onSocketEnd], 
     drain: [Object], 
     timeout: [Function], 
     error: [Function], 
     close: [Object] }, 
    _maxListeners: 10, 
    _writableState: 
     { highWaterMark: 16384, 
     objectMode: false, 
     needDrain: false, 
     ending: false, 
     ended: false, 
     finished: false, 
     decodeStrings: false, 
     defaultEncoding: 'utf8', 
     length: 0, 
     writing: false, 
     sync: false, 
     bufferProcessing: false, 
     onwrite: [Function], 
     writecb: null, 
     writelen: 0, 
     buffer: [], 
     errorEmitted: false }, 
    writable: true, 
    allowHalfOpen: true, 
    onend: [Function], 
    destroyed: false, 
    bytesRead: 32864, 
    _bytesDispatched: 25, 
    _pendingData: null, 
    _pendingEncoding: '', 
    server: 
     { domain: null, 
     _events: [Object], 
     _maxListeners: 10, 
     _connections: 2, 
     connections: [Getter/Setter], 
     _handle: [Object], 
     _usingSlaves: false, 
     _slaves: [], 
     allowHalfOpen: true, 
     httpAllowHalfOpen: false, 
     timeout: 120000, 
     _connectionKey: 'ip' }, 
    _idleTimeout: 120000, 
    _idleNext: 
     { _connecting: false, 
     _handle: [Object], 
     _readableState: [Object], 
     readable: true, 
     domain: null, 
     _events: [Object], 
     _maxListeners: 10, 
     _writableState: [Object], 
     writable: true, 
     allowHalfOpen: true, 
     onend: [Function], 
     destroyed: false, 
     bytesRead: 1246, 
     _bytesDispatched: 751, 
     _pendingData: null, 
     _pendingEncoding: '', 
     server: [Object], 
     _idleTimeout: 120000, 
     _idleNext: [Object], 
     _idlePrev: [Circular], 
     _idleStart: 1433278153744, 
     parser: [Object], 
     ondata: [Function], 
     _paused: false, 
     _httpMessage: null }, 
    _idlePrev: { _idleNext: [Circular], _idlePrev: [Object] }, 
    _idleStart: 1433278184434, 
    parser: 
     { _headers: [], 
     _url: '', 
     onHeaders: [Function: parserOnHeaders], 
     onHeadersComplete: [Function: parserOnHeadersComplete], 
     onBody: [Function: parserOnBody], 
     onMessageComplete: [Function: parserOnMessageComplete], 
     socket: [Circular], 
     incoming: [Circular], 
     maxHeaderPairs: 2000, 
     onIncoming: [Function] }, 
    ondata: [Function], 
    _paused: false, 
    _httpMessage: 
     { domain: null, 
     _events: [Object], 
     _maxListeners: 10, 
     output: [], 
     outputEncodings: [], 
     writable: true, 
     _last: false, 
     chunkedEncoding: false, 
     shouldKeepAlive: true, 
     useChunkedEncodingByDefault: true, 
     sendDate: true, 
     _headerSent: false, 
     _header: '', 
     _hasBody: true, 
     _trailer: '', 
     finished: false, 
     _hangupClose: false, 
     socket: [Circular], 
     connection: [Circular], 
     _expect_continue: true, 
     _sent100: true, 
     _headers: [Object], 
     _headerNames: [Object], 
     req: [Circular], 
     locals: {} } }, 
    httpVersion: '1.1', 
    complete: false, 
    headers: 
    { 'content-type': 'text/xml; charset=utf-8', 
    host: 'host', 
    'content-length': '32697', 
    expect: '100-continue', 
    'x-forwarded-for': 'ip' }, 
    trailers: {}, 
    _pendings: [], 
    _pendingIndex: 0, 
    url: '/return', 
    method: 'POST', 
    statusCode: null, 
    client: 
    { _connecting: false, 
    _handle: 
     { fd: null, 
     writeQueueSize: 0, 
     owner: [Circular], 
     onread: [Function: onread], 
     reading: true }, 
    _readableState: 
     { highWaterMark: 16384, 
     buffer: [], 
     length: 0, 
     pipes: null, 
     pipesCount: 0, 
     flowing: false, 
     ended: false, 
     endEmitted: false, 
     reading: true, 
     calledRead: true, 
     sync: false, 
     needReadable: true, 
     emittedReadable: false, 
     readableListening: false, 
     objectMode: false, 
     defaultEncoding: 'utf8', 
     ranOut: false, 
     awaitDrain: 0, 
     readingMore: false, 
     decoder: null, 
     encoding: null }, 
    readable: true, 
    domain: null, 
    _events: 
     { end: [Object], 
     finish: [Function: onSocketFinish], 
     _socketEnd: [Function: onSocketEnd], 
     drain: [Object], 
     timeout: [Function], 
     error: [Function], 
     close: [Object] }, 
    _maxListeners: 10, 
    _writableState: 
     { highWaterMark: 16384, 
     objectMode: false, 
     needDrain: false, 
     ending: false, 
     ended: false, 
     finished: false, 
     decodeStrings: false, 
     defaultEncoding: 'utf8', 
     length: 0, 
     writing: false, 
     sync: false, 
     bufferProcessing: false, 
     onwrite: [Function], 
     writecb: null, 
     writelen: 0, 
     buffer: [], 
     errorEmitted: false }, 
    writable: true, 
    allowHalfOpen: true, 
    onend: [Function], 
    destroyed: false, 
    bytesRead: 32864, 
    _bytesDispatched: 25, 
    _pendingData: null, 
    _pendingEncoding: '', 
    server: 
     { domain: null, 
     _events: [Object], 
     _maxListeners: 10, 
     _connections: 2, 
     connections: [Getter/Setter], 
     _handle: [Object], 
     _usingSlaves: false, 
     _slaves: [], 
     allowHalfOpen: true, 
     httpAllowHalfOpen: false, 
     timeout: 120000, 
     _connectionKey: 'ip' }, 
    _idleTimeout: 120000, 
    _idleNext: 
     { _connecting: false, 
     _handle: [Object], 
     _readableState: [Object], 
     readable: true, 
     domain: null, 
     _events: [Object], 
     _maxListeners: 10, 
     _writableState: [Object], 
     writable: true, 
     allowHalfOpen: true, 
     onend: [Function], 
     destroyed: false, 
     bytesRead: 1246, 
     _bytesDispatched: 751, 
     _pendingData: null, 
     _pendingEncoding: '', 
     server: [Object], 
     _idleTimeout: 120000, 
     _idleNext: [Object], 
     _idlePrev: [Circular], 
     _idleStart: 1433278153744, 
     parser: [Object], 
     ondata: [Function], 
     _paused: false, 
     _httpMessage: null }, 
    _idlePrev: { _idleNext: [Circular], _idlePrev: [Object] }, 
    _idleStart: 1433278184434, 
    parser: 
     { _headers: [], 
     _url: '', 
     onHeaders: [Function: parserOnHeaders], 
     onHeadersComplete: [Function: parserOnHeadersComplete], 
     onBody: [Function: parserOnBody], 
     onMessageComplete: [Function: parserOnMessageComplete], 
     socket: [Circular], 
     incoming: [Circular], 
     maxHeaderPairs: 2000, 
     onIncoming: [Function] }, 
    ondata: [Function], 
    _paused: false, 
    _httpMessage: 
     { domain: null, 
     _events: [Object], 
     _maxListeners: 10, 
     output: [], 
     outputEncodings: [], 
     writable: true, 
     _last: false, 
     chunkedEncoding: false, 
     shouldKeepAlive: true, 
     useChunkedEncodingByDefault: true, 
     sendDate: true, 
     _headerSent: false, 
     _header: '', 
     _hasBody: true, 
     _trailer: '', 
     finished: false, 
     _hangupClose: false, 
     socket: [Circular], 
     connection: [Circular], 
     _expect_continue: true, 
     _sent100: true, 
     _headers: [Object], 
     _headerNames: [Object], 
     req: [Circular], 
     locals: {} } }, 
    _consuming: false, 
    _dumped: false, 
    httpVersionMajor: 1, 
    httpVersionMinor: 1, 
    upgrade: false, 
    next: [Function: next], 
    baseUrl: '', 
    originalUrl: '/return', 
    _parsedUrl: 
    { protocol: null, 
    slashes: null, 
    auth: null, 
    host: null, 
    port: null, 
    hostname: null, 
    hash: null, 
    search: null, 
    query: null, 
    pathname: '/return', 
    path: '/return', 
    href: '/return', 
    _raw: '/return' }, 
    params: {}, 
    query: {}, 
    res: 
    { domain: null, 
    _events: { finish: [Function] }, 
    _maxListeners: 10, 
    output: [], 
    outputEncodings: [], 
    writable: true, 
    _last: false, 
    chunkedEncoding: false, 
    shouldKeepAlive: true, 
    useChunkedEncodingByDefault: true, 
    sendDate: true, 
    _headerSent: false, 
    _header: '', 
    _hasBody: true, 
    _trailer: '', 
    finished: false, 
    _hangupClose: false, 
    socket: 
     { _connecting: false, 
     _handle: [Object], 
     _readableState: [Object], 
     readable: true, 
     domain: null, 
     _events: [Object], 
     _maxListeners: 10, 
     _writableState: [Object], 
     writable: true, 
     allowHalfOpen: true, 
     onend: [Function], 
     destroyed: false, 
     bytesRead: 32864, 
     _bytesDispatched: 25, 
     _pendingData: null, 
     _pendingEncoding: '', 
     server: [Object], 
     _idleTimeout: 120000, 
     _idleNext: [Object], 
     _idlePrev: [Object], 
     _idleStart: 1433278184434, 
     parser: [Object], 
     ondata: [Function], 
     _paused: false, 
     _httpMessage: [Circular] }, 
    connection: 
     { _connecting: false, 
     _handle: [Object], 
     _readableState: [Object], 
     readable: true, 
     domain: null, 
     _events: [Object], 
     _maxListeners: 10, 
     _writableState: [Object], 
     writable: true, 
     allowHalfOpen: true, 
     onend: [Function], 
     destroyed: false, 
     bytesRead: 32864, 
     _bytesDispatched: 25, 
     _pendingData: null, 
     _pendingEncoding: '', 
     server: [Object], 
     _idleTimeout: 120000, 
     _idleNext: [Object], 
     _idlePrev: [Object], 
     _idleStart: 1433278184434, 
     parser: [Object], 
     ondata: [Function], 
     _paused: false, 
     _httpMessage: [Circular] }, 
    _expect_continue: true, 
    _sent100: true, 
    _headers: 
     { 'x-powered-by': 'Express', 
     'access-control-allow-origin': '*', 
     'access-control-allow-methods': 'GET,PUT,POST,DELETE', 
     'access-control-allow-headers': 'Content-Type' }, 
    _headerNames: 
     { 'x-powered-by': 'X-Powered-By', 
     'access-control-allow-origin': 'Access-Control-Allow-Origin', 
     'access-control-allow-methods': 'Access-Control-Allow-Methods', 
     'access-control-allow-headers': 'Access-Control-Allow-Headers' }, 
    req: [Circular], 
    locals: {} }, 
    secret: undefined, 
    cookies: {}, 
    signedCookies: {}, 
    body: {}, 
    route: { path: '/return', stack: [ [Object] ], methods: { post: true } } } 

編輯2: 我意識到事情是不對的。所以我做了一些觀察,發現Node甚至沒有接受XML,所以我使用了一個模塊來做到這一點,現在主體包含文檔。唯一的問題是,當我試圖保存它時,它已經損壞,所以我正在努力。

+0

XML具有PDFBytes,所以您需要訪問'req',否則您將無法獲取它。 – Andrew

+0

我可以訪問req,但是我可能不得不將它輸出到.txt文件中,因爲我的控制檯只能使用到目前爲止。它存儲了什麼對象? –

+0

我把它扔進了一個答案 – Andrew

回答

2

您必須確保在DocuSign Connect設置中啓用了將文檔附加到Connect事件。

以下是您希望將PDFBytes從中剝離出來然後在本地解碼並保存爲PDF格式的XML。

<DocumentPDFs> 
    <DocumentPDF> 
    <Name>Sample Document.pdf</Name> 
     <PDFBytes>{omitted}</PDFBytes> 
     <DocumentType>CONTENT</DocumentType> 
    </DocumentPDF> 
</DocumentPDFs>