Getting Started
Requirements
Setup
Authentication
About This Demo
File Descriptions
REST Protocol
SOAP Protocol
Using XSLT
Using XML Parsing
In order to run this demo application, you will need an EIT-enabled
profile. If you do not have one, please contact your EBSCO Publishing account
manager, who will create one for you.
You will also need a server environment in which to run this application.
Details of the requirements are below.
Back to Top
To run the PHP applications, copy the "simple_search" folder onto
your web server environment. If running on localhost, and the
folder was placed into the root Internet-accessible folder, it
should be available on:
http://localhost/simple_search/
In order for the search examples to access the EBSCOhost Web Services API, you must have an EIT enabled profile. If you have an EIT-enabled profile, you may enter your details in the 'profile.php' source code, which is found in the "simple_search" folder.
Your EIT profile should be in the format:"customerID.groupID.profileID"
Where customerID is your Customer ID, groupID is your Group ID, and
profileID is the EIT profile.
If your profile is "NS180003", and your password
is "helloworld", your "profile.php" file should look as follows:
$profile = "NS180003"; $password = "helloworld";
This demo application highlights the different methods of retrieving and processing data from the EBSCOhost Web Service API. There are three different "packages" in this demo:
This example uses REST to connect to the EBSCOhost Web Service, and then parses the XML and outputs the results to the screen.
This example uses REST to connect to the EBSCOhost Web Service, and then uses XSLT to render the XML output into HTML.
This example uses SOAP to connect to the EBSCOhost Web Service, and then uses XSLT to render the XML output into HTML.
'
Each of these packages provides an almost identical search interface, but
the backends are different.
Back to Top
Two examples in this demo make use of the REST protocol. They request XML data
from EBSCOhost's Web Service API. This XML data is then rendered into HTML using
XSLT.
The call to the web service is done using HTTP get. This is an example call
and response:
http://eit.ebscohost.com/Services/SearchService.asmx/Info?prof=custid.groupid.profile&pwd=passwordReturn:
<?xml version="1.0"?> <info xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <dbInfo xmlns="http://epnet.com/webservices/SearchService/Response/2007/07/"> <db shortName="f5h" longName="MasterFILE Premier"> <sortOptions> <sort name="Date Descending" id="date" /> <sort name="Date Ascending" id="date2" /> </sortOptions> <dbTags> <dbTag name="TX" description="All Text" /> <dbTag name="AU" description="Author" /> <dbTag name="TI" description="Title" /> <dbTag name="AN" description="Accession Number" /> </dbTags> <dbIndices> <dbIndex name="ZA" description="Author" /> <dbIndex name="ZT" description="Document Type" /> <dbIndex name="ZD" description="Entry Date" /> </dbIndices> <authorityInfo> <db xsi:type="DatabaseWithAuth" shortName="f5hjnh" longName="MasterFILE Premier -- Publications"> <sortOptions /> <dbTags> <dbTag name="SU" description="By Title Subject & Description" /> <dbTag name="OC" description="Country of Origin" /> </dbTags> <dbIndices> <dbIndex name="ZO" description="Company" /> <dbIndex name="ZY" description="Country" /> </dbIndices> <dbFormats> <dbFormat name="list" description="list" /> <dbFormat name="detailed" description="detailed" /> </dbFormats> </db> </authorityInfo> </db> </dbInfo> </info>
Note: the database information above has been shortened and is not valid.
The 'Info' method was requested, and an XML document was returned. This document
contains information about the databases that belong to a profile.
Search:
Call:
http://eit.ebscohost.com/Services/SearchService.asmx/Search?prof=custid.groupid.profile&pwd=password&db=database_name&query=formatted_queryReturn:
<?xml version='1.0' encoding='UTF-8'?> <?xml-stylesheet type='text/xsl' href='search.xsl'?> <searchResponse xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <Hits xmlns="http://epnet.com/webservices/SearchService/Response/2007/07/">93848</Hits> <Statistics xmlns="http://epnet.com/webservices/SearchService/Response/2007/07/"> <Statistic> <Database>a9h</Database> <Hits>49571</Hits> </Statistic> </Statistics> ... <SearchResults xmlns="http://epnet.com/webservices/SearchService/Response/2007/07/"> <records xmlns=""> <rec recordID="1"> <pdfLink /> <plink>http://search.ebscohost.com/login.aspx?direct=true&db=bth&AN=65566785&site=ehost-live</plink> <header shortDbName="bth" uiTerm="65566785" longDbName="Business Source Complete" uiTag="AN"> <controlInfo> <bkinfo /> <jinfo> <jid type="mid">2EL3</jid> <jtl>Sports Marketing</jtl> <maglogo>N</maglogo> </jinfo> <pubinfo> <dt year="2012" month="03" day="01">2012</dt> <pub>Richard K. Miller & Associates</pub> </pubinfo> <confinfo /> <artinfo> <ui>65566785</ui> <ppf>304</ppf> <ppct>48</ppct> <formats> <fmt type="P" size="513KB" /> </formats> <tig> <atl>CHAPTER 43: COLLEGE ATHLETIC PROGRAMS.</atl> </tig> <aug> <au>Miller, Richard K.</au> <au>Washington, Kelli</au> </aug> <sug /> <src>R</src> <pubtype>Market Research Report</pubtype> <doctype>Article</doctype> <ab> </ab> </artinfo> <language code="eng">English</language> <refInfo /> <copyright flag="Y"> <custom>Copyright of Sports Marketing is the property of Richard K. Miller & Associates and its content may not be copied or emailed to multiple sites or posted to a listserv without the copyright holder's express written permission. However, users may print, download, or email articles for individual use.</custom> <item>Sports Marketing</item> <holder>Richard K. Miller & Associates</holder> <dt year="2012" /> </copyright> <holdings islocal="N" /> </controlInfo> </header> </rec> ... </records> </SearchResults> </searchResponse>
Note: the search information above has been shortened and is not valid.
The 'Search' method was requested, and an XML document was returned. This document
contains search results on the database that belong to a profile.
Browse:
Call:
http://eit.ebscohost.com/Services/SearchService.asmx/Browse?prof=custid.groupid.profile&pwd=password&db=database_name&browse=browse_term&index=indexReturn:
<browseResponse xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <response xmlns="http://epnet.com/webservices/SearchService/Response/2007/07/"> <records xmlns=""> <rec resultID="1"> <header> <browseTerms searchKey="kathy" count="9"> <browseTerm>kathy</browseTerm> </browseTerms> </header> </rec> .... </records> </response> </browseResponse>
Note: the browse information above has been shortened and is not valid.
The 'Browse' method was requested, and an XML document was returned. This document
contains information about the record count,name of the specified search/database that belong to a profile.
To view the other methods available on the EBSCOhost Web Service API, visit the Search Service
service description page.
One example in this demo makes use of the SOAP protocol. The application sends
an XML message to the SOAP server, and the SOAP server responds back with an
XML message.
In this example, the message transfer is done using HTTP POST. This is an example
SOAP transaction:
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" > <soap:Header> <auth:AuthorizationHeader soap:mustUnderstand="1" xmlns:auth="http://epnet.com/webservices/SearchService/2007/07/"> <auth:Profile>custid.groupid.profid</auth:Profile> <auth:Password>helloworld</auth:Password> </auth:AuthorizationHeader> </soap:Header> <soap:Body> <eit:Info xmlns:eit="http://epnet.com/webservices/SearchService/2007/07/" /> </soap:Body> </soap:Envelope>Server Response:
<?xml version="1.0"?> <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <soap:Body> <InfoResponse xmlns="http://epnet.com/webservices/SearchService/2007/07/"> <info> <dbInfo xmlns="http://epnet.com/webservices/SearchService/Response/2007/07/"> <db shortName="f5h" longName="MasterFILE Premier"> <sortOptions> <sort name="Date Descending" id="date" /> <sort name="Date Ascending" id="date2" /> </sortOptions> <dbTags> <dbTag name="TX" description="All Text" /> <dbTag name="AU" description="Author" /> <dbTag name="TI" description="Title" /> <dbTag name="AN" description="Accession Number" /> </dbTags> <dbIndices> <dbIndex name="ZA" description="Author" /> <dbIndex name="ZT" description="Document Type" /> <dbIndex name="ZD" description="Entry Date" /> </dbIndices> <authorityInfo> <db xsi:type="DatabaseWithAuth" shortName="f5hjnh" longName="MasterFILE Premier -- Publications"> <sortOptions /> <dbTags> <dbTag name="SU" description="By Title Subject & Description" /> <dbTag name="OC" description="Country of Origin" /> </dbTags> <dbIndices> <dbIndex name="ZO" description="Company" /> <dbIndex name="ZY" description="Country" /> </dbIndices> <dbFormats> <dbFormat name="list" description="list" /> <dbFormat name="detailed" description="detailed" /> </dbFormats> </db> </authorityInfo> </db> </dbInfo> </info> </InfoResponse> </soap:Body> </soap:Envelope>Note: the database information above has been shortened and is not valid.
To see how this application uses SOAP, refer to the file "simple_search/soap.php".
To view the other methods available on the EBSCOhost Web Service API, visit the Search Service
service description page. To format SOAP messages, it may also be helpful to look at the EBSCOhost Search
Service WSDL (Web Service Description Language) file, available here.
XSLT is a W3C standard. XSLT stands for eXtensible Stylesheet Language Transformations. XSLT allows you to use XSL stylesheets to present XML data in a user-friendly format. The search results returned by the EBSCOhost Web Service API can be transformed into HTML using XSLT. In order to use a stylesheet, the XML header must be modified as follows:
From:<?xml version="1.0"?>To:
<?xml version='1.0' encoding='UTF-8'?> <?xml-stylesheet type='text/xsl' href='search.xsl'?>
This can be achieved in almost any programming language by using string functions. An example of this in PHP is below. It uses PHP's str_replace() function. The string in the first parameter is replaced with the string in the second parameter.
$xml = str_replace( '<?xml version="1.0"?>', '<?xml version="1.0" encoding="UTF-8"?> <?xml-stylesheet type='text/xsl' href='search.xsl'?>', $xml );
There are also many different ways, in many different languages, to traverse
an XML document. In the REST with DOM example, PHP's native DOMDocument
class was used. This class allows you to search XML documents by tag names, and
read XML in a tree-like format.
In the example below, The DOMDocument class is initialized, and is loaded with an
XML file. '$xml' is a variable which contains the XML data returned from the
EBSCOhost Web Service.
// Create a DOMDocument to parse the XML file $xmlObj = new DOMDocument(); $xmlObj->loadXML( $xml );
Next, all elements with the name "db" are selected. This effectively selects all databases in the XML document.
// Get all elements with tag "db" $databases = $xmlObj->getElementsByTagName( "db" );
Then, the name of each database is outputted using a foreach loop. The name is contained in the attribute "longName" of the "db" element.
foreach( $databases as $database ) print( $database->getAttribute("longName") );