Smtp Gateway Config Service

From Direct Project
Jump to navigation Jump to search
Back:CSharp Reference Implementation

Installing the Configuration Web Service

The configuration service uses 2 server side components:
  • A Sql Database for storage
  • A Soap 1.1 Web Service fronting the database store


Note: So far, tested only with Microsoft Sql Server 2008 and Sql Server Express 2008.

Prerequisites

This section assumes that you are familiar with:
  • Sql, Sql Server Express & Sql Management Studio
  • IIS 7+


To run the Configuration Web Service, you should install the following on 1 or more machines

Enabling appropriate roles

  • Open Server Manager
    • Start Menu
    • Type Server Manager in the Search box. Click Server Manager Icon.
    • OR Right-Click on Computer, Select Manage
  • On the left pain, expand the Roles node
    • Verify that you have the roles listed above enabled.
    • If not, click the Add Roles button on the right and proceed...

Setting up the Store

To set up the Configuration Store, you must create a DirectConfig database and apply the the Configuration Store Schema.

Creating the database

  • Launch Sql Management Studio 2008
  • Connect to your database server
  • Create a new database called DirectConfig
    • In Object Explorer, right click on the Databases Node
    • New Database ...

Applying the Schema

  • Open a new query window
    • In Object Explorer, Right click on DirectConfig
    • New Query
    • From the source tree, open csharp\config\store\Schema.sql
    • Run the Sql
    • Do confirm you are connected to the right database and so on before crying foul :-)

Sql Logins

The Configuration Web Service will need access to the store. 
  • Create a Sql Login with Read/Write permissions to the DirectConfig database
  • You will need this login to construct a proper connection string.



Setting up the Config Web Service

Installing the code

  • Open a command prompt
  • Do a full build: msbuild build.xml
    • You do not need to do a 64 bit build. The Configuration Service uses .NET assemblies compiled for Any CPU.
  • cd csharp\config\install
  • type install.bat


install.bat places all binaries in a C:\inetpub\ConfigService

Customizing Web.config

You must point the Config Web Service at your Sql Server. 
  • Open a command prompt
  • cd C:\inetpub\ConfigService
  • notepad web.config
  • under connectionStrings, locate the configStore entry
  • Edit the connection string. Make sure you supply appropriate Sql login credentials.


You always install a custom web.config that you pre-create and save, pass the path to the config file when you call install.bat:
install.bat C:\myConfigFiles\fooMachine.config

The script will replace the default web.config with the contents of your config file.

Deploying to another machine

You can xcopy deploy the C:\inetpub\ConfigService folder to your target machine.

You can either prop the folder created by install.bat, OR:
  • Open a command prompt
  • cd csharp\config\install
  • copybins.bat
  • Hit return to accept all defaults.
    • You may want to customize the config file

Creating the Web Site

The Configuration Web Service is a WCF SOAP service with a Basic Http Binding. 
  • Make sure the service bits are deployed to your target machine (above)
  • Launch the IIS Admin UI
  • Expand the Sites folder
  • Right Click on Default Site, select New Application
  • Name the application ConfigService
  • Set the physical path to C:\inetpub\ConfigService (or whatever directly you copied the service code to)
    • Make sure you've set the right permissions OR are running the service under an account with adequate privileges
    • Inadequate permissions is the most common bootstrap problem

Verifying your installation

  • Verify that WCF can run your service:
    • Launch your web browser
    • [1]
      • If you have an already open page, make sure you hit Refresh
    • You should see a web service description page
  • Verify that your service can connect to the database.
    • [2]
    • You may see an error like this: System.Data.SqlClient.SqlException: Cannot open database "DirectConfig" requested by the login. The login failed. Login failed for user 'IIS APPPOOL\DefaultAppPool
    • If so, you can either:
      • Modify your connect string to use a valid Sql Login
      • If you use a connect string with Integrated Security, use an App Pool configured to run with a user account that has access to Sql.

Running the project in the Debugger

  • The Config Service project is configured to run on port 6692 within the ASP.NET Development Server.
  • It looks for ./SqlExpress as on your local machine
    • Customize the path using web.config by editing the configStoreConnectionString appSetting
  • To install the default test certificate etc used by the Developer Gateway: CSharp Setup Instructions

Config Console

The Config Console is a command line adminstration tool for the Configuration Service. You use it to create and adminster domains, addresses, certificates and anchors.

Deploying

  • Open a command prompt
  • Build
  • cd csharp\config\console
  • type copybins.bat
  • By default, the script places binaries in C:\inetpub\ConfigConsole
    • You can pass the destination path like this: copybins.bat destinationPath

Using

  • Open a command prompt
  • cd C:\inetpub\ConfigConsole
  • Type ConfigConsole.exe
  • Type help for a list of commands.
    • commands for a list of all commands
    • help <commandName> for a specific command
    • help <nameprefix> for commands with names beginning with...
    • search <text> for commands whose names contain the given text
  • By default, the Config Console is set up to connect to a service running on localhost
    • To change the host:
      • type settings_host_set hostName [port]
      • OR: edit ConsoleConfigSettings.xml

Config Admin Web UI

TODO: John
In Developer Install
  • usename: admin
  • password: admin