Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including exchange-test-server with all npm packages installed. Try it out:

var exchangeTestServer = require("exchange-test-server")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

exchange-test-server v0.1.5

The test server that implement the EWS API


NPM version Build Status Dependency Status Coverage Status

The test server that implement the EWS API


$ npm install --save exchange-test-server


start the test server

server = new Server()
server.start {port: 3000}, ->
  console.log 'server listen on localhost:3000'

start the test server and send the SOAP request

Server = require 'exchange-test-server'
Builder = require 'libxmljs-builder'
http = require 'http'
NS =
  NS_SOAP: 'soap'
  NS_TYPES: 't'
    soap: ''
    t: ''
    m: ''


class RequestConstructor
  _build: (bodyCallback) ->
    @builder = new Builder
    @builder.defineNS NS.NAMESPACES
    @builder.rootNS NS.NS_SOAP, 'Envelope', (builder) ->
      builder.nodeNS NS.NS_SOAP, 'Body', bodyCallback

  _buildAction: (action, callback) ->
    @_build (builder) ->
      builder.nodeNS NS_M, action, callback

  buildFolderIds: (builder, folderIds) ->
    folderIds = [folderIds] unless Array.isArray(folderIds)
    builder.nodeNS NS_M, 'FolderIds', (builder) =>
      @buildDistinguishFolderId(builder, folderId) for folderId in folderIds

  buildDistinguishFolderId: (builder, folderId) ->
    builder.nodeNS NS_T, 'DistinguishedFolderId', Id: folderId

class GetFolderRequest extends RequestConstructor
  build: (folderIds) ->
    @_buildAction 'GetFolder', (builder) =>
      builder.nodeNS NS_M, 'FolderShape', (builder) ->
        builder.nodeNS NS_T, 'BaseShape', 'Default'
      @buildFolderIds(builder, folderIds)

dbPath = require('path').resolve(__dirname, 'data/db.sqlite')
server = new Server()
server.start dbPath: dbPath, ->
  console.log 'server start'

  config =
    port: 3000, method: 'POST', path: '/EWS/Exchange.asmx'
    headers: 'Content-Type': 'text/xml'

  req = http.request config, (res) ->
    console.log 'Done'
  req.end new GetFolderRequest().build('inbox').toString()


(Coming soon)


In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using gulp.


Copyright (c) 2015 liuxiong. Licensed under the MIT license.

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free