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
Java applications, copy the "SimpleSearch" 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:8080/SimpleSearch/Back to Top
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 'web.xml' source code, which is found in the "SimpleSearch\WEB-INF" folder.
<context-param> <param-name> username <param-name> <param-value> UserNameValue <param-value> <context-param> <context-param> <param-name> password <param-name> <param-value> PasswordValue <param-value> <context-param>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 "web.xml" 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 HttpWebRequest . This is an example call and
response:
For Info Method:-
Call: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.
To view the other methods available on the EBSCOhost Web Service API, visit the
Search Service service description page.
For Search Method:-
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.jsp?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 database information above has been shortened and is not valid.
The 'Search' method was requested, and an XML document was returned. This document
contains information about the databases that belong to a profile.
To view the other methods available on the EBSCOhost Web Service API, visit the
Search Service service description page.
For Browse Method:-
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 database 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 databases 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 "SimpleSearch/TypeSearch/Soap/SOAP.cs".
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='index.xsl'?>
This can be achieved in almost any programming language by using string functions. An example of this in Java is below. It uses String.replace(old String,new String) function. The String in the first parameter is replaced with the String in the second parameter.
String xml = String.replace( '<?xml version="1.0"?>', '<?xml version="1.0" encoding="UTF-8"?> <?xml-stylesheet type='text/xsl' href='index.xsl'?>', $xml );
There are also many different ways, in many different languages, to traverse an XML document. In the REST with DOM example, The Document class implements the W3C Document Object Model (DOM) Level 1 Core and the Core DOM Level 2. The DOM is an in-memory (cache) tree representation of an XML document and enables the navigation and editing of this document. Because Document implements the XslTransform class.The Document class extends Document and allows structured data to be stored, retrieved, and manipulated through a relational
See XML Document Object Model (DOM) for more information.
In the example below, The Document class is initialized, and is loaded with an XML file. 'xmlData' is a variable which contains the XML data returned from the EBSCOhost Web Service.
// Create a Document to parse the XML file
org.w3c.dom.Document = New org.w3c.dom.Document()
Document.XMLDoc= docBuilder.parse (Path of the XML data);
Next, all elements with the name "db" are selected. This effectively selects all databases in the XML document.
// Get all NodeList with tag "db" NodeList xnList = xmlData.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.
for(int index=0; index less than xnList.getLength() ; index++) Node firstNode = xnList.item(index); if(firstNode.getNodeType()== Node.ELEMENT_NODE) NamedNodeMap getAttrib = firstNode.getAttributes(); if(dbSelected!=null && getAttrib.getNamedItem("shortName").getNodeValue().equals(dbSelected)) getAttrib.getNamedItem("longName").getNodeValue().trim()Back to Top