Escolar Documentos
Profissional Documentos
Cultura Documentos
Building,debugging,anddeployingaDataSnap/RESTISAPIdll
LOCATION | ENGLISH | LOGON
EMBARCADEROHOME
Watch,Follow,&
ConnectwithUs
ShareThis
COMMUNITIES
ARTICLES
BLOGS
RESOURCES
DOWNLOADS
HELP
EDNDelphiDist.ComputingDataSnap
Building,debugging,anddeployingaDataSnap/REST
ISAPIdll
By:JohnKaster
Abstract:StepsandsuggestionsfordeployingaDataSnap/RESTserverasanISAPIDLL
Introduction
RADStudioXEincludessomenewfeaturesforDataSnapthatIhaveeagerlyanticipatedandbeenrequestingfor
years.TheXEreleaseprovidesanimplementationthatisalreadyprovingtobeveryusefulandproductive.ForEDN,
wehavealreadystartedcreatingnewDataSnap/RESTbasedservicesforour"nextgeneration"ofservicesbecause
ofthestrengthofthesenewfeatures.
ThisarticlediscussesthestepstakentobuildaDataSnap/RESTISAPIdllthatisdeployedtoIIS6onWindowsServer
2003.
AlthoughtheDataSnapwizardcaneasilymakestandaloneDataSnapservers,ISAPIisavaluableoptiontosupport.
ADataSnapISAPIserver:
Canshareportswithanexistingwebserver
CanbemanagedwithotherIISapplications
GetsSSLsupport"forfree"withthebuiltinSSLsupportofIIS
Painlessproxies
ThenewDataSnapclientproxygenerationsystemincludedinXEhasgeneratorsforDelphi,C++,DelphiPrism,PHP
andJavaScript.TheclientproxygeneratoraddressesissuesI'velonghadwithconsuminganyoftheRESTbased
servicesavailableontheweb.TheproxygeneratortakesthepainofcommunicatingwithandconsumingREST
servicesawaycompletelybytranslatingtheDataSnapmethodsandevencomplextypesinto"native"
implementationsforthetargetclientlanguage.
Developanddebugtheserver
Inmyopinion,theeasiestwaytodevelopanddebugaDataSnapserverisbyusingtheDataSnapserverwizardto
createastandaloneVCLformsapplication.
CreatetheDataSnap/RESTVCLformserver
FromFile|New|OtherselectDelphiProjects,thentheDataSnapServernode.SelectDataSnapREST
ApplicationandclickOK.
Hideimage
INTHISARTICLE
Introduction
Painlessproxies
Developanddebugthe
server
Createthe
DataSnap/RESTVCLform
server
Unit1
Unit2
ServerMethods1
TesttheDataSnapserver
Addyourbusinesslogic
UseCreateConnection
fromDBXUtils.pas
Converttheserverto
ISAPI
Createnew
DataSnap/RESTISAPIdll
server
CopytheISAPIproject
filestoyourVCLproject
folder
Removegeneratedunit
refsfromIISproject
AddtheVCLprojectunits
toIISproject
UseMidasLibtoembed
MIDAS.DLLintoyour
application
TesttheISAPIversion
withIIS7.5
MakesureISAPIis
enabledinIIS
ConfiguretheIIS
virtualdirectory
Checkyourapplication
pooluseraccount
AddIISuser"write"
rightstotheproject
folder
Note(highlightedwiththeredboxinthescreenshotabove)thedescriptionavailableforeachitemin
theobjectgallerywhenyoueitherselectorhoveroveritwiththemouse.
ClickOKtostarttheDataSnapRESTapplicationwizard.
Configure
Authenticationforyour
virtualdirectory
Localdebuggingusing
theIDE
Updatingyourdll
DeploytoIIS6
Createtheapplication
directory
AddIISuser"write"
rights
AllowISAPImodules
ConfiguretheIISvirtual
directory
PutthedbExpressDLLs
inthesystempath
Testwithlocalhost
http://edn.embarcadero.com/article/40873
1/12
02/09/2016
Building,debugging,anddeployingaDataSnap/RESTISAPIdll
Hideimage
Launchtheapp!
RATING
DownloadTrial
BuyNow
DownloadDelphi10
now!
ThestandaloneVCLapplicationoptionisthemostconvenientoptionforinteractivelytestinganddebugging
yourapplication,becauseyoucanstartandstoptheDataSnapserveratanytime,andopenabrowserpagedirectly
fromthemainformtotestyourmethodswiththeJavascriptbasedserverexplorer.(Moreonthislater.)Thisisthe
optionwe'llusefornow.
IfyouwanttodoautomatedtestingofyourDataSnapserver,thestandaloneconsoleapplicationisagood
option,becauseyoucanstartandstoptheapplicationeasilyfromanautomationsystem.
Whenyou'rereadytodeployyourDataSnapservertoaproductionenvironmentrunningIIS,youcanusethe
ISAPIdynamiclinklibraryoption.Youcouldalsousethisifyou'refamiliarwithdebuggingISAPIdllsorhave
utilitiesfordebuggingISAPIdlls.We'llusethisoptionlater,whenwe'regettingreadytodeploytoourproduction
server.
ClickNexttogotothenextstep.
Hideimage
Webinarsondemand!
Delphi
19 mil curtidas
Curtir Pgina
Moresocialmediachoices:
DelphionGoogle+
@RADToolsonTwitter
Thewizarddefaultstousingport8080.YoucanclickTest Porttoverifytheportisavailable,orplaytheDataSnap
versionof"Ifeellucky!"byclickingtheFind Open Portbuttonandaportwillbeassignedtoyourapplication.
ClickNexttogotothenextstep.
http://edn.embarcadero.com/article/40873
2/12
02/09/2016
Building,debugging,anddeployingaDataSnap/RESTISAPIdll
Hideimage
Bydefault,ServerMethodsClassandSampleMethodsareselected.Leavethemselected.Thesamplemethods
aretrivialtoremovelater,andareveryconvenientfortestingthebasicinvocationsupportofyourDataSnapserver.
Unlessyouwanttoimplementyourauthenticationmethodsrightaway,leavethoseoptionsdeselectedfornow.
AuthenticationandAuthorizationisveryeasytoaddlateron.YoucanreadMatDelong'sblogpostformore
informationonAuth/Auth.
ClickNexttogotothenextstep.
Hideimage
Eachoptionintheradiogroupshownintheabovescreenshotprovidesadditivefeaturestotheoptionlistedabove
it.
TheTComponentancestortypeisthelightestweightancestorforyourDataSnapserver.Ifyoudon'twanta
designsurfacefornonvisualcomponents(manypeoplelikeusingtheIDEdesigntimesupportfordatabase
components,etc.)youcanselectthisoption.
Forthisserver,I'mselectingTDataModuleasmyancestor,becauseIhaveadesignsurfaceavailableshouldI
choosetouseit.
IfyouwanttoprovidecompatibilitywiththecallinginterfaceforanexistingDataSnaporMIDASserver,youcan
selectTDSServerModule,whichwillalsoimplementIAppServerinadditiontothesamedesignsurfaceyou'dhave
withTDataModule.
ClickNexttogotothenextstep.
http://edn.embarcadero.com/article/40873
3/12
02/09/2016
Building,debugging,anddeployingaDataSnap/RESTISAPIdll
Hideimage
Choosetheprojectlocationyouwant,andclickFinishtocompletethewizard.Youshouldseesomethingsimilarto
thefollowingintheIDE:
Hideimage
Unit1
Unit1containsyourserverformandtheeventsforstartingandstoppingyourDataSnapserver,andopeningthe
browsertotheDataSnapserverhomepage.
Note:TheOpenBrowserbuttonwillautomaticallystarttheDataSnapserverifit'snotstartedalready.
Hideimage
Unit2
Unit2containsalltheDataSnapspecificlogicforyourstandalone(Indybased)webserver.Inthestructurepane,
youcanseethatitregisterssupportforyourtemplatesfolder,andmimetypesupportforcss,javascript,andpng
images.ItalsoprovidestheRESTandJSONsupportyourserverwilluse.
ServerMethods1
InServerMethods1,youdon'thavetoworryaboutthewebserverormarshallingtheRPC(remoteprocedurecalls)
supportedbytheDataSnapserver,becausethat'shandledintheotherunits.Youcanfocusinsteadonyourcustom
logic.
Here'stheinitialclassgeneratedbythewizard.Thepublicorpublishedmethodsandclassescontainedbetween
{$METHODINFOON}and{$METHODINFOOFF}canbemarshaledwithDataSnap.
unitServerMethodsUnit1
interface
uses
SysUtils,Classes,DSServer
type
{$METHODINFOON}
TServerMethods1=class(TDataModule)
private
{Privatedeclarations}
public
{Publicdeclarations}
functionEchoString(Value:string):string
functionReverseString(Value:string):string
end
{$METHODINFOOFF}
implementation
http://edn.embarcadero.com/article/40873
4/12
02/09/2016
Building,debugging,anddeployingaDataSnap/RESTISAPIdll
{$R*.dfm}
usesStrUtils
functionTServerMethods1.EchoString(Value:string):string
begin
Result:=Value
end
functionTServerMethods1.ReverseString(Value:string):string
begin
Result:=StrUtils.ReverseString(Value)
end
end.
Asyoucanseefromthecode,EchoStringandReverseStringarealreadyimplementedandreadytouse.Solet'stest
theapplication.
TesttheDataSnapserver
Testingtheapplicationisprettysimple.Wejustrunitwithorwithoutdebuggingsupport.
Hideimage
ClicktheOpen Browserbutton.ThiswillopenthedefaultbrowsertotheDataSnapserverhomepage.Thefirsttime
yourunyourDataSnapserverbyclickingStartorOpenBrowser,youmayseeaWindowsSecurityAlert.Hide
image
YoucanclickAllow AccesstofinishloadingyourDataSnapserverapplication.
Thebrowserpagewilllooksomethinglikethis:
http://edn.embarcadero.com/article/40873
5/12
02/09/2016
Building,debugging,anddeployingaDataSnap/RESTISAPIdll
Hideimage
YoucanclickReverseStringtoimmediatelyverifyyourDataSnapserverisrunning,anditwillupdatethetextbox
tosay"CBA"instead.
AmoreeffectivewayoftestingistousetheJavaScriptbasedserverfunctioninvoker(Itoldyouwe'dgetbackto
thislater!)toexaminetheavailablemethodsonyourDataSnapserver.
TheserverfunctioninvokeroptionisautomaticallyavailablewhenyourunyourDataSnap/RESTserveronlocalhost.
Thefollowingfunctionenablesit:
functionTWebModule2.AllowServerFunctionInvoker:Boolean
begin
Result:=(Request.RemoteAddr='127.0.0.1')or
(Request.RemoteAddr='0:0:0:0:0:0:0:1')or(Request.RemoteAddr='::1')
end
ClickingtheServerFunctionslinkonthehomepageopenstheserverfunctioninvokerinanewbrowserwindow.
Hideimage
Astheplussignindicates,youcanexpandboththeDSAdmin(DataSnapadmin)interfaceandthe
TServerMethods1interface.DSAdminhasmanymethodsavailabletoit,whichwillhavetobecoveredelsewhere.
Let'sexpandTServerMethods1andinvokeReverseString.
Hideimage
Clicktoseefullsizedimage
Nowthatwe'veusedtheautomatictestinginterfaceavailablewhenyou'rerunningtheDataSnapserveron
localhost,wecanstartaddingour"business"logic.
Addyourbusinesslogic
BeneaththedeclarationforReverseString,we'lladdthefollowingdeclaration:
functionAdd(x,y:integer):integer
TheeditorwillcreatetheimplementationstubforusifweuseClasscompletionbypressingCtrl+Shift+C,andour
cursorwillbepositionedinthebodyofthemethod.
functionTServerMethods1.Add(x,y:integer):integer
begin
http://edn.embarcadero.com/article/40873
6/12
02/09/2016
Building,debugging,anddeployingaDataSnap/RESTISAPIdll
end
Makethecodereturntheadditionofxandylikeso:
functionTServerMethods1.Add(x,y:integer):integer
begin
Result:=x+y
end
Stopandreruntheserver(withdebugging)torebuildit,andclicktheStartorOpen Browserbutton.
Afterstoppingandrestartingtheserver,ifyoutrytoreuseyourexistingserverinvokerwebpage,you'llseeanerror
likethefollowing:
Hideimage
YoucanrefreshthepagetoestablishasessionwiththenewDataSnapserverinstance.Yournewmethodwillalso
beavailableaftertherefreshorreload.
We'llsetabreakpointonournewAddmethodintheIDE,andexecutethecalltoAddfromtheinvokerwebpage.
Hideimage
TheIDEwillstoponthebreakpoint,andyoucanseethatxandyhavethevaluesspecified(5and10)onthe
browserpage.
WecontinuerunningtheDataSnapserver,andseetheresultinthebrowser:
Hideimage
UseCreateConnectionfromDBXUtils.pas
Ifyou'regoingtousedbExpressforyourISAPIdll,youmaywanttouseCreateConnectiontoopenyourdatabase
connections.
IntheRADStudiodemosprojectonSourceforge,thereisabranchforRADStudioXE.Underneaththatbranch
intheDelphi/Database/dbExpress/Utilsfolder,youwillfindasetofdbExpressutilityfunctionsheavilyusedbythe
EDNteamintheunitcalledDBXUtils.
CreateConnectionisautilityfunctionthatcreatesandopensaTSQLConnectionfromasimplecall.Youpassinthe
nameoftheconnection,andCreateConnectionfirstlooksinthedirectorycontainingyourdllorexeforan.inifile.If
theinifileisfound,asectionnamematchingyourpassedinparameterisusedforthedefinitionsofthedatabase
connection.It'snearlyidenticaltowhatmightbeinyourdbxconnections.inifile,butit'saconvenientlocal
connectiondefinitionthatmakesitabiteasiertodeployyourapplicationtoaproductionserver.
Here'sanexamplelocalapplicationINIfileforyourdbExpressconnection.Database,UserName,andPasswordare
required.DriverdefaultstoINTERBASE.Anyextrapropertiescanbesetinthe[*Extra]sectionforthedatabase
name:
[Employee]
Database=localhost:d:\ibdata\employee.ib
UserName=sysdba
Password=masterkey
Driver=INTERBASE
[EmployeeExtra]
Dialect=3
Here'stherelevantcode:
///<summary>
///Createandopena<c>TSQLConnection</c>withthespecifiedconnectionname
///tryingtoopenita)firstbytryingapplication.inithenb)by
///readingdbxconnections.iniifa)fails
///</summary>
///<paramname="AName">Nameofconnectiontoopen</param>
///<paramname="AIniFile">Optional.NameoftheInifile.
///Defaultstotheapplicationname+'.ini'
///<remarks>
///Theobjectreturnedwillneedtobefreedinthecaller
///</remarks>
functionCreateConnection(constAName:string
AIniFile:string=''):TSQLConnection
var
error1:string
begin
try
ifFileExists(ModuleIniFile)then
Result:=CreateConnectionIni(AName)
http://edn.embarcadero.com/article/40873
7/12
02/09/2016
Building,debugging,anddeployingaDataSnap/RESTISAPIdll
else
begin
Result:=nil
error1:=Format(StrIniWasNotFound,[ModuleIniFile])
end
except
onE:Exceptiondo
begin
error1:=E.Message
Result:=nil
end
end
ifnotAssigned(Result)then
try
Result:=CreateConnectionName(AName)
except
onE:Exceptiondo
begin
raiseException.CreateFmt(StrCouldNotOpenConnection,
[AName,error1,E.Message])
end
end
end
Ifthisinifileisn'tfoundorCreateConnectionIniraisesanexception,theroutineattemptstoopentheconnection
usingthedefaultbehaviorofreferringtodbxconnections.inifortheconnectiondefinition(viathecallto
CreateConnectionName).
Itisalsoeasytomanagethelifetimeofyourdatabaseconnectionwitheachinstanceofyourservermethods
module.Forexample,here'stheinterface:
Private
FConnection:TSQLConnection
functionGetConnection:TSQLConnection
public
propertyConnection:TSQLConnectionreadGetConnection
destructorDestroyoverride
Andhere'stheimplementation:
functionTRoleCall.GetConnection:TSQLConnection
begin
ifnotAssigned(FConnection)then
FConnection:=CreateConnection(SConnectionName)
ifFConnection.ConnectionState<>csStateOpenthen
FConnection.Open
Result:=FConnection
end
destructorTRoleCall.Destroy
begin
ifAssigned(FConnection)then
begin
FConnection.Close
FreeAndNil(FConnection)
end
inherited
end
CreateConnectionbecomesparticularlyvaluablewhenusinganISAPIdll,becausethedbExpressruntimelooksfor
thedbxconnections.inifileinthehostenvironment'sinstalldirectory(whereIISisinstalled)ratherthaninthe
directorywhereyoudeployedyourDataSnapdll.Thisbehaviorshouldchangeinalaterversiontolookinyour
module'slocalfolderfirst(usinglogicsimilartotheDBXUtilsModuleIniFileroutine)forlocatingyourapplication
.inifile.
ConverttheservertoISAPI
WhentheDataSnapserverworksasdesired,bothUnit2(orwhateveritsfinalnameis)andyourservermethods
unitinanISAPIversionoftheDataSnapserver.ThefollowingstepsdescribehowtodothisusingtheDataSnap
serverwizardagain.
CreatenewDataSnap/RESTISAPIdllserver
StarttheDataSnapRESTapplicationwizardasdescribedaboveandrunitagain.
Hideimage
SelectISAPIdynamiclinklibraryandclickNextallthewaythroughtothelaststep.We'resimplygoingto
discardallthefilesitcreatesexceptfortheprojectfiles,soitdoesn'tmatterwhichoptionsyouselect.
http://edn.embarcadero.com/article/40873
8/12
02/09/2016
Building,debugging,anddeployingaDataSnap/RESTISAPIdll
Hideimage
Selectalocation"near"yourotherprojectsoit'seasytocopytheprojectfilesover,andclickFinishtocompletethe
wizard.
Saveallfiles,namingtheprojectsomethingeasytorecognize.UseFile|Closeallandclosetheproject.
CopytheISAPIprojectfilestoyourVCLprojectfolder
Inthisexample,thenewprojectiscalledDSIsapi.dllandthetheDataSnapVCLformprojectisProject8.exe.
Fromyourfilemanager,copyDSIsapi.dprandDSIsapi.dprojtothesamefolderasyourDataSnapVCLform
application.
ReopenyourDataSnapVCLproject.RightclickonProjectGroup1intheprojectmanager,andselectAddExisting
Project.
Hideimage
SelectyourISAPIprojecttoopen.
Ifyoudidn'tcopytheproject.RESfileover,you'llgetawarningthatitwasrecreated.That'sok.
Hideimage
Afterthat,theprojectwillappearintheprojectgroup.
Hideimage
RemovegeneratedunitrefsfromIISproject
YoucanremovethereferencestoServerMethodsUnit2andUnit3byselectingbothofthefilesintheproject
managerandselectingRemovefromProject.
Hideimage
AddtheVCLprojectunitstoIISproject
SelectServerMethodsUnit1andUnit2fromtheVCLprojectanddraganddropthemontoDSIsapi.DLL.Thiswill
bringupadialog.
Hideimage
AnswerYesandthefileswillbepartoftheproject.
UseMidasLibtoembedMIDAS.DLLintoyourapplication
Ifyou'regoingtobeusingdatasetsinyourDataSnapapplication,IrecommendusingtheMidasLibunitinyour
projectsourcecode.Thissimplifiesthedeploymentofyourapplicationbecauseyoudon'thavetodeployorregister
MIDAS.DLL.
Gototheprojectmanager,rightclickontheproject,andselectView Source.
Hideimage
(YoucanalsoclickontheprojectintheprojectmanagerandpressCtrl+V,whichisanoverriddenkeystrokeforthe
projectmanagerthatviewsthesourceoftheselectedproject.)
Thiswilldisplayyourprojectsourcecode.JustaddMidasLibtotheusesclause,saveandrebuildtheproject.
libraryDSIsapi
{$R*.dres}
uses
ActiveX,
ComObj,
WebBroker,
ISAPIApp,
ISAPIThreadPool,
DBXCommon,
DSService,
http://edn.embarcadero.com/article/40873
9/12
02/09/2016
Building,debugging,anddeployingaDataSnap/RESTISAPIdll
MidasLib,
Unit2in'Unit2.pas'{WebModule2:TWebModule},
ServerMethodsUnit1in'ServerMethodsUnit1.pas'{ServerMethods1:TDataModule}
TesttheISAPIversionwithIIS7.5
CompiletheDLL.Nowthatitexists,we'rereadytoconfigureIIStorunyourDataSnapserver.
Manyofthestepscoveredhereareonlyrequiredonetime,buttheyarenecessary.Evenifthey'reset,it'sgoodto
havethemasreviewpointsfortroubleshooting.
MakesureISAPIisenabledinIIS
ForIIS7.5,youcanstarttheIISmanager,selectthemachinename,andenter"isapi"inthefilterbox.Thiswill
displaytheISAPIandCGIRestrictionsfeature.
Hideimage
DoubleclickonthefeaturenameorclickOpenFeatureintheActionslist.SelectEditFeatureSettingsfromthe
Actionslist.Hideimage
CheckAllowunspecifiedISAPImodulesandclickOK.
ConfiguretheIISvirtualdirectory
RightmouseclickonDefaultWebSiteandselectAddVirtualDirectory.
Hideimage
EntertheAlias(asimplenamewithnospecialcharacters)andputinthephysicalpathtotheDLL.
Hideimage
ClickOK,andrightmouseclickonthevirtualdirectory.SelectConverttoapplication.
Hideimage
Thefollowingdialogisdisplayed.
Hideimage
Thedefaultvaluesshouldbefine,soclickOK.
Checkyourapplicationpooluseraccount
SecuritybehaviorshavechangedfromIIS6toIIS7andup.MoreinformationaboutIIS7.5'saccount
implementationisavailableonthelearn.iis.netwebsite.
AccountpreferencescanbeverifiedtheIISapplicationpoolsusingtheIIS7.5managementinterface.
SelectApplicationPools,thenselectDefaultAppPoolandclickAdvanced SettingsintheActionslist.
Hideimage
OntheAdvancedSettingsdialog,selecttheProcessModelIdentityandclicktheellipses.
Hideimage
SelectApplicationPoolIdentityinthebuiltinaccountandclickOK.
Note:ifyou'rerunningoperatingsystemis64bit,alsosetEnable32bitApplicationstoTrueunderthe
(General)tabsoyour32bitdllwillrun.
Hideimage
ClickOKtoclosetheAdvancedSettingsdialogalso.
Nowthatwe'veensuredtheappropriateaccountisusedfortheapplicationpool,wecanconfiguretheappropriate
rightsfortheDataSnapproject'sfolder.
AddIISuser"write"rightstotheprojectfolder
Therearetwowaystomodifytherightsfortheappropriateaccountonyourcomputer.Theabilitytowritefilesis
requiredbecauseofthebuiltinlogicyourDataSnapRESTserverhasforautomaticallyupdatingtheJavaScriptproxy
fileforyourcustomlogic.Thefollowingroutineshowshowitworks.
procedureTWebModule2.WebFileDispatcher1BeforeDispatch(Sender:TObject
constAFileName:stringRequest:TWebRequestResponse:TWebResponse
varHandled:Boolean)
var
D1,D2:TDateTime
begin
Handled:=False
ifSameFileName(ExtractFileName(AFileName),'serverfunctions.js')then
ifFileAge(AFileName,D1)andFileAge(WebApplicationFileName,D2)and(D1<D2)then
begin
DSProxyGenerator1.TargetDirectory:=ExtractFilePath(AFileName)
DSProxyGenerator1.TargetUnitName:=ExtractFileName(AFileName)
DSProxyGenerator1.Write
end
end
Thankstothisroutine,youcanbeassuredthattheserverfunctionsjavascriptinterfaceisalwayscurrentwiththe
logicofyourapplication.Sinceyouareincontrolofthesourcecode,youcanmodifythisbehaviorifyouwantbut
thisroutinerequireswriteaccesstothedirectorycontainingyourDLL,whichiswhywe'reabouttomodifyrights.
Ifyouwanttoavoidgrantingwriteaccess,youcanmodifyyourbuildanddeployprocess(particularlywiththe
FinalBuilderbundledwithRADStudioXE)togenerateyourJavascriptfileduringthebuildprocessandusean$IFDEF
forproductionversusdebugcodesotheserveronlygeneratestheJavascriptfilelocallywhenrunningyour
applicationinthedebugenvironment.
Note:AsBobSwartpointedout,thejsfolderistheonlyfolderinyourprojectthatneedswriteaccess.
Bobhassomeothergoodfeedbackonhisforumpostaswell.
WithinIIS7.5'smanagementUI
WithIIS7.5,youcangodirectlytoyourvirtualfolderandclicktheEditPermissionsactiontodisplaythe
propertiesdialogforyourfolder.Ifyou'reusingaversionofIISmanagerthathastheEditPermissionsaction,it's
probablymoreconvenienttousethatforconfiguringrightstoyourvirtualdirectory.
However,sincedeployingtoIIS6willalsobecovered,thestepsforsettingaccessrightswillbedonewithWindows
Explorer.
WithWindowsExplorer
YoucanalsosetsecurityoptionsfromtheprojectfolderinWindowsexplorer.ThescreenshotbelowisfromWindows
7.TheWindowsServer2003dialoglooksalittledifferent,butthestepsarebasicallythesame.
Gotoyourprojectfolder,selectthejsfolderfromit,rightmouseclick,andselectPropertiestobringupthe
Propertiesdialog.
http://edn.embarcadero.com/article/40873
10/12
02/09/2016
Building,debugging,anddeployingaDataSnap/RESTISAPIdll
Hideimage
SelecttheSecuritytabandclickEdit,whichbringsupthepermissionsdialog.
Hideimage
ClickAddtodisplaythedialogforaddinganaccount.Putin"IISAppPool\DefaultAppPool"andclickCheck Names.
Hideimage
ItshouldchangetosayDefaultAppPool.
Hideimage
ClickOKtoclosethedialog.
SelectDefaultAppPoolonthepermissionsdialog,andcheckAllowfortheWritepermission.
Hideimage
CheckAllowfortheWritepermission,andclickOK.
ClickOKonthepropertiesdialogtoacceptthepermissionchangesandclosethedialog.
ConfigureAuthenticationforyourvirtualdirectory
Thevirtualdirectoryalsoneedstobeconfiguredtousetheapplicationpoolidentityforitsauthentication.
SelectyourvirtualdirectoryinIISmanager,selectAuthentication,andeitherdoubleclickonitorclickOpen
FeatureintheActionslist.
Hideimage
SelectAnonymousAuthenticationandclicktheEditaction.
Hideimage
SelectApplicationpoolidentityandclickOK.
LocaldebuggingusingtheIDE
OpenthebrowsertotheURLforyourDataSnapserver,anditshouldbeworkingnow.Ifyou'vemissedastep,you'll
seesomethinglikethis:
Hideimage
Ifyouhaveitright,you'llseesomethinglikethis:
Hideimage
Attachtoprocessfordebugging
WecanuseAttachtoProcessintheIDEtodebugthisDLLnow.Setabreakpointonthelineofcodeyouwantto
debug(thecalculationofAddisusedinthescreenshotbelow),andselectRun|AttachtoProcesstohookinto
w3wp.exe,whichistheIISprocess.
Hideimage
Thisdisplaysthetheattachtoprocessdialog.Checktheincludesystemprocessescheckboxandlocatew3wp.exe.
Hideimage
ClickAttach,andyourIDEwillswitchtodebugmodeand(bydefault)pauseattheCPUview.Hitruntocontinue.
Note:ifyoudon'tseew3wp.exe,itmayhaveshutitselfdownafterbeingidle.Refreshthebrowser
pageforyourDataSnapapplication,clicktheRefreshbuttononthisdialog,anditshouldbevisible
again.Asyoucanseefromthepathofw3wp.exeabove,I'musing64bitIIS.
GototheserverfunctionspagewiththebrowserandcallAddwiththevaluesyouwanttoadd.
Hideimage
TheIDEwillstoponyourbreakpoint.
Hideimage
ClickruntocontinueandreturntheresulttoyourJavascriptcaller.
Hideimage
Updatingyourdll
IIS"holdson"totheDLLonceit'sbeeninvoked,soifchangesarerequired,IISwillneedtobetoldtounloadthe
DLL.Otherwise,rebuildingthedllwillfailbecausethefileisalreadyinuse.
ThereareafewoptionstoupdatetheDLL.
UseIISmanagertorecycletheapplicationpoolusedbyyourDataSnapserver.ThiswillunloadyourDLLand
itcanberebuilt.
Hideimage
ConfiguretheapplicationpooltoquicklyrecyclebyclickingontheRecyclingactionshownabove.
Hideimage
UsethecommandlinetostopandstarttheWorldWideWebpublishingservice
d:\>netstopw3svc
TheWorldWideWebPublishingServiceserviceisstopping.
TheWorldWideWebPublishingServiceservicewasstoppedsuccessfully.
d:\>netstartw3svc
TheWorldWideWebPublishingServiceserviceisstarting.
TheWorldWideWebPublishingServiceservicewasstartedsuccessfully.
UsetheservicesdialogtorestarttheWorldWideWebpublishingservice
Hideimage
Whenyou'redonedebuggingtheapplication,you'rereadytodeploytotheproductionenvironment!
DeploytoIIS6
OurproductionserversarestillprimarilyWindowsServer2003withIIS6,sothissectioncoverswhat'sinvolvedin
configuringtheDataSnapISAPIdllIIS6.
Createtheapplicationdirectory
Weuseastandardfolder(\apps)tohostallourapplications.I'llcreated:\apps\datasnapontheserver,andcopy
thedllfile,andthecss,images,js,andtemplatesdirectoriesthere.
Hideimage
http://edn.embarcadero.com/article/40873
11/12
02/09/2016
Building,debugging,anddeployingaDataSnap/RESTISAPIdll
AddIISuser"write"rights
ForIIS6,theaccountISUR_<MACHINENAME>shouldbeusedfortheDataSnapapplication.Forexample,ifthe
machineisnamedMYSERVER,theuserwouldbeIUSR_MYSERVER.Thestepsarenearlyidenticaltothoseoutlined
above.
AllowISAPImodules
BringupIISmanager6,selectWebServiceExtensions,thenAllUnknownISAPIExtensions,andclickAllow.
Hideimage
SayYestothewarningaboutthesecurityrisk.
ConfiguretheIISvirtualdirectory
Selecttheappropriatewebsite,rightmouseclickandselectNew|VirtualDirectory.
Hideimage
ThisdisplaystheVirtualDirectorywizard.
Hideimage
ClickNexttogotothenextstep.
Hideimage
ProvidethedirectoryaliasandclickNext.
Hideimage
PutinthepathforthedirectoryandclickNext.
Hideimage
CheckRunscriptsandExecuteandclickNext.
Hideimage
ClickFinishtocompletethewizard.
PutthedbExpressDLLsinthesystempath
Ifyou'reusingdbExpressforyourDataSnapapplication,you'llneedtoputwhateverdbExpressDLLsyouuseinto
yoursystempath.Forexample,InterBaserequiresdbxint.dlltobeavailableinthesystempath.
Testwithlocalhost
OpenthebrowserpageonyourlocalmachineandmakesuretheDataSnapserverworkslikeitdidwhenyouwere
testingit.
Launchtheapp!
Wheneverythingisworkingasexpected,you'redone!
Ofcourse,nowthattheDataSnapserverisconfigured,youcanusethetechniquescoveredheretoquicklydeploy
updatestoit.
IlookforwardtoseeingtheDataSnapimplementationspeoplecomeupwith.
Enjoy!
LATESTCOMMENTS
Movemouseovercommenttoseethefulltext
ReplyPostedbyCravenWeaselonAug292013
Building,debugging,anddeployingaDataSnap/RESTISAPIdll
hi,what'sthebestpracticeifweneedtodrasticallychangetheserversideDLLbutwewant
tomaintainthecompatibilitywiththeolderclientDLL?Perhaps,keeptheolderinterface
intactandadd...
ReplyPostedbyCravenWeaselonAug292013
Building,debugging,anddeployingaDataSnap/RESTISAPIdll
hi,what'sthebestpracticeifweneedtodrasticallychangetheserversideDLLbutwewant
tomaintainthecompatibilitywiththeolderclientDLL?Perhaps,keeptheolderinterface
intactandadd...
ServerResponsefrom:ETNASC03
Copyright19942013EmbarcaderoTechnologies,Inc.Allrightsreserved.SiteMap
http://edn.embarcadero.com/article/40873
12/12