Tải bản đầy đủ - 0 (trang)
Chapter 24. How to Integrate URL Access

Chapter 24. How to Integrate URL Access

Tải bản đầy đủ - 0trang

Chapter24.HowtoIntegrateURLAccess

InThisChapter

HowtoUseURLAccessinanApplication

URLAccessisoneoftheeasiestmethodsavailableto

developerstoincorporateSSRSfunctionalityintocustom

applications.URLAccessisdesignedtoprovidethehighestlevel

ofperformancewhenusedtoviewandnavigatereports.URL

Accessachievesthisperformancebybypassingthewebservice

interfaceandcommunicatingdirectlywiththeReportServer.On

theotherhand,becauseURLAccessdoesnotaccesstheweb

service,URLAccess'functionalityislimitedtoviewingand

navigatingreports.



Note

SSRSprogrammerswhohaveimplementedcustom

securityextensions(Chapter26,"WritingCustom

ReportingServicesExtensions,"discussessome

detailsofcustomextensions)shouldknowthat

SSRSstillchecksforpermissionsandavalid

authorizationcookiebeforeallowingURLAccesstoa

report.Inapracticalsense,thismeansthatbefore

reportscanbeaccessedthroughtheURL,acall

mustbemadetotheLogonUsermethodintheSSRS

webservice,andtheresultingcookiemustbe

relayedtotheclient'sbrowser.



URLAccessacceptsvariousparametersthataffectthereport's

rendering.Forexample,someparametersaffecttheframingof

areportandspecifywhetherthetoolbaranddocumentmapare

displayed.Otherparametersspecifyareport'soutputformat

(HTML,IMAGE,EXCEL,CSV,PDF,XML).Asetofcommonlyused

parametersisdiscussedfurtherinthischapter.

YoucanuseURLAccesstorenderareportinabrowserby

typingtheURLAccesscommandintheaddressbarorembed

URLAccessintoapplicationsthatyoudevelop.

Let'sstartfromasimpleexampleofaURLAccess.Oneofthe

methodstodiscoverwhatispossiblethroughURLAccessisto

actuallynavigatethroughtheReportViewer(ReportServerweb

UI)andseehowitworks.Let'sstartat

http://localhost/ReportServer(genericsyntaxwouldbe

http:///ReportServer,whereisaNetBIOSname,

fullyqualifieddomainname,oranIPaddressofaserveron

whichReportServerisinstalled).WhenadeveloperusesReport

Designertodeployareport,thenameoftheprojectbecomes

thenameofthefolderonaReportServer.



Note

Ifyoudeployasolutionthatcontainsareport,the

report'spathwouldbe/{SolutionName}/{Project

Name}/{ReportName}.Ifyoudeployaproject(right-click

ontheprojectandselectDeployfromtheshortcut

menu),thereport'spathwouldbe/{Project

Name}/{ReportName}



Forexample,ifyoucreateaprojectwiththenameGeneric,

ReportDesignercreatesaGenericfolder.Whenyounavigateto

theGenericfolder,theaddresschangesto:



http://localhost/ReportServer?/Generic&rs:Command=ListChildren.

AsitcanbeinferredfromCommand=ListChildren,thiscommand

rendersalistofchildren,suchasreports,datasources,orany

otheritemslocatedintheGenericfolder.

YoudonothavetoURLencodeaURLAccessstringpassedtoa

browser.Browsersshouldautomaticallyencodeit.Themost

commonencodingisthespaceisreplacedwith"+"(plussign)

oranescapesequence"%20","/"(slash)isreplacedwithan

escapesequence"%2f",and";"semicoloninanyportionofthe

stringisreplacedwithanescapesequence"%3A".

URLAccesscommandshavecorrespondingcallsinthe

ReportingServiceswebservice.Thiscaseisnoexceptionthe

URLAccesscommandCommand=ListChildrencorrespondstothe

ListChildren()methodcalloftheSSRSwebservice.Whenauser

clicksononeofthereports(let'suseSimpleReportasaname

ofthereport)intheSSRSwebinterface,youseethefollowing

URLaddressinabrowser:

http://localhost/ReportServer/Pages/ReportViewer.aspx?

%2fGeneric%2fSimpleReport&rs:Command=Render.

Renderperhapsisoneofthemostfrequentlyusedcommands



andalsohasacorrespondingwebmethodcallintheSSRSweb

servicecalledRender().Renderiscalledtogenerateastreamof

data(thisstreamisarenderedreport)intheformatspecified

byaparameter.Bydefault,abrowserreceivesanHTMLstream.

Whenappropriateforaparticularrendering,URLAccessuses

implicitdefaults.Forexample,bydefaultareportisrendered

withatoolbar.However,youdonotseeanythingmentioning

thetoolbarintheURLaddressofthebrowser.

URLAccessusesthefollowingsyntax

http[s]:///?/.

isaNetBIOSname,fullyqualifieddomainname



(FQDN),oranIPaddressofaserveronwhichReportServeris



installed.

isavirtualdirectorypathonwhichReportServeris



installed(bydefault,itisinstalledtotheReportServervirtual

directory).

canconsistsofarelativepathofanitem(reportor



otherresource)inrelationtotheSSRSvirtualdirectoryfollowed

byoneormoreparameterswiththesyntax

&prefix:parameter=value.ValidprefixvaluesareshowninTable

24.1andvalidparametersareshowninTable24.2.

Table24.1.ValidParameterPrefixes

Prefix



Purpose



Example



Noprefix



Treatsthisparameterasa

reportparameter.Topassa

nullvalueforaparameter,

use

ParameterName:isnull=true.

Note:Reportparameters

arecasesensitive.



&EmployeeID=123

&EmployeeID:isnull=true



rc



Denotesareportcontrol

parameter.Passesdevice

informationsettingsto

renderingextensions.In

thecaseofHTML(HTML

Viewer),itisreportframing

information.Note:rc

parametersarenotcase

sensitive.



&rc:DocMap=True&rc:doCmaP=true

&rc:Toolbar=True



rs



DenotesaReportServer

parameter.Passesa

parametertoSSRS.Note:

rsparametersarenotcase

sensitiveandallhave

counterpartfunctionsinthe

SSRSwebservice.



&rs:Command=Render



dsu



Specifiesausernamewith

whichtoaccessadata

source.



&dsu:MyDataSource=MyUser



dsp



Specifiesapasswordwith

whichtoaccessadata

source.Subjectto

limitationsandrisksof

securityexposures.

Basically,avoidusingit

wheneverpossible.



&dsp:MyDataSource=Password



Syntaxrequireseachprefixtobefollowedbyaparameter.

ReportparametersdonothaveprefixesandthisishowURL

Accessdeterminesthataparticularparametershouldbe

treatedasareportparameter.IfaURLAccesscommand

includesareportparameterthatdoesnotmatchanyofthe

parametersdefinedinthereport,SSRSreportsan

rsUnknownReportParametererror.

Ontheotherhand,SSRSisverylenientwithprefixed

parametersandusesadefaultvaluewhenthevaluespecifiedin

URLAccessisinvalid.Forexample,rs:Command=Reindeer(note

intentionalmisspellofRender)defaultstors:Command=Render.Thisis

amixedblessingasitmightnotbeimmediatelyclearwhya

certainURLAccesscommanddoesnotworkasyouwouldhave

expected.Howeverthishandlingminimizeserrors.

Commandisthemostfrequentlyusedparameterandisusedin



almostallURLAccesscommands.Command'sdetailsandother

availablers:parametersareshowninTable24.2.

Table24.2.rs:ReportServerParameters

rs:parameter Purpose



Command



Specifiesthecommandtobeexecuted.Validcommandsincludethefollowing:

propertiesofagivenshareddatasourceasXML.

Example:http://localhost/ReportServer?/Samples/Adventure+Works&rs:Command=

GetresourceContentsRendersafileinabrowser.Thisisusedtoshowimagesandothernonr

sourcefile.Example:

http://localhost/ReportServer?/Samples/flogo.jpg&rs:Command=GetResourceContents



itemsinafolder.Example:http://localhost/ReportServer?/Samples&rs:Command=ListCh

RenderRendersthespecifiedreport.Example:

http://localhost/ReportServer/Pages/ReportViewer.aspx/Samples/SimpleReport&rs:Comm

Format



Specifiestheformatinwhichtorenderareport.CommonvaluesincludeHTML3.2,HTML4

MHTML,IMAGE,EXCEL,CSV,PDF,XML,andNULL.



ParameterLanguage



ProvidesalanguageforparameterspassedinaURL.Thedefaultvalueisthebrowserlan

canbeaculturevalue,suchasen-usorde-de.Thisisespeciallyhelpfulforinternational

example,inEuropemostofthecountriesreversemonthanddaypositionascomparedw

States.



Snapshot



Rendersareportbasedonareporthistorysnapshot.



Table24.3showspartialsetofReportControlparameters.

ReportControlparameterstargetHTMLViewertoprovide

framingandthelookandfeelforarenderedreport.More

detailsonthistopicareavailableinSQLServerBooksOnline.

Table24.3.rc:ReportControlParameters

rc:parameter



Target

Rendering



BookmarkID



HTML



DirectsSSRStopositionthereport's

viewingfocustothebookmarkID.



DocMap



HTML



DirectsSSRStoshoworhidethereport

documentmap.Validvaluesaretrue

(default)orfalse.



DocMapID



HTML



DirectsSSRStopositionthereport's

viewingfocustothedocumentmapID.



DpiX,DpiY



IMAGE



Specifiesresolutionoftheoutputdevice

inx|ydirection.96isthedefault.



EndPage,StartPage



IMAGE,PDF



DirectsSSRStorenderlast|firstpageof

thereport.StartPage=0rendersallpages.



Value



Defaults:StartPage=1,EndPage=StartPage.

FieldDelimiter



CSV



SpecifiesURL-encodeddelimiterstring.

Thedefaultvalueisacomma(,).



FindString



HTML



Specifiesthetexttosearchforinthe

report.Thedefaultisanemptystring.



JavaScript



HTML,MHTM IndicatesJavaScriptsupportedinthe

renderedreport.



HTMLFragment



HTML



DirectsSSRStoreturnanHTMLfragment

insteadofafullHTMLdocument.An

HTMLfragmentincludesthereport

contentinaTABLEelementandomitsthe

HTMLandBODYelements.Thedefault

valueisfalse.Imagesforareportmust

beretrievedseparately.



LinkTarget



HTML



Specifiesatargetforhyperlinksinthe

report.LinkTarget=_blankopensanew

targetwindow.Othervalidtargetnames

includeaframename,_self,_parent,and

_top.



MarginTop,

MarginBottom,

MarginLeft,

MarginRight



IMAGE,PDF



Specifiesthemarginvalue,ininches,for

thereport.Itisanintegerordecimal

valuefollowedby"in"(forexample,1in).

Overridesthereport'soriginalsettings.



NoHeader



CSV



Indicateswhethertheheaderrowis

excludedfromtheoutput.Thedefault

valueisfalse.



OmitDocumentMap



EXCEL



Indicateswhethertoomitthedocument

mapforreportsthatsupportit.The

defaultvalueisfalse.



OmitFormulas



EXCEL



Indicateswhethertoomitformulasfrom

therenderedreport.Thedefaultvalueis

false.



OmitSchema



XML



Indicateswhethertoomittheschema

namefromtheXMLandtoomitanXML

schema.Thedefaultvalueisfalse.



OutputFormat



IMAGE



Specifiesreport'srenderinggraphical

format:BMP,EMF,GIF,JPEG,PNG,or

TIFF.



PageHeight,

PageWidth



IMAGE,PDF



Specifiesareport'spageheight/widthin

inches.Youmustincludeanintegeror

decimalvaluefollowedby"in".Thisvalue

overridesthereport'soriginalsettings.



Parameters



HTML



Showsorhidestheparametersareaof

thetoolbar.Parameters=true(default)

shows,Parameters=falsehidesthe

parametersarea.Parameters=Collapsed

hidestheparametersarea,butallowsthe

endusertotoggle.



Qualifier



CSV



Specifiesastringtoputaroundresults

thatcontainstringsequaltoFieldDelimiter

orRecordDelimiter.Iftheresultscontain

thequalifier,thequalifierisrepeated.The

Qualifiersettingmustbedifferentfrom

theFieldDelimiterandRecordDelimiter

settings.Thedefaultvalueisaquotation

mark(").



RecordDelimiter



CSV



Specifiesarecorddelimiterfortheendof

eachrecord.Thedefaultvalueis.



RemoveSpace



EXCEL



Directsanextensiontoeliminatesmall,

emptycellsfromtheresult.Avalidvalue

isanintegerordecimalvaluefollowedby

"in".Thedefaultvalueis0.125in.



Schema



XML



IndicatestoSSRStorendertheXML

schemadefinition(XSD)versusactual

XMLdata.Avalueoftrueindicatesthat

anXMLschemaisrendered.Thedefault

valueisfalse.



Section



HTML



Setsthereport'sviewingfocuspage.A

valuegreaterthanthenumberofpages

inthereportdisplaysthelastpage,

negativevaluesdisplaypage1.The

defaultvalue:1.



SimplePageHeaders



EXCEL



Indicateswhetherthepageheaderofthe

reportisrenderedtotheExcelpage



header.Avalueoffalseindicatesthatthe

pageheaderisrenderedtothefirstrow

oftheworksheet.Thedefaultvalueis

false.

SuppressLineBreaks



CSV



DirectsSSRStosuppresslinebreaks

fromtheoutput.Thedefaultvalueis

false.Ifthevalueistrue,the

FieldDelimiter,RecordDelimiter,and

Qualifiersettingscannotbeaspace

character.



Toolbar



HTML



Showsorhidesthetoolbar.Trueisthe

defaultvalue.Ifthevalueofthis

parameterisfalse,allremainingframing

options(exceptthedocumentmap)are

ignored.Thetoolbarisnotrendered

throughtheSOAPAPI,buttheToolbar

deviceinformationsettingaffectsresults

ofSOAPRendermethod.



XSLT



XML



SpecifiesthepathofanXSLTtoapplyto

theXMLoutput,forexample

/transforms/myxslt.TheXSLfilemustbea

publishedresourceontheReportServer

andyoumustaccessitthroughaReport

Serveritempath.Thistransformationis

appliedafteranyXSLTthatisspecifiedin

thereport.Whenused,theOmitSchema

settingisignored.



Zoom



HTML



Setsthereportzoomvalueasaninteger

percentage(rc:Zoom=100isthedefault)or

inrelationtothedisplayedpage(Page

Width(rc:Zoom=Page%20Width)orWholePage).

SupportedbyMicrosoftInternetExplorer

5.0andabove.







HowtoIntegrateURLAccessinanApplication

YoucanuseURLAccesstoincorporatereportsintoWindows

andwebapplications.

Severalmethodsareavailableforwebapplications.Themost

commonmethodistouseaURLAccesscommandstringasa

sourceorIFRAME.Inasimplecasescenario,thiscouldbean

HTMLfilewiththefollowingcode:




NAME="Frame1"SRC="http://localhost/ReportServer?/Samp



rc:Toolbar=false&rc:LinkTarget=Frame1",width=50%,





Theprecedingcodecreatesaframeonthepagethatislocated

intheupper-leftcornerandtakes50%ofthepage's"real

estate."Theframechangessizeasthebrowserwindow

changessize.Thepurposeof&rc:LinkTarget=Frame1istomake

surethatallofthereport'snavigationhappensinsideofthe

framecalledFrame1.

Youcanalsoaddalinktoareportinawebapplicationor

leveragetherc:HTMLFragmentparameter.

YoucanalsocallSSRSwebservicestoobtainneeded

informationandthenincorporatethereturnedstreamintothe

application'sHTMLstream.MoredetailsonworkingwithSSRS

webservicecanbefoundinChapter25,"HowtoUseReporting

ServicesWebServices."



URLAccessmethodsforwebapplicationsdescribedabove,such

asusingURLAccesscommandasasourceforIFRAME,havea

commondownside.TheyallusetheHTTPGETmethod,whichis

anequivalenttoaformsubmissionwhereMETHOD="GET".

ThereareacoupleofpotentialissueswiththeGETmethod.

First,itmightbeeasytohacktheURLstringandmakechanges

thatwouldallowamalicioususertopotentiallygetsome

proprietaryinformation.Areport'ssecurityrestrictsauser's

accesstoawholereport,butdoesnotpreventsomeonefrom

experimentingwiththeparametersofareport.

Bycontrast,whenyouuseURLAccesswithMETHOD="POST",you

canusehiddenfieldstopreventusersfromchanging

parametersusedinURLAccess.

Second,theURLGETrequest'slengthislimitedtothemaximum

allowedbythebrowser.Somebrowsershavethislimitaslowas

256characters.

InternetExplorer'smaximumURLrequestlengthis2,083

characters,with2,048maximumpathlength.Thislimitapplies

tobothGETandPOSTmethods.POST,however,isnotaffectedby

thislimitationforsubmittingname/valuepairs,becausethey

aretransferredintheheaderandnottheURL.

Formoredetails,seethefollowingMicrosoftKnowledgeBase

Article:http://support.microsoft.com/default.aspx?scid=kb;enus;208427.



Note

LimitsonthelengthofPOSTrequestscanalsobe

controlledbyregistrysettings.ForexampleinIIS

6.0,

HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\HTTP\Parameters



subkeysMaxFieldLengthandMaxRequestBytescontrolthe



Tài liệu bạn tìm kiếm đã sẵn sàng tải về

Chapter 24. How to Integrate URL Access

Tải bản đầy đủ ngay(0 tr)

×