Está en la página 1de 156

Enterprise System Integration with Web Services: A Case Study with a Book Broker Application

by Michael Ryan

Submitted in partial fulfillment of the requirements for the degree of M.S. in Computer Science at School of Computer Science and Information Systems Pace University August 2005

ii

ABSTRACT
Web services are gaining a tremendous amount of momentum in recent years as a viable tool in distributed computing. Web Services have evolved from other distributed technologies, which include Java RMI, CORBA, and DCOM, but their specification deficiencies with respect to complete platform and programming language independence, and interoperability are creating a need for a more suitable solution. Despite its youth, Web Services offer to provide such a solution by inheriting the beneficial traits of its predecessors, utilization of an IDL in the form of a WSDL (Web Service Description Language) for one, and at the same time, avoiding the negative aspects associated with its predecessors, which include tight coupling specifications, potential for firewall blocking, long development times, and higher costs. Through the use of standardized technologies (HTTP, SOAP, and XML), Web Services offer to deliver results. I present a book broker in two formats: as a web interface and as a Composite Web Service. Both formats provide book-pricing data from various vendors and book search functionality based on any combination of factors, such as author, title, publisher, keyword and ISBN. The purpose of this project is to provide a publicly accessible book broker that is superior in functionality to existing book brokers today, to enable developers to integrate my Web Service into their own applications, promoting data exchange regardless of the platform or programming language being used and lastly, to provide a good case study of how to bring out the best in Web Services.

iii

ACKNOWLEDGEMENTS
I would like to thank my advisor, Dr. Lixin Tao, for his guidance and expertise. Many times when I began to veer off course, he would step in and put me back on track. I would like to thank the department Chairperson, Dr. Narayan Murthy, for convincing me to pursue my thesis and making me aware of the potential personal rewards that come about from the entire process. A special thank you to Dr. Mary Courtney for her motivational comments, finding time to discuss my project and for re-shuffling her schedule on my behalf. Finally, I would like to thank my entire family for their feedback, support and love.

iv

TABLE OF CONTENTS

LIST OF TABLES LIST OF FIGURES CHAPTER 1 INTRODUCTION 1.1 1.2 1.3 1.4 1.5 1.6 Enterprise Integration Dilemma Web Service Defined Enterprise Integration Web Service Solution Phases of Adoption CWS Solution Overview

viii ix

1 1 2 4 4 5

CHAPTER 2 B2B SYSTEM INTEGRATION TECHNOLOGIES 2.1 2.1.1 2.1.2 2.1.3 2.1.4 2.2 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 2.2.7 2.3 2.4 Distributed Computing Technologies Java RMI CORBA DCOM Web Service Evolution Web Service Architecture Protocol Layer-HTTP Packaging Layer-SOAP Information Layer-XML Service Layer- Web Service & WSDL Discovery Layer-UDDI Alternative Layers-REST and HTML Scraping Web Service Stack Analysis Web Service Industry Trends Current Book Broker Environment 6 6 7 7 8 11 11 12 14 14 16 17 18 19 20

CHAPTER 3 CWS ANALYSIS & ARCHITECTURE 3.1 3.2 3.3 3.3.1 3.3.2 3.3.3 3.3.4 3.3.5 3.3.6 CWS Requirements CWS Functional Specifications CWS Design Architecture Methods Used Data Structures CWS Web User Interface-CWSUI CWS Composite Web Service-CWSWS Hardware and Software Specifications 21 22 24 24 26 29 29 29 30

CHAPTER 4 CWS IMPLEMENTATION 4.1 4.2 4.2.1 4.2.2 4.2.2.1 4.2.2.2 4.2.2.3 4.2.3 4.3 4.3.1 4.3.1.1 4.3.2 4.3.2.1 4.3.2.2 4.3.3 4.3.3.1 4.3.3.2 Overview CWS Web Interface View Controller The searchIsbn() Method Vendor methods The amazon() Method Model CWS Web Service CWS Service Deployment CWS Client Java Client .NET Client CWS Discovery Publishing CWS Performing a CWS Query 31 31 31 33 35 35 37 38 38 38 40 41 42 43 43 44 45

CHAPTER 5 CWS TEST CASES 5.1 5.2 Use Case Verification CWS vs. Current Book Brokers 48 61

vi 5.2.1 Third Party Web Services 5.2.2 BookFinder4u.com 5.2.3 Chambal.com 5.2.4 FetchBook.info CHAPTER 6 CONCLUSION 6.1 6.2 6.2.1 6.2.2 6.3 APPENDIX 1 APPENDIX 2 APPENDIX 3 APPENDIX 4 APPENDIX 5 APPENDIX 6 APPENDIX 7 APPENDIX 8 APPENDIX 9 APPENDIX 10 APPENDIX 11 APPENDIX 12 APPENDIX 13 APPENDIX 14 APPENDIX 15 APPENDIX 16 CWS Interoperability Solution Future of Web services Market Research Statistics and Forecasts Potential Trends Potential Pitfalls Web service enabling products Index.jsp Results.jsp Controller.java BookBean.java Error.jsp Search.jsp CWS.wsdl Aboutus.jsp BookServerImpl.jws IBookSearch.java CWSBookSearchClient.java cwsForm.cs BookServerImplService.cs AssemblyInfo.cs PublishCWS.java 61 64 64 65 66 67 67 68 69 71 84 86 88 100 102 103 105 107 108 120 121 125 130 132 133

vii APPENDIX 17 APPENDIX 18 APPENDIX 19 APPENDIX 20 APPENDIX 21 REFERENCES FindCWS.java Configurator.java PropCWS.properties CWS Build Manual CWS User Guide/Maintenance Manual 135 137 139 141 143 146

viii

LIST OF TABLES
Table 1 Table 2 Table 3 Table 4 Current Web Book Brokers CWS Hardware and Software Specifications UDDI Registry Access Point URLs Future Trends in Web Services 20 26 41 66

ix

LIST OF FIGURES
Figure 1 Figure 2 Figure 3 Figure 4 Figure 5 Figure 6 Figure 7 Web Service Stack SOA Model Model 1 JSP Architecture Model 2 JSP Architecture CWS MVC Architecture CWS Sequence Diagram CWS Data From IBM UDDI Registry 10 24 25 25 27 28 45

CHAPTER 1
1.1

INTRODUCTION

Enterprise Integration Dilemma

Enterprises continue to face the dilemma of integrating heterogeneous applications to meet the demands of business. Firms struggle to manage the costs associated with correcting internal, integration inefficiencies or with efforts to expand existing applications to trading partners, service providers or third parties. Firms are continuously attempting to maintain and improve their business-to-business (B2B), business-toconsumer (B2C), department-to-department, or peer-to-peer relations. Web services are gaining a tremendous amount of momentum in recent years as a viable solution to this problem. Whether the environment is within an enterprises intranet or beyond their firewall, Web services offer to connect disparate systems regardless of platform, programming language or vendor.

1.2

Web Services Defined

In it simplest form, a Web service is an application or function that is defined and published to be called over a network. Web services are classified as a distributed technology, are appropriate to any type of networking environment and can support business-to-business (B2B), business-to-consumer (B2C), department-to-department, or peer-to-peer relations. Web services incorporate open standards (i.e. SOAP, XML, HTTP), which result in a modular structure that provides a foundation for application integration, data exchange, elimination of component lock in and improved interoperability. The functionality provided by a Web service can vary from simple data retrieval requests to complex business processes. A basic Web service may be

2 discovered and invoked to access a weather report, research currency exchange rates, or retrieve a book price. A more complex Web service may be invoked to handle multiple transactions within an enterprises supply chain application, which includes purchase orders, work orders, financial and client reporting, and manufacturing data.

One of the most compelling aspects of Web services is the ability to aggregate various Web services into one higher-level Web service by way of process composition that is executed in a specific sequence. The open standard, building blocks that make up the Web service architecture allow for the implementation of multiple Web service invocations and can lead to new functionality. A consumer can now invoke a composite Web service and shop for multiple currency exchange rates from numerous Web services all from one locale. An enterprise can improve their supply chain application by adding a composite Web service that researches suppliers offering the best prices. Web service composition creates more flexibility for consumers and enterprises, promotes code reusability and increased quality of service.

1.3

Enterprise Integration Web Service Solution

Through the use of open standards, process composition, and loose coupling specifications, Web services offer to correct the integration problems many Enterprises face today. The cause of these integration problems is that since many applications are built around different platforms and programming languages, it is difficult to have these applications interoperate effectively. Many business applications are written in various programming languages, such as C++, Java, Visual Basic, and reside on various

3 platforms, such as Windows or Linux based systems. Moreover, most business data are still kept on mainframes in non-relational (VSAM) files and accessed by mainframe applications written in COBOL. The programming languages themselves present a few barriers. A few specific conflicts include the use of Javas Collection class, passing an array with a null element, and namespace conflicts. Despite these obstacles, Web services present a solution by establishing a common ground for all parties to interoperate effectively.

Additionally, in an effort to provide Web service guidelines, constraints and practical recommendations, the Web Services Interoperability Organization (WS-I) has been formed and delivers sets of use cases, profiles, sample applications and test tools. WS-I has provided the Basic Profile (BP) 1.0 specification to address existing interoperability issues. A few of the key BP constraints [8] include:

Precludes the use of SOAP encoding Requires the use of HTTP binding for SOAP Requires the use of HTTP 500 status response for SOAP Fault messages Requires the use of HTTP POST method Requires the use of WSDL1.1 to describe the interface of a Web service Requires the use of RPC-literal or document-literal forms of WSDL Precludes the use of RPC-encodedstyle WSDL Precludes the use of solicit-response and notification style operations Requires the use of WSDL SOAP binding extension with HTTP as the required transport Requires the use of WSDL1.1 descriptions for UDDI tModel elements representing a Web service

Overall, Web services are still in their youth, but the technology is being employed today and is continuously undergoing fine-tuning. The optimism is so high that research firms have laid out a potential schedule for its progress.

1.4

Phases of Adoption

Surveys from leading market research firms (Gartner Group, Forrester, IDC, and others) find the adoption of Web services involves three distinct phases of progression. The initial phase entails organizations beginning to adopt Web Services behind the firewall. They experiment with pilot projects to gain hands-on experience and implement low-risk incremental strategies when migrating over to a Web service solution. As firms establish a comfort zone, they progress to the next phase of Web service adoption where they start integrating applications and business processes beyond the firewall. Enterprises begin to build sophisticated, collaborative systems with trading partners. The final phase deals with the presence of numerous publicly available Web Services. Firms initiate the development of complex applications by pulling together and incorporating existing public Web Services. Each phase presents numerous challenges for enterprises and developers. These include security issues, interfacing with legacy systems, and service level agreements.

1.5

CWS Solution

I present CWS, a book broker composite Web service that fulfills three objectives. First, CWS provides a superior tool for consumers, allowing them to search for book information from numerous web sites from one centralized web site. Currently, numerous book brokers (i.e. Chambal.com, FetchBook, BookFinder4U) exist, but fail to offer the same robust, book search functionality that CWS offers and are not making the leap forward toward applying Web services technology.

5 Secondly, CWS enables developers to integrate CWS J2EE-based Web service into their own applications regardless of the platform, programming language or component model being used on their end. A .NET client application has no difficulty exposing CWS methods.

Lastly, CWS presents a good case study of how to bring out the best in Web Services by emphasizing the power of process composition, the ability to alter the building blocks of the Web service stack and providing dual B2B and B2C supports.

1.6

Overview

Chapter 2 begins with a brief summary of B2B distributed technologies and details the component layers of the Web service standard. Recent Web service trends and the current book broker environment are also discussed. Chapter 3 outlines CWS requirements, functional specifications through specific use cases and CWS architecture. Chapter 4 addresses the implementation of CWS Web interface and composite Web service. Chapter 5 covers test cases which verify how successful CWS is in satisfying the use cases specified in Chapter 3, and how CWS functionality matches up to third party Web services and the major book brokers. Lastly, Chapter 6 details the future of Web Services and the problems which still need to be addressed.

CHAPTER 2
2.1

B2B INTEGRATION TECHNOLOGIES

Distributed Computing Technologies

Distributed computing, in its simplest form, deals with providing a tool for a client program, running on a local host, to call or invoke a server method, running on a remote host, and to retrieve the result of the remote execution. A client can utilize different communication styles when contacting a remote server. A client can simply call a remote method or procedure (Remote Procedure Call or RPC), invoke a method on a remote object (Remote Method Invocation or RMI) or even put messages or receive messages from a remote queue (Message queuing). Many distributed technologies have been developed over the years utilizing various styles, but three key distributed technologies stand out from the rest: Java RMI, CORBA, and DCOM. Each distributed computing paradigm is unique in its own right, but they all share one critical trait: they have all contributed to the evolution of Web Services.

2.1.1 Java RMI


Java RMI or Java Remote Method Invocation entails having an object call a method of a remote object. The remote object is located on a different Java Virtual Machine (JVM) and possibly, on another machine. In order for the two objects to communicate, a "stub" or "proxy", located on the caller's JVM, and a "skeleton" or tie, located on the remote object's JVM, are needed. The stub and skeleton represent Java public interfaces. The process involves a caller gaining direct access to the stub, the stub transforms the programming language input parameters into a byte stream (a process known as marshaling or serialization), the stub relays the caller's method call to the skeleton

7 using a given protocol and transport mechanism, the skeleton converts the incoming byte stream back into its respective programming language (a process known as unmarshaling or deserialization), the skeleton executes the method on the remote object based on the received parameters, and the response comes back through the reverse path. Java RMI utilizes a wire protocol known as Java Remote Method Protocol (JRMP).

2.1.2 CORBA
CORBA or Common Object Request Broker Architecture (CORBA) is a binary specification created by a group of vendors called the Object Management Group. CORBA utilizes an Interface Definition Language (IDL), which allows for client/server object interaction within a specific Object Request Broker (ORB). The ORB is the intermediary that creates the connection between distributed objects. A CORBA object is represented by an interface with a set of methods. The client of a CORBA object acquires its object reference and uses it as a handle to make method calls. The ORB is responsible for all the mechanisms required to find the object's implementation, prepare it to receive the request, communicate the request to it, and carry the reply back to the client. The wire protocol that is used by CORBA is known as Internet Inter-ORB Protocol (IIOP). CORBA employs an object-oriented RPC communication style.

2.1.3 DCOM
DCOM is the distributed form of Component Object Model (COM), which builds an object remote procedure call layer on top of DCE RPC. A COM client interacts with a

8 COM object by acquiring a reference to one of the object's interfaces and invoking methods through that reference. DCOM employs an object-oriented RPC communication style where the client interface is called the proxy and the server interface is called the stub. The specification of DCOM is at the binary level and permits integration of components written in various programming languages.

2.1.4 Web Service Evolution


Java RMI, CORBA, and DCOM are still utilized today, but their specification deficiencies with respect to complete platform and programming language independence, and interoperability are creating a need for a more suitable solution: Web Services. Web Services are evolving by inheriting the beneficial traits of its predecessors which include the utilization of an IDL in the form of a WSDL (Web Service Description Language) and the use of object-oriented RPC style communication via stubs and skeletons. At the same time, the specification of Web Services is avoiding the negative aspects associated with its predecessors, which include tight coupling specifications, potential for firewall blocking, long development times, and higher costs.

Distributed computing technologies of the past operate under a tightly coupled specification, meaning a client can only interact with a server when both sides have the appropriate libraries installed on their machines. CORBA requires each endpoint, the client at one end and the server at the other, to have a compatible Object Request Broker (ORB). The same holds true for Microsoft DCOM and Java RMI where endpoint

9 implementations must match. Granted a tight coupling specification has its place when needed, but a more diplomatic and flexible format is the answer. Fortunately, Web services specifications enforce loose coupling, meaning a client and a server can interact independently irrespective of each endpoints platform and programming language. This promotes flexibility, interoperability and improved integration. A .Net client can interact with a J2EE server without having to worry about installing required components and libraries. Various departments within an enterprise, running on different platforms, can exchange data freely.

Additionally, distributed technologies in use today, namely CORBA and DCOM, are geared more for internal enterprise use and utilize non-standard ports to communicate. Thus, a client from outside the enterprise utilizing a standard port, who has appropriately installed the required libraries, attempting to interact with a firms server is going to be unsuccessful. Aside from the security benefits for the enterprise, such traffic is blocked by the institutions firewall by default due to port differentials. This limits the use of such distributed technologies beyond enterprises. A firewall has to be configured every time an open port has to enter the mix. This is time consuming, inefficient and costly. Undoubtedly, the presence of a universal standard protocol with security measures in place expands the use of distributed technologies beyond the enterprise arena. Web services operate generally via one standard protocol, Hyper Text Transmission Protocol (HTTP), over open port 80. This eliminates the problem of firewalls blocking traffic due to port differentials and the need to perform additional gateway configurations. It

10 furthers relationships beyond the enterprise and expands the use of distributed technologies.

Finally, the development process for distributed technologies of the past tends to take an enormous amount of time to complete. The existence and installation of numerous components, and the possibility of performing additional plumbing (i.e. additional gateway configurations) lead to such an unpromising result. Furthermore, the increased cost associated with the additional development time is a major drawback, especially for IT managers. A more cost effective and reduced development time solution is desired. Web services are simple to implement and deploy. The components associated with

Web services generally revolve around three technologies: HTTP, SOAP and XML. Web services operate under a text based protocol, unlike the binary protocols employed by past distributed technologies. This expedites the development process, reduces costs and improves overall productivity.

Admittedly, Web services possess their share of disadvantages. One of the key issues facing Web services today is misuse. Web services have generated a tremendous amount of hype. It is very common to get caught up in the latest industry trend or buzzword. Freeman and Jones point out that when a new and exciting technology arises, it is frequently over-prescribed and shoehorned into inappropriate situations, often because people misunderstand the benefits and limitations of the technology, but also because programmers simply want to experiment with the new technology. [1] Additional disadvantages include security loopholes, network failures, service level agreements and

11 quality of service non-compliance, latency and poor return on investment(ROI). Despite the few negative aspects surrounding Web Services, the technology is being utilized today and is continuously being improved upon.

2.2

Web Service Architecture

Currently, the Web Service architecture consists of many layers. The following stack demonstrates the building blocks of a Web Service and the corresponding technologies:

Figure 1: Web Service stack. Source: www.embedded.com

2.2.1 Protocol Layer-HTTP


The initial layer is the Protocol layer. This layer specifies which mechanism is used to communicate or invoke a Web Service over a network. FTP or File Transfer Protocol is used for transmitting files across networks and SMTP or Simple Mail Transfer Protocol is used for sending e-mail. The most common protocol used over the Internet today is

12 HTTP 1.1 or Hyper Text Transport Protocol. HTTP is a request/response, text-based style protocol where a client opens a connection to a server, sends a request, the server processes its specific utility based on the client request and sends a response back to the client.

2.2.2 Packaging Layer-SOAP


The packaging layer houses a mechanism or protocol that packages and binds messages sent over a network. SOAP or Simple Object Access Protocol occupies this layer. SOAP is a lightweight protocol that specifies the format of messages used in Web services and enables cross-platform integration independent of the programming language or distributed object infrastructure being used. For a detailed description of SOAP, visit http://www.w3.org/TR/SOAP/. From a Web Services standpoint, there are a total of two SOAP messages crossing the wire: a client request and a server response. SOAP messages are formatted in XML or Extensible Markup Language and consist of four parts: an optional XML declaration, a SOAP Envelope, an optional SOAP Header, and a SOAP Body. The following example demonstrates a SOAP request/response dialogue where a client is invoking a server method named multiply with two parameters:
Request <?xml version="1.0" encoding="UTF-8" ?> <SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <SOAP-ENV:Body> <ns1:multiply xmlns:ns1="urn:MyWebService"> <param1 xsi:type="xsd:int">2</param1> <param1 xsi:type="xsd:int">3</param1>

13
</ns1:multiply> </SOAP-ENV:Body> </SOAP-ENV:Envelope> Response <?xml version="1.0" encoding="UTF-8" ?> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <SOAP-ENV:Body> <ns1:multiplyResponse xmlns:ns1="urn:MyWebService" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> <return xsi:type="xsd:int">6</return> </ns1:multiplyResponse> </SOAP-ENV:Body> </SOAP-ENV:Envelope>

Both SOAP messages contain the XML declaration <?xml version="1.0" encoding="UTF-8"?> which specifies the XML version and the character encoding of the XML message. The SOAP Envelope consists of the XML root element, SOAP-ENV:Envelope, which specifies the namespaces used in the SOAP message. The optional SOAP Header tag is contained within the SOAP Envelope, but is not represented in the example above for simplicity. The SOAP Header is commonly used to transmit authentication and session management data. The SOAP Body, located within the SOAP Envelope, contains what is commonly called the payload. In the client request, the SOAP Body contains the name of the method the client wishes to call, multiply, along with the method's input parameters, 2 and 3 in this case. The server response SOAP Body contains the method name concatenated with Response and the results of the method invocation, 6. Note that even if there is no return value, a message is still sent back to verify that the method executed.

14

2.2.3 Information Layer-XML


XML occupies the Information layer of the Web Services stack. XML or Extensible Markup Language is a text-based meta-language that not only describes how data is structured, but also describes the context of the data, gaining a better understanding of its significance. Visit http://www.techcourt.com/technologies/xml/whyimp.htm for a detailed introduction to XML. XML plays a key role as the main data interchange format for Web Services.

2.2.4 Service Layer- Web Service & WSDL


The Service layer specifies the mechanism, WSDL in this case, for describing the Web Service and the actual Web Service itself. WSDL or Web Service Description Language is an XML vocabulary for describing web services. A client needs to know various pieces of information in order to interact with the Web Service. These include: where the service can be reached, how the service can be reached, what methods and parameters are required, and what data types are used by messages sent or received by the web service. The WSDL document provides all this information in a very unambiguous way. A WSDL document consists of six major elements and two utility elements:
The definitions element is the root element and specifies the name of the web service and the namespaces used throughout the document. The message element specifies the message name along with zero or more part elements. The part elements define the parameters that are required. Zero parts means zero parameters. The message element only specifies the name, value(s) and the type of each value. It is the job of the portType element to specify whether the message is for input or output. The portType element defines a group of one or more operations, each of which has an operation element. Each operation element has a name value and defines which message is the input and which is the output. If an operation represents a request/response dialogue, then the operation would include two messages. If an operation represents only a request with no response or a response with no request, it would include only a single message.

15

The types element declares all the types that are used between the client and the web service for all the services declared in the WSDL document. Types can be simple or complex. The binding element defines a specific portType implemented using a specific protocol such as SOAP. If a service supports more than one protocol (SOAP, CORBA, etc.), the WSDL document includes a listing for each. The service element specifies the actual location or endpoint of the web service in the form of a URL. The documentation element is a utility element which permits comments to be placed throughout the WSDL document The import element is utilized to import other WSDL documents or XML Schemas

The following example displays a HelloService WSDL document [6]:


<?xml version="1.0" encoding="UTF-8"?> <definitions name="HelloService" targetNamespace="http://www.ecerami.com/wsdl/HelloService.wsdl" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://www.ecerami.com/wsdl/HelloService.wsdl" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <message name="SayHelloRequest"> <part name="firstName" type="xsd:string"/> </message> <message name="SayHelloResponse"> <part name="greeting" type="xsd:string"/> </message> <portType name="Hello_PortType"> <operation name="sayHello"> <input message="tns:SayHelloRequest"/> <output message="tns:SayHelloResponse"/> </operation> </portType> <binding name="Hello_Binding" type="tns:Hello_PortType"> <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/> <operation name="sayHello"> <soap:operation soapAction="sayHello"/> <input> <soap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:examples:helloservice" use="encoded"/> </input> <output> <soap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:examples:helloservice" use="encoded"/> </output> </operation> </binding>

16

<service name="Hello_Service"> <documentation>WSDL File for HelloService</documentation> <port binding="tns:Hello_Binding" name="Hello_Port"> <soap:address location="http://localhost:8080/soap/servlet/rpcrouter"/> </port> </service> </definitions>

A client in possession of the HelloService WSDL document has all the required data needed to invoke the service. By checking the service element, the client discovers the actual service is located at http://localhost:8080/soap/servlet/rpcrouter. The binding element reveals the web service can be invoked with an RPC communication style via HTTP and SOAP. Lastly, the client learns from the portType element that the actual name of the method to be called is sayHello and the method requires one parameter in the form of a String type, specified by the part element within the message element.

Not only does a WSDL document describe fully the details of a Web Service, but also a key selling point for its continued use is that its structure makes it possible to generate code from WSDL descriptions and WSDL descriptions from code. This expedites client code development and reinforces the use of XML as a universal format for data interchange.

2.2.5 Discovery Layer-UDDI


The Discovery layer completes the Web Service stack and is occupied by a mechanism, which publishes information about various Web Services. UDDI or Universal Description, Discovery, and Integration resides here. For a detailed description of UDDI, visit http://www.uddi.org . UDDI provides a repository where any entity, at design or run

17 time, can search to find specific Web Services. As the number of Web Service systems grows, the need for an organized directory is a necessity. The repository contains

information about businesses, the services they provide(Web Services and Non-Web Services), version changes, and how to access services. A UDDI can be structured for

public use where any person or business can publish their services to the world and establish partnerships or for private use, where an individual company can create their own isolated UDDI registry to list the services available within their private network. An entity that wishes to register their Web Service must do so using XML-based documents and provide four key data elements, which are used in the discovery process:
The businessEntity element specifies the web service owner and includes business name, description, address, and contact information. Every business receives its own UUID (Universally Unique Identifier) called a businessKey. The businessService element describes one specific service. A business can have multiple web services. Each service is given a unique serviceKey. The bindingTemplate element specifies the technical aspects of a single service such as the endpoint URL and interface information. Each template is uniquely identified by a bindingKey. The tModel element or serviceType provides a URL location to a document that provides more information (metadata) about the service. This document can be a WSDL document(preferred) , HTML page, etc. Each tModel is uniquely identified by a tModelKey

2.2.6 Alternative Layers-REST and HTML Scraping


Alternative mechanisms can be added to the Web Service stack and consequently, removing a few existing mechanisms in the process. Two tools that are in widespread use today are REST and HTML Scraping. Both tools simplify the Web Service Stack and serve as formidable supplements to the Web Service architecture. REST or Representational State Transfer is an architecture style created by Roy Fielding in his dissertation [5], which attempts to capture the characteristics of the Web. In short, a client using HTTP specifies or binds the method name and parameters directly into the

18 URL and the server responds by returning an XML-formatted response. A hypothetical REST example using a similar method call from the SOAP request/response example above is: http://www.mywebservice.com/xml?method=multiply&param1=2&param2=3 The server makes available a URL to a resource to multiply numbers and return the results in an XML-formatted response. The REST style, commonly termed XML over HTTP, eliminates the SOAP layer in the Web Services stack and is especially useful for simple applications. (see Chapter 4 Amazon implementation). HTML scraping is the process of programmatically making a connection to a specific URL, gathering the HTML source code from the URL, and then pulling the necessary data from the code through pattern matching. The process does not involve calling a method and receiving a response, but more of locating a resource through a URL and fetching the data oneself. HTML scraping involves a tremendous amount of housekeeping on the part of a client since any change to the HTML source code from the URL forces a client to alter their pattern matching code. On the flip side, HTML scraping is dynamic, can gather up to the minute data and is considered a legitimate last resort when no other mechanisms are available.

2.2.7 Web Service Stack Analysis


Overall, the Web Services stack presents a framework for seamless interoperability. HTTP is a common transport protocol that everyone can utilize. SOAP can bridge the gap between parties of different languages and platforms. XML is a data exchange

19 mechanism that every a programming language can employ by its text based nature. WSDL documents provide a universal guidebook and key starting point. Lastly, the UDDI provides the window to web services, providing a yellow pages for existing services and for those yet to arrive.

2.3 Web Service Industry Trends


Theoretically, the Web Service distributed architecture appears to have the ingredients for success and current industry trends support this. Perhaps the most compelling trend deals with the number of companies that have already deployed Web services. Line56.com points out that in a Yankee Group survey of 437 enterprises, 48 percent have already deployed Web services, and another 39 percent plan to do so in 2005 [2]. Additionally, corporations are solidifying their positions in the Web Services market through acquisitions. Computer Associates has recently acquired Adjoin. Hewlett-Packard is in talks to acquire Talking Blocks. This can be a huge driving force and can generate a tremendous amount of momentum toward increased Web service implementation. Software vendors are making a key contribution to the success of Web Services by creating formidable Web service enabling products for various platforms and programming languages. Not only do they provide the tools for implementing the distributed component, but are simplifying the process. One Java toolkit that is in use today is Apache Axis. Axis through its API simplifies the Web Service building process by performing many low level tasks (i.e. dynamic WSDL creation and stub/skeleton code generation), enabling a developer to focus more on higher level problem solving and faster deployment of the finished product. JavaSkyline [3] outlines a few Java

20 related products and a few Java-competitive products in Appendix 1. Lastly, a unified effort exists among big corporations like IBM, Microsoft, and Hewlett-Packard to standardize the distributed technology. In the past, these firms were competing amongst themselves to get the upper hand and gain market share. Today, firms are working together to come up with a standard and are realizing the financial benefits of forming business partners as opposed to business opponents.

The combination of all these factors demonstrate that the Web Services architecture is gaining the support and confidence of many corporations and this foundation can lead to not only a promising future, but a productive one.

2.4 Current Book Broker Environment


The following table illustrates a list of current book brokers on the Web: Chambal Allbookstores Bookpool Bookchecker Isbn.nu Fetchbook.info Bookfinder4u Bigwords BestBookDeal AddAll Bublos MetaPrices BestWebBuys BookFinder.us BookPriceCompare FastBookFinder PriceSCAN like2read isbndb PriceFarmer EveryBookstore FindBookPrices BookWormer thecheapestbook

Table 1: Current Web Book Brokers

21

CHAPTER 3
3.1

CWS ANALYSIS & ARCHITECTURE

CWS Requirements

CWS is a Web-based book broker application designed to provide book pricing and book search functionality for a client via a browser and for a client via an application. CWS allows a client to input specific, book search criteria. Search criteria includes author name, book title, ISBN, publisher, year of publication, subject, and keyword. In addition, a client can input a combination of search criteria and not be limited to just one form. This promotes search refinement and faster response time. Upon receiving a search request, CWS takes on the role of a book broker and a client itself, and begins to navigate to various vendors searching for book data originally specified by the client. Once CWS gathers all the book information from its business partners, CWS presents the results in list form to the client. Results from a price search are presented with a complete book detail summary (author, title, publisher, ISBN, manufacturers retail price) and a list of the vendor, current price, and vendor link. Results from a book search are presented with a total number of books found, a brief summary for each book and option to perform a price search for a selected book. In the event of an error, an error message is displayed and a client is asked to perform a new search. Overall, CWS responds to all requests within 60 seconds.

For a client utilizing a Web browser over the Internet, CWS offers a Web interface, allowing a user to provide the necessary search criteria for CWS to process and respond back with data.

22 For a client accessing CWS via an application, CWS supplies a composite Web service. A client application can initially find CWS through a UDDI registry. Upon successful CWS discovery, a client application can invoke CWS Web service. CWS in turn invokes Amazons Web service to gather all book data originally specified by the client application. Upon completion, CWS Web service returns book results in XML format. In the event of an error, an error message is returned in XML format. Only client applications that can parse XML documents can utilize CWS Web service.

3.2

CWS Functional Specifications

In order to demonstrate CWS functionality, use cases are presented. Use cases are written reports describing a system and its functionality from an external usage perspective. Use cases provide a discrete collection of task-related activities. In this case, the external point of view comes from a person shopping for book prices via their browser, accessing CWS through CWS web user interface (CWSUI) or from an application searching for book data, accessing CWS through CWS composite Web service (CWSWS). Use Case 1: Search ISBN Primary Actor: Student Supporting Actor: Multiple vendors Pre-Condition: User has correct ISBN number Actor: Student System: CWSUI 1. Arrives at CWS home page 2. Present company logo and links 3. Present list of search parameters 4. Enter ISBN number for specific book 5. Submit request 6. Verify parameter(s) have been sent 7. Edit ISBN by removing dashes, spaces 8. Retrieve prices from multiple vendors 9. Display book details, vendor name,

23 price and link 10. Select preferred, vendor link Exception- Step 6: Search parameter(s) are invalid. Report error to user Use Case 2: Search AUTHOR and YEAR PUBLISHED Primary Actor: Student Supporting Actor: Amazon Web service Pre-Condition: User has correct author name and year of publication Actor: Student System: CWSUI 1. Arrives at CWS home page 2. Present company logo and links 3. Present list of search parameters 4. Enter author name 5. Enter year published 6. Submit request 7. Verify parameter(s) have been sent 8. Retrieve books from Amazon 9. Display books (title, author, publisher, year, ISBN, link to Use case 1) 10. Select book 11. Submit request 12. Go to Use case 1 Exception- Step 7: Search parameter(s) are invalid. Report error to user Use Case 3: Invoke searchISBN() method Primary Actor: Java Client Application Supporting Actor: Multiple vendors Pre-Condition: User has correct ISBN number Actor: Java Client Application System: CWSWS 1. Invokes searchIsbn() method 2. Edit ISBN by removing dashes, spaces 3. Retrieve prices from multiple vendors 4. Build results in XML format 5. Return book results 6. Parse results Use Case 4: Invoke searchAll() method Primary Actor: .NET Client Application Supporting Actor: Multiple vendors Pre-Condition: User has correct author name and year of publication Actor: .NET Client Application System: CWSWS 1. Invokes searchAll() method with author name and year of publication

24 parameters 2. 3. 4. 5. Verify parameter(s) have been sent Retrieve books from Amazon Build results in XML format Return book results.

6. Parse results Exception- Step 2: Search parameter(s) are invalid. Return error to user in XML

3.3

CWS Design

3.3.1 Architecture
In order to fulfill system requirements and functional specifications, CWS architecture applies two design patterns. The first is the Service Oriented Architecture (SOA) model (see Figure 2), which consists of a service provider, service broker and service requester.

Figure 2: SOA Model. Source: www.ibm.com IBM Systems Journal Vol. 41, No 2, 2002

CWSWS fills the role of the service provider, providing a service interface to a specific resource and publishing its service with the UDDI registry. The UDDI registry takes on the role of the service broker, providing a locale for service requesters to find Web services. The role of the service requester is filled by a client, usually a person or computer, who searches registries for Web Services and then binds itself to the provider.

25 The second design framework that CWS applies is Model 2 architecture. Since the introduction of Java Server Page (JSP) technology, Model 1 and Model 2 architectures have emerged for building server-side applications. Model 1 (see Figure 3) employs the use of JSP and JavaBeans to separate business logic from presentation. Model 2 (see Figure 4) takes it a step further by incorporating Servlets and presenting a format that follows the Model-View-Controller (MVC) model. The Model consists of data and business logic, the View is responsible for presenting data and the Controller takes in client requests, dictates application behavior and dispatches responses to the View.

Figure 3: Model 1 JSP Architecture [4]

Figure 4: Model 2 JSP Architecture [4]

26 In the Model 2 framework, the Servlet acts as the controller, taking in requests, forwarding responses to the appropriate JSP (the view), and instantiating any required JavaBeans (the model) needed by the JSP environment.

Overall, the utilization of specific design patterns provide numerous benefits to developers. These benefits include capturing the experience of developers from the past who have already tested such patterns, providing a common vocabulary for team members to reduce miscommunication, defining roles to reduce cross participation, and expediting the development process as a whole.

3.3.2 Methods Used


The Controller is structured as a Java Servlet and consists of a doPost() and a
doGet() method to handle client requests. doPost() performs server-side form

validation and invokes a normalize() method to housekeep and trim client parameters. There is a method for each of the 11 vendors. A searchIsbn() method addresses client requests that specify an ISBN parameter and invokes each of the 11 vendor methods. All other types of client requests are handled by an amazon() method. A scrape() method performs HTML scraping and is invoked by each vendor who does not provide Web services functionality (At the time of this writing, Amazon is the only CWS vendor offering Web service capabilities). A getCharacterDataFromElement() method assists the amazon() method with spacing when there are multiple authors for a given book.

27 The methods of the BookBean class (Model) consist of all the accessor methods pertaining to properties of a given book. These properties include vendor, retail price, vendor link, title, publisher, year of publication and author. A compareTo() method is invoked to assist in sorting book price results.

The following diagram presents CWS MVC architecture, classes, class interrelationships, underlying methods and fields:

Figure 5: CWS MVC Architecture

28 The following sequence diagram demonstrates the events that can potentially take place during a CWS book search:

Figure 6: CWS Sequence Diagram

29

3.3.3 Data Structures


CWS does not utilize a database. The BookList, an instance of the Java Vector class, serves as the key data structure for storing book results. The BookList is not to be shared by all client requests. Each individual client request must result in the creation of a new BookList.

3.3.4 CWS Web User Interface-CWSUI


CWS Web user interface operates as a form page and lists each search criteria: Author, Title, Publisher, Publish Year, Subject, Keyword, and ISBN. To the right of each criteria, a user can enter their corresponding search text. In order to initiate a search, a user selects the CWS Search button. The Clear button erases all text entered by a user. CWS logo, About Us link, Contact Us link, and Home page link are also displayed.

3.3.5 CWS Composite Web Service-CWSWS


In order for CWS to meet the role of a Web service provider, CWS will register via a Web browser with two UDDIs (IBM and Microsoft) to facilitate discovery. In addition, CWS provides two methods for client consumption: searchIsbn() and searchAll(). The searchIsbn() method addresses client requests that have specified an ISBN parameter. The searchAll() method handles all other types of client requests. Each method returns book results in XML format. CWS utilizes the Apache Axis 1.1 toolkit as its SOAP engine for deploying CWSWS dynamically and WSDL generation.

30

3.3.6 Hardware and Software Specifications


The following table summarizes CWS hardware and software specifications: Operating System Red Hat Linux 7.2 CSIS Server Matrix File Transfer Application/Protocol Secure Shell Telnet Client (SSH) Java SDK version 1.5.0.01 Application Server Tomcat 4.1.18 Java Servlet specification 2.3 Java JSP specification 1.2 WSDL version 1.1 SOAP Engine Axis 1.1 Table 2: CWS Hardware and Software Specifications

31

CHAPTER 4
4.1 Overview

CWS IMPLEMENTATION

The following implementation of the CWS web interface and the CWS Web Service demonstrate how effective Web service technology can lead us closer to seamless interoperability. The chapter is divided into two sections. The first section details the CWS web interface, which provides book search functionality to the public over the Internet via a browser. The second section details the actual CWS web service. The complete source code is located in the Appendix.

4.2

CWS Web Interface

4.2.1 View
The web interface follows Model 2 architecture and consists of a total of seven files:
index.jsp error.jsp results.jsp Controller.java search.jsp aboutus.jsp

BookBean.java

Index.jsp represents the home page for CWS, providing a means for a user to enter any

combination of specific book-search criteria based on author name, title, publisher, publication year, subject, keyword and international standard book number (ISBN). Once a user selects the search button, the request is passed via the HTTP post method to the servlet, Controller. The following excerpt from index.jsp demonstrates how the post method is initiated:
<table border="10"> <form name= advsearch method=post action="http://matrix.csis.pace.edu:23451/pace/servlet/Controller" ID="form"> <tr valign=middle> <td align=left><font face="verdana,arial,helvetica" size=-1><strong>Author:</strong></font></td> <td align=left><input type=text name=author value="" size=40></td> </tr>

32 As an example, if a user performs an author search by entering James Gosling in the text field, the name/value pair becomes author/James Gosling. If a user selects the search button without making changes to the text fields, then the request is still sent with the corresponding name and all values defaulting to . Index.jsp does not perform form validation. All validation is performed on the server side.

Results.jsp displays the results of an ISBN search. The page displays the details of the

specific book (i.e. author, title, cover image icon, etc.), how many vendors have been found, and a listing of the results with vendor, price and buy-link headings. Since results are forwarded from the Controller servlet as a session attribute in the form of a Vector of BookBean objects, the BookBean class must be imported via a JSP page directive and an instance of a BookBean must be created via the useBean JSP standard tag as follows:
<%@page import="java.util.*, CWS.BookBean" %> <jsp:useBean id="bookList" class="java.util.Vector" scope="session"/>

This allows the id value, booklist, to be used like any Vector object. In order to access each BookBean, the elementAt() method of the Vector class is utilized along with a
BookBean cast, since the method returns an Object type. The following scriptlet

demonstrates accessing an author of a specific book from the bookList:


<%= ((BookBean) bookList.elementAt(index)).getAuthor() %>

Search.jsp displays the results of a non-ISBN search. The page displays how many

books have been found, the details of each book, a corresponding radio button, and a Shop Prices button to search prices for a specified book. The page lists twenty books

per page. The Shop Prices button forwards a request to the Controller via the HTTP

33 get method. If a radio button is not selected by the user, the request is still forwarded, but results in an error from server side validation.

Error.jsp displays any errors, which may have occurred servicing a request. The page

accesses a session attribute in the form of a String, displays that String, invalidates the session and provides a link to begin a new search.

Aboutus.jsp displays corporate information about CWS.

4.2.2 Controller
The servlet, Controller, is the workhorse of the application performing numerous tasks, which include processing all requests, forwarding requests, bean creation, and form validation. The following excerpt from the doPost method shows how the users search parameters are gathered and validated:
String []author String []title = request.getParameterValues("author");

= request.getParameterValues("title");

String []publisher = request.getParameterValues("publisher"); String []year = request.getParameterValues("year");

String []subject = request.getParameterValues("subject"); String []keyword = request.getParameterValues("keyword"); String []isbn = request.getParameterValues("isbn");

if ( (author[0].equals("") && title[0].equals("") && publisher[0].equals("") && year[0].equals("") && subject[0].equals("") && keyword[0].equals("") && isbn[0].equals("") ) || (author[0].equals(" ") || title[0].equals(" ") || publisher[0].equals(" ") || year[0].equals(" ") || subject[0].equals(" ") || keyword[0].equals(" ") && isbn[0].equals(" ")) ) { String err = "Invalid search criteria entered.";

34
session.setAttribute("err", err); ServletConfig cfg = this.getServletConfig(); ServletContext thisCxt = cfg.getServletContext(); RequestDispatcher rd = thisCxt.getRequestDispatcher( "/error.jsp" ); rd.forward( request, response );

Each parameter is gathered using the getParameterValues() method of the request object, which returns an array of Strings. Utilizing the James Gosling search example earlier, the String is not tokenized, but placed entirely into the author array at index zero. As for validation, if all parameters equal , then a user has not entered any search criteria, resulting in the servlet setting up an error session attribute labeled err and forwarding the request to the error.jsp page. Form validation also addresses the possibility of a user entering a white space for all parameters. This results in an error as well.

In the event of a user submitting a request with a valid parameter or a combination of valid parameters, the Controller creates a bookList, an instance of the Vector class, to serve as the data structure to gather all the books that surface from a search. In order to ensure thread safety, the bookList is declared as a local variable inside the doPost method. This guarantees that a bookList is created for each request that the servlet receives. If bookList is declared as a global variable, then all requests would share the same bookList.

The Controller verifies if an ISBN number has been requested. If so, the
searchIsbn() method is invoked. Otherwise, control passes to the amazon() method.

Upon completion of the relevant method call, the Controller sorts the bookList by

35 price, establishes a bookList session attribute named bookList, and forwards the request to either the results.jsp page for an ISBN search or to the search.jsp page for a non-ISBN search.

4.2.2.1

The searchIsbn() Method

The searchIsbn() method accepts two parameters: the ISBN request from the user and the bookList. Initially, the ISBN is edited in the event that a user has entered an ISBN number with hyphens or spaces. The StringTokenizer class is utilized to break up the ISBN into tokens or pieces, eliminate hyphens and spaces, then concatenate to ensure a pure number sequence. From here, each vendor method is invoked accepting the newly edited ISBN and the bookList as parameters.

4.2.2.2

Vendor methods

With the exception of the amazon() method, all vendor websites utilized by CWS are deficient in implementing Web service functionality. As a result, each CWS vendor method resorts to HTML scraping to gather book data. Each vendor possesses a specific Uniform Resource Locator (URL) for accessing his or her book data. Each vendor method invokes the scrape() method with their corresponding URL concatenated with the users ISBN request. A connection to the URL is made using the java classes,
java.net.URL and java.net.URLConnection. The process involves creating a URL

object, u, then calling the openConnection() method of u to create a URLConnection object, urlconnx. Then the setup parameter, setDoInput, is assigned to true since the URL connection is being used for input. Lastly, the connection is made using a socket

36 for a network connection or a file input stream for a local connection. The response header information is read from the server. Data is read from the connection by using the input stream returned by getInputStream(). The scrape() method returns a String of the entire web page. In the event a connection can not be made and an exception occurs, the exception is caught and the scrape() method returns null. This enables processing to continue when certain vendors are unavailable.

Each vendor method utilizes the String from the scrape() method, captures the specific price that is offered from the vendor based on a stable identifier, creates a book object of the BookBean class, sets the price, vendor and URL link of the book via the accessor methods of the BookBean class, and finally adds the book to the bookList.

The difficulty with the HTML scraping process is that all the URLs and stable identifiers must be collected and researched by a server-side programmer prior to implementation. Additionally, if a vendor alters their respective site or URL, then existing code must be altered to reflect such changes. HTML scraping requires a tremendous amount of upkeep and is prone to generating numerous runtime errors. However, it does serve as a last resort when no other alternative, data-gathering methods exist. One common strategy that is used to reduce the amount of upkeep is to centralize all URL and stable identifier information from each vendor into one key file on the server. This way when changes occur, a programmer only has to modify the key file.

37

4.2.2.3

The amazon() Method

The amazon()method demonstrates the power of Web service technology by utilizing Amazon.coms Amazon Web Services (AWS 3.0). AWS, recently changed to Amazon E-Commerce Service (ECS 4.0), allows access to numerous Amazon.coms web sites in the form of a Web Service (Registration and programming information is available at http://www.amazon.com/gp/aws/registration/registration-form.html ). AWS can be accessed through either SOAP or REST requests. CWS utilizes the REST or XML over HTTP approach via Amazon.coms PowerSearch function. AWS is utilized for ISBN searches and is the only vendor CWS utilizes for non-ISBN searches due to its consistency. Basically, a connection is made to a specific URL, which includes a users request data, and AWS returns book results in the form of an XML document (AWS returns ten items per page, so subsequent connections are required for multiple pages). The CWS amazon() method retrieves the XML document as a String, parses the document utilizing the Document Object Model (DOM) from the Java APIs for XML Processing (JAXP), creates a book of the BookBean class for Amazon books as well as for used books being sold by the public through Amazon.com, sets numerous properties of the book via accessor methods, and finally adds the book to the bookList.

Regarding XML processing, DOM is utilized instead of SAX or JDOM for two reasons. First, DOMs biggest drawback is its efficiency problems which can impact performance, but performance is not a critical ingredient to CWS functionality. Moreover, the AWS XML document is not exceptionally large and combined with the fact that CWS sets a 500 book-result threshold, loading the entire document into memory is not very resource

38 intensive. Secondly, the DOM API offers feature-rich methods, specifically the
getElementsByTagName() method, which provides random access to any tag name.

4.2.3 Model
The BookBean class is a JavaBean component that represents a single book. Each book possesses numerous properties, which include title, author, vendor, ISBN and price. Properties can be accessed or modified through a properties corresponding accessor method. The BookBean class implements the Comparable interface to provide a price sorting mechanism for the bookList. Sorting is initiated by the Controller using the
sort() method of the Collections class. The Comparable interface assists the sort()

method by clarifying which particular book property is used in the comparison. A


ClassCastException is thrown otherwise. The Comparable interface contains one

method, compareTo(), which takes an Object as a parameter and returns an integer. The
compareTo() method returns zero if the object passed is equal to the current instance. It

returns a positive integer or a negative integer if the current object is greater or smaller than the passed object. The bookList is sorted by price in ascending order.

4.3 CWS Web Service 4.3.1 CWS Service


The CWS Web Service (CWSWS) consists of the following source files:
BookServerImpl.java IBookSearch.java BookServerImpl.jws

IBookSearch is an interface that defines the two methods that are to be exposed as Web

Services: searchIsbn() and searchAll(). BookServerImpl implements the

39
IBookSearch interface and is derived from the Controller class of the CWS web

interface. The key difference is that CWSWS does not use the BookBean class, but resorts to a more simplified type, the String class. Instead of constructing a bookList, CWSWS sequentially builds an XML document consisting of the book results from each vendor. An instance of the StringBuffer class is utilized to contain the book results. The append() method of the StringBuffer class is called to add book information to the buffer as they come about in the form of a String. A relevant property of a book (vendor, title, author, ISBN, etc) is added to the buffer in XML format. The following code excerpt demonstrates how book information is added to a buffer:
sb.append("<Vendor>"); sb.append("half.com"); sb.append("</Vendor>"); sb.append("<Price>"); sb.append(priceHalf); sb.append("</Price>"); sb.append("<Link>"); sb.append(halfUrl); sb.append("</Link>");

In the event of a successful book search, the assembled XML document within the buffer is edited. Certain characters in XML have special meaning to XML parsers and can be represented incorrectly in an XML document. Such characters include < , >, and &. Built-in entities must be employed to ensure correct representation. The ampersand is a commonly used URL character and therefore, CWS replaces all instances of & with &amp; to ensure accurate representation. The following code demonstrates the replacement process within the sb buffer:

40
int ind=sb.indexOf("&"); while(ind != -1){ sb.replace(ind,ind+1,"&amp;"); ind=sb.indexOf("&",ind+1); }

Finally, the toString() method of the StringBuffer class is invoked to change the entire buffer to a String and this String is returned to a client. If an unsuccessful book search occurs, CWS returns the following String:
"<?xml version=\"1.0\"?><Results><Books>No books found</Books></Results>"

In the event of an error, CWS returns:


"<?xml version=\"1.0\"?><Results><Error>Invalid search criteria</Error></Results>"

4.3.1.1 Deployment
Utilizing the Apache Axis 1.1 framework, there are two ways to deploy a web service: JWS instant deployment and WSDD custom deployment. CWS utilizes the JWS (Java Web Service) method of deployment which simply involves changing the extension of a java source file, BookServerImpl.java in this case, from .java to .jws and placing it into the Axis webapps folder. CWSWS can then be accessed via the following URL:
http://matrix.csis.pace.edu:23451/axis/BookServerImpl.jws

Moreover, the WSDL for CWSWS is accessed by adding ?wsdl to the above URL:
http://matrix.csis.pace.edu:23451/axis/BookServerImpl.jws?wsdl

Axis automatically compiles the class and dynamically generates the WSDL document.

The WSDD (Web Service Deployment Descriptor) method involves static deployment of a service. The steps are:

41
1) 2) 3) 4) 5) 6) 7) 8) creation of java source file and java interface creation of WSDD file, deploy.wsdd, specifying methods to be exposed and type mappings construct the WSDL file using Axis Java2WSDL tool generate server-side wrapper code and stubs using Axis WSDL2Java tool modify the xxxxSoapBindingImpl file with correct return statements and objects compile all class files (creation of jar file is optional) copy class files to the Axis/WEB-INF/lib folder start the server and deploy service using Axis AdminClient tool with deploy.wsdd

The WSDD-deployed service can then be accessed via the following hypothetical URL:
http://matrix.csis.pace.edu:23451/axis/services/XXXX

The WSDD-deployed service can be undeployed using the AdminClient tool with a autogenerated undeploy.wsdd file.

CWS utilizes JWS instead of the WSDD because of its simplicity, dynamic capabilities and loosely coupled structure. The WSDD method promotes a tightly coupled structure due to the presence of stubs and skeletons. Each time the underlying implementation changes, new glue code must be generated as well. David Bau states since automatic WSDL and stub-generation tools work by directly generating a message shape from a function signature (or vice versa), when you change your implementation code, it changes your public contract at the same time. [7].

4.3.2 CWS Client


A client has two options when invoking a JWS service. The first option is dynamic invocation in which a client uses Axis implementation of JAX-RPC. The services WSDL is not directly used, but can be referenced for endpoint, namespace, and operation

42 details. The second option is standard stub generation. In an effort to demonstrate CWSWS interoperability, a Java client and a .NET client (C# implementation) are presented. Both clients implement a graphical user interface (GUI) to facilitate use.

4.3.2.1

Java Client

The java client, CWSBookSearchClient, invokes CWSWS using dynamic invocation:


public void searchIsbn(String isbn) { String ret = null; try { Service service = new Service(); Call call = (Call) service.createCall(); call.setTargetEndpointAddress(new java.net.URL(endPoint)); call.setOperationName( new QName("BookServer", "searchIsbn") ); call.addParameter("isbn", XMLType.XSD_STRING,ParameterMode.IN); call.setReturnType(XMLType.XSD_STRING); ret = (String)call.invoke(new Object[] {isbn}); results.setText(ret); results.setCaretPosition(0); } catch (Exception e) { results.setText("Unable to process searchIsbn request at this time. Please try again."); } } // end searchIsbn method

After gathering and setting the endpoint, operation, parameter type, and return type information from the CWSWS WSDL, the service is invoked using the invoke() method of the Call class, which takes an array of Objects as a parameter. The CWSWS XML document is returned with a mandatory String cast.

43

4.3.2.2

.NET Client

The .NET client, cwsForm.cs, invokes CWSWS using stub (proxy) generation:
private void button1_Click(object sender, System.EventArgs e) { try{ display.Clear(); string result = null; BookServerImplService svc = new BookServerImplService(); if(!isbnx.Text.Equals("")) { result = svc.searchIsbn(isbnx.Text); display.AppendText(result);

The .NET framework provides a tool, wsdl.exe, for generating proxy classes for XML Web Services clients from WSDL contract files. The following command generates a proxy class, BookServerImplService.cs, from the CWS WSDL:
wsdl /out:BookServerImplService.cs http://matrix.csis.pace.edu:23451/axis/BookServerImpl.jws?wsdl

The client then creates an instance of the proxy class and simply calls the desired service method. The .NET client has no difficulty processing the String returned from the J2EE based CWSWS.

4.3.3 CWS Discovery


Numerous firms or operators provide public, UDDI registries and testing registries. A few of the most common include:
Operator HP Inquiry URL http://uddi.hp.com/inquire Publish URL https://uddi.hp.com/publish

IBM

http://www-.ibm.com/services/uddi/inquiryapi

https://www-3.ibm.com/services/uddi/protect/publishapi

IBM Test

http://www3.ibm.com/services/uddi/testregistry/inquiryapi

https://www3.ibm.com/services/uddi/testregistry/protect/publishapi

44
Microsoft http://uddi.microsoft.com/inquire https://uddi.microsoft.com/publish

Microsoft Test SAP Test

http://test.uddi.microsoft.com/inquire

https://test.uddi.microsoft.com/publish

http://udditest.sap.com/UDDI/api/inquiry/

https://udditest.sap.com/UDDI/api/publish/

Systinet

http://www.systinet.com/wasp/uddi/inquiry/

https://www.systinet.com/wasp/uddi/publishing/

Table 3: UDDI Registry Access Point URLs

UDDI registries can be accessed using an operators web interface via a browser or programmatically. Java developers can utilize SOAP APIs, custom Java-based UDDI client APIs (i.e. UDDI4J and WASP UDDI), and the Java API for XML Registries (JAXR). CWS utilizes Microsofts and IBMs UDDI registry for publishing and IBMs UDDI4J class library for queries.

4.3.3.1

Publishing CWS

CWS utilizes the web interfaces from Microsoft and IBM to register and publish CWS functionality. The process entails providing a business name, description, contact information, overview document (location of CWS WSDL file) and tModel data. Further data can be entered such as business relationships and categories, which refine the search process. The following is a screen capture of CWS data from the IBM registry:

45

Figure 7: CWS Data From IBM UDDI Registry

4.3.3.2

Performing a CWS Query

A CWS query can be performed using IBMs UDDI4J project. UDDI4J is a Java class library that provides an API that can be used to interact with a UDDI registry. The UDDI client implementation is derived from IBMs sample files from the UDDI4J kit and consists of three customized files:
FindCWS.java Configurator.java propCWS.properties

propCWS is a properties file which centralizes all the key information needed to interact

with a UDDI registry. This information includes usernames and passwords when publishing, the URLs for the inquiry and publish APIs of the target registry, SOAP

46 transport classes, security settings, and logging options. When a developer needs to access a different registry, one only has to alter the settings of the properties file. This is convenient and adds an additional layer of security.

Configurator is responsible for reading the properties file, setting the SOAP transport,

and configuring the SSL/JSSE provider.

FindCWS is the driver of the client application and performs a simple query based on

business name. FindCWS begins by enabling the Configurator to perform its duties via the creation of a Configurator object, config, then calling the load() method of
config. Once the correct environment settings are configured, FindCWS creates a UDDIProxy object, proxy. UDDIProxy is the central class in the UDDI4J class library

and represents a proxy for the UDDI server. Its methods map to the UDDI Version 2 API Specification (For details visit http://uddi.org/pubs/ProgrammersAPI_v2.htm). FindCWS then sets the URL for the inquiry API of the target registry, Microsoft UDDI registry in this case, as follows:
proxy.setInquiryURL(config.getProperty("inquiryURL"));

Next, FindCWS specifies the specific business name to be queried:


Vector names = new Vector(); names.add(new Name("CWS"));

Lastly, FindCWS adds a specific case sensitive qualifier to the query and calls the
find_business() method of the UDDIProxy class to initiate the query to the Microsoft

registry. Surprisingly, the client application returns two business names for CWS. This

47 is due to the fact that CWS is published with Microsoft and IBM, and the registries not only return data from their side, but from their companions as well.

Queries are not limited to just business names, but can include business descriptions, tModels, categories and a host of other criteria.

48

CHAPTER 5
5.1

CWS TEST CASES

Use Case Verification

The following is a summary of the use cases from Chapter 3:


Use Case 1: Primary Actor: System: Supporting Actor: Pre-Condition: Use Case 2: Primary Actor: System: Supporting Actor: Pre-Condition: Use Case 3: Primary Actor: System: Supporting Actor: Pre-Condition: Use Case 4: Primary Actor: System: Supporting Actor: Pre-Condition:

Search ISBN Student CWSUI Multiple vendors User has correct ISBN number Search AUTHOR and YEAR PUBLISHED Student CWSUI Amazon Web service User has correct author name and year of publication Invoke searchIsbn() method Java Client Application CWSWS Multiple vendors User has correct ISBN number Invoke searchAll() method .NET Client Application CWSWS Multiple vendors User has correct author name and year of publication

Each use case has been tested to verify if CWS can fulfill the specific requests for resources. Each test case number corresponds to each use case number. Test cases 1 and 2 have been tested using Microsofts Internet Explorer and Mozillas Firefox browsers. CWSUI is accessible at http://matrix.csis.pace.edu:23451/pace/index.jsp.

49
Test Case 1

A student is greeted with the CWS homepage which displays the user interface:

50 The student, shopping various prices for Steve Grahams Building Web Services with Java, enters the books correct ISBN number 0672326418:

51 After the student clicks on CWS Search, CWS successfully returns a book summary, sorted prices, and links from numerous vendors:

52
Test Case 2

A student searching for books written by Walter Savitch with a publication year of 2004 enters the data as follows:

53 After the student clicks on CWS Search, CWS successfully returns various books based on the students search parameters:

54 Regarding Test cases 1 and 3, in the event of an error, CWS displays the following:

55
Test Case 3

Launching the Java client application, CWSBookSearchClient, from the command line or from an IDE results in the display of a user interface:

56 A user of the application, shopping various prices for Microsoft .NET XML Web Services Step by Step written by Adam Freeman, enters the books correct ISBN number 0735617201:

57 After the user clicks the Search button, CWS successfully returns the following XML document:

58 The output displays a well formed XML document. The complete XML document is as follows:
<?xml version="1.0"?> <Results> <Book> <Title>Microsoft .NET XML Web Services Step by Step</Title> <Authors>Adam Freeman,Allen Jones,Adam Freeman</Authors> <Publisher>Microsoft Press</Publisher> <ISBN>0735617201</ISBN> <RetailPrice>39.99</RetailPrice> </Book> <Vendor>Amazon</Vendor> <Price>26.39</Price> <Link>http://www.amazon.com/exec/obidos/ASIN/0735617201</Link> <Vendor>Amazon-Used</Vendor> <Price>16.50</Price> <Link>http://www.amazon.com/exec/obidos/ASIN/0735617201</Link> <Vendor>Barnes and Noble</Vendor> <Price>31.99</Price> <Link>http://search.barnesandnoble.com/booksearch/isbnInquiry.asp?endeca=1&amp;isbn=07356 17201</Link> <Vendor>eCampus</Vendor> <Price>27.99</Price> <Link>http://www.ecampus.com/bk_detail.asp?ISBN=0735617201</Link> <Vendor>Powells</Vendor> <Price>20.80</Price> <Link>http://www.powells.com/cgi-bin/biblio?isbn=0735617201</Link> <Vendor>BiggerBooks</Vendor> <Price>27.43</Price> <Link>http://www.biggerbooks.com/bk_detail.asp?ISBN=0735617201</Link> <Vendor>BooksAMillion</Vendor> <Price>27.99</Price> <Link>http://www.booksamillion.com/ncom/books?isbn=0735617201</Link> <Vendor>AllDirect.com</Vendor> <Price>24.79</Price> <Link>http://www.alldirect.com/book.asp?isbn=0735617201</Link> <Vendor>VarsityBooks</Vendor> <Price>39.99</Price> <Link>http://www.varsitybooks.com/Search.aspx?SearchType=ISBN&amp;SearchValue=0735617 201</Link> <Vendor>half.com</Vendor> <Price>16.50</Price> <Link>http://half.ebay.com/search/search.jsp?&amp;product=books&amp;keyword=0735617201< /Link> </Results>

59
Test Case 4

Launching the .NET client application, cwsForm.cs, from the command line or from an IDE results in the display of a user interface:

60 A user of the application, searching for books written by M. Morris Mano with a publication year 1992, enters the information as follows:

61 After the user clicks on the Search button, CWS successfully returns the following XML document:

5.2

CWS vs. Current Book Brokers

5.2.1 Third Party Web Services


Xmethods.net is a popular Web site that offers a listing of third party web services. Only three Web services exist which provide book search functionality. One Web service,
BNPriceWS, returns Barnes and Noble book prices based on a client ISBN number

62 request. The Xmethods listing directs one to the publishers Web page at http://www.abundanttech.com/default.asp?content=WebServices/BNPrice/default.aspx. Initially, the Web service appears to be a legitimate resource for CWS to incorporate in its composite, Web service capabilities. However, when a test is performed on
BNPriceWS with an ISBN number of 0672326418, the following results are

disappointing:

63

If one compares BNPriceWS generated price to Barnes and Nobles actual price listed on their Web page, BNPriceWS does not provide accurate pricing. They provide the publishers list price, not Barnes and Nobles price. The screen captures above demonstrate that the correct Barnes and Noble price is $39.99, not $49.99.

The second Web service that provides book search functions is ISBNInformation, available at http://www.webservicex.net/isbn.asmx?op=GetISBNInformation, which returns in XML format basic book information such as title, author, publisher and year of publication, but does not provide any vendor prices.

Thirdly, BookService , available at http://www.winisp.net/cheeso/books/books.asmx, returns in XML format title, author, publisher, publication year and price information, but the service only quotes prices from Amazon.com.

64

5.2.2 BookFinder4u.com
BookFinder4u.com is a fierce competitor offering a great deal of functionality which includes price alerts, currency converter, and a broad scope of bookstores. CWS fails to match BookFinder4u in this regard. However, CWS does distinguish itself from BookFinder4u in two areas. One, BookFinder4u does not expose its functionality as a Web service. The only way to programmatically access this resource is via HTML scraping. Secondly, BookFinder4u does not allow a user to enter a combination of search parameters in their request. The following screen capture displays their search mechanism:

BookFinder4us radio button structure limits a users search to only one criteria. CWS enables a user to submit multiple search parameters in a single request resulting in a more refined and faster search response.

5.2.3 Chambal.com
Chambal.com is one step ahead of all book brokers by providing 13 digit ISBN search capabilities. Recently, the International Organization for Standardization (ISO) approved plans to transition from the existing 10 digit ISBN structure to a 13 digit ISBN structure [14]. The change is taking place because the supply of available 10 digit numbers is

65 exhausting. By January 1, 2007, all book and book-related products must carry 13 digit ISBN numbers. Currently, no other book brokers offer this functionality. CWS executes a 13 digit ISBN search request, but responses are limited to prices from Barnes and Noble and Booksamillion. However, Chambals advantage is short lived once Amazon and the other players update their systems for 13 digit ISBN compliance. Also, Chambal only provides ISBN, title and author search functionality, reducing the effectiveness of their search mechanism.

5.2.4 FetchBook.info
FetchBook.info provides a broad scope of bookstores, price alerts, currency converter, and customizable views of search results. However, they only allow keyword, title, author and ISBN search capabilities. Additionally, if a user submits a 13 digit ISBN request, the request is altered to a title-type request, probably due to a 10 digit form validation rule, with zero results.

66

CHAPTER 6
6.1

CONCLUSION

CWS Interoperability Solution

Certainly, CWS does not solve the interoperability problem at all levels, but has illustrated interoperability to a small degree between two different programming languages. The CWS solution itself has its disadvantages and advantages. One drawback behind returning an XML document as a String is that it lacks programming structure. Secondly, the burden of interpreting and parsing the XML response is placed on the client. Thirdly, the solution breaks down the layers of abstraction in the Web service stack and does not hide the complexities of the service, but exposes the implementation details.

On the positive side, the solution makes full use of the XML language. Any entity programming with XML parsing capability can utilize CWS as a resource. Also, the solution avoids some of the current, interoperability trouble spots, which include employing Java Collection classes and returning an array with null elements. Lastly, the solution omits the use of creating book instances of the BookBean class to optimize performance. By this omission, specifically the omission of the new keyword, this conserves server resources, reduces memory usage, and potential garbage collection. Overall, this optimization can increase performance between CWS and a client.

Furthermore, CWS raises a few key points. First, XML is the pivotal, underlying language that can connect disparate systems and lead to seamless interoperability. There must be some common ground allowing for two parties to communicate. XML provides

67 this. Secondly, the decision by WS-I through its Basic Profile 1.1 towards RPC-literal and Document-literal emphasizes a movement toward document passing Web service solutions. Thirdly, the CWS solution demonstrates that complexity is not always a required ingredient for every software solution. Security is one functionality that CWS does not need to operate since the data being sent by the client and server is publicly available. Fundamentally, CWS is passing XML documents over the HTTP wire. LaMonica states that sending XML documents over existing Internet protocols is suited for relatively simple applications. But businesses wanting the benefits of the flexible systems design called a services-oriented architecture should adopt Web services. [11] The important issue is to recognize the needs of the application and compose a solution based on those needs. Additional levels of complexity may be unwarranted. Lastly, the ability to aggregate various Web services into one higher-level Web service by way of process composition is an attractive feature, leading to more functionality and greater flexibility when business demands change.

6.2

Future of Web services

The future of Web services is difficult to forecast. Recent market research data and trends illustrate the outlook appears promising, but a few potential pitfalls must not be overlooked.

6.2.1 Market Research Statistics and Forecasts


An October 2004 Evans Data Corp survey [15] of over 400 developers finds that 60 percent of developers believe that Web services can be implemented at significantly

68 lower costs. Other findings specify that the top three services being developed with Web service technologies are business process management, data management, and ecommerce applications. According to the Yankee Group 2004 U.S. Enterprise Web Services Survey [Yankee], 65 percent of IT development budgets are addressing integration of systems, Web services are being widely used, but penetration is low, and enterprises are gearing up for higher spending on web services across all business processes. The Radicati Group Web Services Market, 2004-2008 Survey [9] affirms that the increase in Web service deployment is not limited to enterprises in the U.S., but all over the world Survey results point out that the majority of Web service deployments fall within the North American region, but are on the rise in Europe and Asia.

6.2.2 Potential Trends


The W3C XML Binary Characterization Working Group is exploring the possibility of creating a binary version of XML that is faster than the current text-based version of the standard. Since XML is designed to be read by both machines and humans, it results in message sizes that can easily be 10 to 50 times larger than equivalent messages sent via binary encodings. [12] A client and server XML conversation might require the following operations: decryption, validation, marshaling, parsing, canonicalization, document signing and encryption. Binary XML may reduce a lot of the overhead involved in data exchange.

69 Another potential trend Web services may experience in the future is the burial of the Web service stack into the application integration runtimes and tooling. The trend has actually started. BEA, IBM, Microsoft, Oracle, and others all have Web services firmly entrenched in the middleware infrastructure. [13] The following table lists additional potential Web services trends in the future: Rise of Service-Level Agreements Arrival of On Demand Computing Increasing Role of Portals Emergence of Value Networks Improved Security Standards Increasing Role of an Enterprise Service Bus Rise of Business Activity Monitoring (BAM) Adoption of Business Process Execution Language (BPEL)
Table 4: Future Trends in Web Services [13]

6.3

Potential Pitfalls

A few potential pitfalls that may limit the success of Web services are: semantic interoperability, interfacing to legacy systems and specification development. Web services are bringing us a step closer to seamless interoperability in a technical sense, by utilizing XML as the key intermediary language. However, Web services can not interpret the meaning of the actual data being sent in XML and therefore, fail to provide semantic interoperability. XML provides the common alphabet to communicate, but Web services themselves do not have an inherent understanding of the words and grammar of XML. [10] From a business standpoint, it would be beneficial for a Web service to be able to distinguish between an invoice or a work order and interpret it based on common business rules. If Web services fail to provide semantic

70 interoperability, this may result in passing the torch to another technology to solve the problem, reducing the effectiveness of Web services.

Interfacing to existing legacy systems has been an ongoing problem. Further findings from the October 2004 Evans Data Corp survey [15] of over 400 developers specify that legacy system interfacing is the biggest obstacle to web services by 20 percent of the respondents, compared with 8 percent a year ago. Failure to provide such a solution may put Web services into the same camp as its distributed predecessors of the past.

Lastly, the W3C is generating numerous specifications, which include hundreds of pages of technical guidelines. This makes it difficult for professionals to keep abreast of all the changes taking place. The ongoing process of specification development has caused consternation among some people, who claim that programmers and their employers cannot absorb the flow of new specifications. [11]. Moreover, as enterprises and vendors build applications now in an effort to acquire market share, if a W3C entity suddenly prohibits a specific technology, as is the case in the Basic Profile 1.1, this can be costly to enterprises and vendors who may have to go back to the drawing board in an effort to be compliant. Such parties are required to make educated guesses and build flexible systems to adapt to subsequent changes and avoid unnecessary expenses.

71

APPENDIX 1
Web service enabling products for Java

Vendor
Actional

Product
SOAP Switch

Type and Scope


Web service Integrator/Wrapper

Description
Provides a Service Oriented Architecture (SOA) bus. Wraps packages and applications as Web service providers and consumers. See Whitepaper

AltoWeb

Application Platform

Framework, server. J2EE, Choreography:

Framework enables J2EE/JSP/EJB/Web services and

BPM, EAI, Logic, EJB, portal development without J2EE JSP, Tags, SOAP, WAP, Portlets AmberPoint Management Foundation Web service Security and Monitoring, WS Security, SAML, XACML Apache XML SOAP SOAP API for Java; Tomcat, SSL Reference implementation of W3C SOAP, based on IBM SOAP4J.Follow-on to IBM SOAP4J project. See Feature list. Apache XML Axis 1.0 SOAP API for Java JAX-RPC, SAAJ compatible expertise. Supports WebLogic, WebSphere. Monitor Web services, enforce and streamlines security policies

with WSDL, JAX-RPC, SOAP/WSDL implementation SAAJ. Includes TCP monitor. See User Guide.

72
Atomikos TransactionsSOAP SOAP-based J2EE transactions Implements JTS/JTA transactions in the Web services environment based on Atomikos's TransactionsJTA product. BEA WebLogic EJB => WSDL Weblogic 6.1 exports WSDL from a stateless EJB. See Integration data sheet for latest developments. Bowstreet Business Web Portal Framework: SOAP, EJB, CORBA Cape Clear CapeStudio Web Services Development, integrated web Auto-creates Web services from existing enterprise components. Or design the service using the WSDL

services runtime: EJB, Editor. Once defined, CapeStudio JAVA, CORBA, WSDL, SOAP, UDDI, XML, XSL, XPATH provides tools enabling the automatic client creation (Java, VB and browser), Creation of serverside implementation. Mapping tool links XML-based systems with Web services applications. All tools come with and integrate with runtime environment for Web services. See Getting started with and other tutorial/demos page. CapeConnect Web service integrator, UDDI, SMTP, J2EE, SSL, MIME, XPATH, Web services platform. Generates WSDL from EJBs.

73
CORBA WSDL Assistant WSDL.=>EJB or Client: Java, VB Generates client proxy and server skeleton code from WSDL. See screen shot Data Access Component X Technologies RAD Tool; Supports ebXML, J2EE, .Net, MQ Series, CORBA Cross-platform, cross-technologies visual development tool with dragand-drop assembly. See screen shot and whitepaper and tutorial collection Develop Mentor SOAP SOAP API for Java An early implementation of SOAP (approximately version 0.9) from SOAPs originator, Develop Mentor also published SOAP versions for Perl and C++. Dorado OWare Web services ebyz Web Service Gateways Web services integration UDDI, JMS Web services integration (plus adaptors) ebys provides gateways to specific software such as Intuit, plus a toolkit and engine for building new Web service gateways. Integration with JBuilder and Forte for Java is provided. See the White Paper Epicentric Web Services RAD Tool, Portal Epicentric provides a RAD tool and Modeler, Adapters

Framework: EJB, JSP, extensive portal framework that Tags enables incorporation of external Web services. Please contact

74
Epicentric for details. HP HP e-speak Web services Web services platform RAD Tool, Web serivces integrator, choreography, EJB, ebXML, UDDI Creates and deploys Web services; derives Web services from EJBs. Provides interaction control (choreography) and messaging. For developer information see Trail map IBM Dynamic WSDK e-Business Web service integrator, HTTPR, PKI, alphaWorks: WS WSDK (Web services Tool Kit). See the IBM Dynamic e-Business Web site for a Web services overview for IBM. This is alphaWorks main Web services package. The WSDK handles proxy support and supports WebSphere 4.0 Web services. It now includes HTTPR is a more reliable form of HTTP. See WSDE RAD Tool, SQL WSDE: Web services development environment. Tool for Discovery, Build, map Web services, deploy on WebSphere or Tomcat, test, and publish to UDDI. Includes UDDI Browser. UDDI4J UDDI API for Java Programmatic interaction with UDDI Registry. See Overview WSIF Web service integrator Web services invocation framework. Tool to invoke a Web service (nonSOAP) See Web service invocation sans SOAP by Nirmal K. Mukhi

75
WSDL4J WSDL API for Java Web services description language for Java.Create, display, and edit WSDL. (0.8 release available with WSDK) IBM's implementing of JCP JSR 110. and (possibly JSR 109). See also Overview of WSDL James Kao WSPMT Process management Web services process management toolkit. TRL SOAP Envelope WebSphere App Server SOAP envelope API for Java Web services - J2EE integration. Company changed Idoox See SystInet names. Infravio WSMS Web service manager, Web Services Management System UDDI (WSMS) provides single point management of multiple Web services. See news release. and data sheet (PDF). Manages building, deployment and access using request broker. intelliun Virtual Enterprise RAD Tool and Web service framework: J2EE The framework Web service enables applications that are built using VE/Designer a UML compliant business modeling tool, and API for managing SOAP as a document

76
implementation on a J2EE-based server framework called VE/Server.

Insession

WebGate SOAPTP Web service integrator/secure connection, transactions.

Exposes EJB as a Web service and enables secure POS, ATM and mobile device transaction solutions.

IONA

XMLBus

Web service

Development environment, Auto

integrator, SSL, MIME, gen of SOAP clients, Platforms: RPC, CORBA, JMX IONA, WebLogic, WebSphere. See feature list.and XMLBus Learn for overviews. B2B Integrator Enterprise Integrator iopsis iNsight Web service messaging;EDI to XML RAD Tool, Web Integrated framework for Web

service EAI integrator, services and business process BPI choreography, UDDI publishing wizard and Web services consumer (ITell) integration; RAD add-on for Forte,V Cafe, JBuilder, DreamWeaver UltraDev. Platform on WebSphere, WebLogic, iPlanet, HP TeS. Has Windows connector W2One. See iNsight Data Sheet, Whitepaper (PDF)

77
JBoss ZOAP Web service integrator Dynamic serialization using SAX, for EJB transparent proxies, special fast proxies for XML-enabled clients. UDDI API for Java jUDDI.org jUDDI created by Bowstreet Killdara Vitiris Web Services-ready a Java UDDI API. Small footprint, for embedded use Was a pre-alpha project to produce

lightweight app server, with various industry XML payloads. J2ME, HTTPS, UDDI Their motto: "From now on, everything is a server" See White paper (PDF). Killdara also offers a health data application. Liberty Alliance Liberty Project Identity and registry based project. Federated interoperational identity solution for the Internet enabling single sign-on and AAA from any platform, and on-demand services. The Mind Electric Glue Web service integrator/manager, UDDI, WAP, XPATH, EJB, JMS GLUE provides abilities to create, deploy and consume Web services with an extensive yet highlevel API - see example. Runs stand-alone or inside an application server. Standard edition is free for most commercial use. Professional edition includes EJB, JMS integration and UDDI server. Enterprise edition includes transaction,load balancing, clustering. See feature matrix.

78
Oracle XDK for Java Web service integrator,SQL Combines a number of Oracle XML technology packages including Oracle SOAP, XSQL Servlet, XML Class generator, XML Schema processor, XSLT, XML SQL Utility, TransX Utility, and XML Parser Oracle9iAS Dynamic Services Polar Lake Polar Lake XPath Rule engine, See Using Oracle9iAS Dynamic Services and XML XML enabling desktop and server

XML Server with Web platform for J2EE that provides Web service support, SMTP services. SilverStream eXtend Workbench RAD Tool, Web service integrator, J2EE, RPC, JMS J2EE Web Services Integration tool - works with IDEs. jBroker enables SOAP message queuing. Has dynamic proxies (also packaged with SilverStream App Server).

RAD tool enables engineering WSDL from Java classes or EJB, has WSDL editor and Wizards, UDDI Manager, plus many J2EE dev features. See Product Matrix, eXtend Home Web services message Sonic SonicXQ integration:JMS, FTP, Message integration includes SSL, HTTPS, JCA, MQSeries, TIBCO. See datasheet Integrates with J2EE using J2EE Connection Architecture (JCA).

79
ebXML, ebXML, Sun Sun ONE (PDF)

Web services strategy Sun ONE (Open Network for Sun Microsystems Environment) is the umbrella that and reference Web describes the Java Web services

service impementation reference implementation. This for Java. consists of 1) Sun's iPlanet/Forte-centric Web services and 2) Java-based enabling solutions for Web services. See also Java Skyline: News: Sun ONE for overview. JAXM SOAP Messaging API JAXM is the Sun/JCP for Java JAXB implementation of JSR-067

XML Java Binding API Sun/JCP implementation of JSR031 may be used as basis of:

JAX-RPC

XML-RPC API for Java

Sun/JCP implementation of JSR101.

JAXR

UDDI Registry API for Sun/JCP implementation of JSRJava 093. Sun/JCP implementation of JSR093.

JAXP

XML Parsing API for Java

Long Term Bean Persistence

XML bean persistence Enables serialization of Java bean API for Java as an XML entity. Sun/JCP implementation of JSR-057.

Sun/iPlanet

Integration

Web service message A family of products (Integration

80
Services integrator Server EAI, Integration Server B2B, Message Queue for Java). See iPlanet's Family enable Web services from top to bottom [pdf] Sybase B2Bi B2Bi Web service message Allegedly to be demonstrated at Fall integrator, JMS, ebXML Comdex: A Web services enabled messaging system that is ebXML capable. Systinet WASP for Java Web service integrator: MIME, Systinet publishes a series of Web service tools and has this product

Product matrix Advanced

HTTP 1.1, SSL, GSS; comparison matrix that explains EJB, JMS, JDBC, JNDI, JTA their features. WASP Advanced implements pluggable transports, remote references. Works with JNDI to expose EJB, JMS integration. See WASP Advanced Data Sheet, WASP/J2EE Tutorial WASP UDDI Standard WASP Advanced + UDDI V 2.0 API WASP UDDI has the features of WASP Advanced plus UDDI. Provides browser access and test UDDI registry. Supports Oracle, PostGres. WASP Lite Web service integrator Free commercial version of WASP, includes Wasp Tools, works with J2SE - but does not have advanced J2EE integration.

81
WASP Developer (a.k.a WASP Tools,Stardust) RAD Tools for J2EE Distributed with WASP Lite. Works

Integration, UDDI, and with Forte (JBuilder in beta) WSDL. Provides server, client, SOAP debugging environment. See WASP Tools: Getting Started

WASP JavaScript SOAP Client Talking Blocks

Web service client: Javascript

See live demo

Talking Blocks 2.0 Web service contract manager: J2EE

Provides contract management of both internal Web services plus J2EE integration, substitution, and load balancing.

Versata

Versata for Web Services

BPM, Logic Framework

Exposes simple Web services; consumes Web services; coordinates multiple Web services.

Velocigen

VelocigenX

Web service integrator Web Services- EJB Wrapper, and EJB, SOAP generation tool, XML Mapping.

Velocigen

VelocigenX Enterprise

Web service integrator Web Services- EJB Wrapper and EJB, SOAP Generation tool

WebMethods B2BI WestGlobal mScape Web service manager Tool to manage Web services. Works on IONA, WebSphere, WebLogic, iPlanet; Messaging: TIBCO. See Technical Specs WSUI.Org WSUI RI Web services manager: WSUI JSP/Java API Reference Implementation for "Web services User Interface," a layer that provides usage information for

82
reference implementation WSDL

Table 2 Web service enabling products for Java Competitors

Vendor
Apple

Product

Type: Platform, Scope

Description

AppleScript Web services client: Mac See Scripting a SOAP request samples. RPC Borland BizSnap OS X Web service integrator: Apache, Linux, Kylix, Delphi See Kylix news and datasheet (PDF). Borland is also working on a Java Web services implementation. See Borland Web services Microsoft .Net, .Net Framework SDK Overall Web service Microsoft's new overall software

strategy: Windows NT, 2K, framework for Web service XP development with C#, VB.Net, Foxpro, (and maybe J#) See Simply SOAP.by Roger Wolter

SOAP Toolkit Mirus NetHesive

Web service integrator: Win32 Web service integrator: Apache, DLL

Complex messages; analyzes WSDL, See SOAP Toolkit Documentation Provides Web services (as Apache Web server extension) to native libraries in XML.- See Win32 example. Supports SOAP 1.2. See Overview, What is

Phalanxsys WSDL

COM => WSDL

Provides Web services capabilities for

83
Wizard pre-.Net MS software. Phalanxsys is also developing other Web service products. pocketSOAP pocketSOAP Web service integrator: Project integrates with UserLand

SSL, WSDL=>VB, Pocket Manilla and is working on a PC, Manilla PythonWare Soap for Python Web service integrator: RPC Web services for Python. Capabilities described in ZSI documentation: Zolera Soap Infrastructure SoapLite Soap::Lite for Perl Web service messaging: Also provides non-blocking TCP, COM SchemaTron WSDL validator

Python Web SOAPpy and Web service integrator: Services ZSI Python, MIME, UDDI

MQ, Jabber, RPC HTTPS. interface. Supports SMTP, POP3 for eMail.

UserLand

Frontier

Content manager/scripter with Web service integrator: Mac OS X, Win32, RPC

SOAP RPC WhiteMesa Server

Web service integrator: Win32, COM

84

APPENDIX 2
Index.jsp
<%@page contentType="text/html"%> <%@page pageEncoding="UTF-8"%> <html> <head><title>CWS.com Book Search</title></head> <body bgcolor="#BDB76B"> <center> <img src= "http://matrix.csis.pace.edu:23451/pace/logo.GIF" alt="CWS.com"> <p> <table width="80%" border="0" cellspacing="0" cellpadding="5"> <tr> <td align=center> <a href = "http://matrix.csis.pace.edu:23451/pace/aboutus.jsp" > <img src = "http://matrix.csis.pace.edu:23451/pace/about.GIF" name=aboutus alt="About Us"</a> </td> <td align=center> <a href = "mailto:mr13204w@pace.edu" </a> <img src = "http://matrix.csis.pace.edu:23451/pace/contact.GIF" name=contact alt="Contact Us"</a> </td> <td align=center> <a href = "http://matrix.csis.pace.edu:23451/pace/index.jsp" > <img src = "http://matrix.csis.pace.edu:23451/pace/home.GIF" name=home alt = "Home"</a> </td> </tr> </table> <h3><i>CWS.com is the ideal place to shop for the best book prices from various bookstores around the world</i></h3>

<p> <p> <table border="10"> <form name= advsearch method=post action="http://matrix.csis.pace.edu:23451/pace/servlet/Controller" ID="form"> <tr valign=middle> <td align=left><font face="verdana,arial,helvetica" size=1><strong>Author:</strong></font></td> <td align=left><input type=text name=author value="" size=40></td> </tr> <tr valign=middle> <td align=left><font face="verdana,arial,helvetica" size=1><strong>Title:</strong></font></td> <td align=left><input type=text name=title value="" size=40></td> </tr> <tr valign=middle> <td align=left><font face="verdana,arial,helvetica" size=1><strong>Publisher:</strong></font></td> <td align=left><input type=text name=publisher value="" size=40></td> </tr>

85
<tr valign=middle> <td align=left><font face="verdana,arial,helvetica" size=-1><strong>Publish Year:&nbsp;&nbsp;</strong></font></td> <td align=left><input type=text name=year value="" size=40></td> </tr> <tr valign=middle> <td align=left><font face="verdana,arial,helvetica" size=1><strong>Subject:</strong></font></td> <td align=left><input type=text name=subject value="" size=40></td> </tr> <tr valign=middle> <td align=left><font face="verdana,arial,helvetica" size=1><strong>Keyword:</strong></font></td> <td align=left><input type=text name=keyword value_u34 ?" size=40></td> </tr> <tr valign=middle> <td align=left><font face="verdana,arial,helvetica" size=1><strong>ISBN:</strong></font></td> <td align=left><input type=text name=isbn value="" size=40></td> </tr> <tr valign=middle> <td>&nbsp;</td> <td>&nbsp;&nbsp;&nbsp;&nbsp;<input type=submit value="CWS Search" > &nbsp;&nbsp;&nbsp;&nbsp;<input type =reset value="Clear" ></td> </tr> </form> </table> <p>

<h6 align=center>Copyright 2005 CWS.com. All rights reserved.</h6></center> </body> </html>

86

APPENDIX 3
Results.jsp
<%@page contentType="text/html"%> <%@page pageEncoding="UTF-8"%> <%@page import="java.util.*, java.text.*, CWS.BookBean" %> <jsp:useBean id="bookList" class="java.util.Vector" scope="session"/> <jsp:useBean id="decoy" class="java.util.Vector" scope="session"/> <html> <head><title>CWS.com Book Search</title></head> <body bgcolor="#BDB76B"> <center> <img src="http://matrix.csis.pace.edu:23451/pace/logo.GIF" alt="CWS.com"> <p> <table width="80%" border="0" cellspacing="0" cellpadding="5"> <tr> <td align=center> <a href = "http://matrix.csis.pace.edu:23451/pace/aboutus.jsp"> <img src = "http://matrix.csis.pace.edu:23451/pace/about.GIF" name=aboutus alt="About Us"</a> </td> <td align=center> <a href = "mailto:mr13204w@pace.edu" </a> <img src = "http://matrix.csis.pace.edu:23451/pace/contact.GIF" name=contact alt="Contact Us"</a> </td> <td align=center> <a href = "http://matrix.csis.pace.edu:23451/pace/index.jsp" > <img src = "http://matrix.csis.pace.edu:23451/pace/home.GIF" name=home alt = "Home"</a> </td> </tr> </table> <h3><i>CWS.com is the ideal place to shop for the best book prices from various bookstores around the world</i></h3> <p> <p> <a href="http://matrix.csis.pace.edu:23451/pace/index.jsp"> Click Here for New Search</a> <h3 align=center>The results of your search are:</h3> <p> <p> <% if (!bookList.isEmpty()){ DecimalFormat decFor = new DecimalFormat("#0.00"); decFor.setMaximumFractionDigits(2);%> <center> <table border="10" bgcolor="#ffff99"> <tr> <td rowspan="20"><img src="<%= ((BookBean) decoy.elementAt(0)).getCover()%>"></td></tr> <tr> <td><b><font face="Verdana"><%= ((BookBean) decoy.elementAt(0)).getTitle()%></font></b></td></tr> <tr> <td><b><font face="Verdana">Author(s):&nbsp&nbsp<%= ((BookBean) decoy.elementAt(0)).getAuthor()%></font></b></td></tr> <tr> <td><b><font face="Verdana">Publisher:&nbsp&nbsp<%= ((BookBean) decoy.elementAt(0)).getPublisher()%></font></b></td></tr>

87
<tr> <td><b><font face="Verdana">ISBN:&nbsp&nbsp<%= ((BookBean) decoy.elementAt(0)).getIsbn()%></font></b></td></tr> <tr> <td><b><font face="Verdana">Retail Price:&nbsp$<%=decFor.format( ((BookBean) decoy.elementAt(0)).getRetail())%></font></b></td></tr> </table> </center> <p> <p> <table align="center" border="0" cellpadding="0" width="100%" bgcolor="#ffff99"> <tr> <td align=center><b><u>VENDOR</u></b></td> <td align=center><b><u>CURRENT PRICE</u></b></td> <td align=center><b><u>PURCHASE BOOK</u></b></td> </tr> <% for (int index=0; index < bookList.size(); index++) { %> <tr> <td align=center><b><%= ((BookBean) bookList.elementAt(index)).getVendor() %></b></td> <td align=center><font color="#cc0000">$<%= decFor.format( ((BookBean) bookList.elementAt(index)).getPrice() ) %></font></td> <td align=center><a href = "<%= ((BookBean) bookList.elementAt(index)).getBuyLink()%>"> <img src = "<%= ((BookBean) decoy.elementAt(0)).getCoverSmall()%>" name=cover alt = "Purchase Book"</a></td> </tr> <% } %> </table> <% } else out.println("Sorry, your book search was unsuccessful. Please try again."); %> <% bookList.removeAllElements(); session.invalidate(); decoy.removeAllElements();%> <a href="http://matrix.csis.pace.edu:23451/pace/index.jsp"> Click Here for New Search</a> <hr> <p> <h6 align=center>Copyright 2005 CWS.com. All rights reserved.</h6></center> </body> </html>

88

APPENDIX 4
Controller.java
import import import import import import import import java.io.*; java.util.*; //for Vector java.net.*; //for URL,URLConnection javax.servlet.*; javax.servlet.http.*; javax.xml.parsers.*; org.w3c.dom.*; org.xml.sax.*;

import CWS.BookBean; public class Controller extends HttpServlet { public void init(ServletConfig config) throws ServletException { super.init(config); } protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { HttpSession session = request.getSession(true); String []author = request.getParameterValues("author"); //author: String []title = request.getParameterValues("title"); //title: String []publisher = request.getParameterValues("publisher"); //publisher: String []year = request.getParameterValues("year"); // pubdate: String []subject = request.getParameterValues("subject"); //subject: String []keyword = request.getParameterValues("keyword"); //keywrod: String []isbn = request.getParameterValues("isbn"); if ( (author[0].equals("") && title[0].equals("") && publisher[0].equals("") && year[0].equals("") && subject[0].equals("") && keyword[0].equals("") && isbn[0].equals("")) || (author[0].equals(" ") || title[0].equals(" ") || publisher[0].equals(" ") || year[0].equals(" ") || subject[0].equals(" ") || keyword[0].equals(" ") && isbn[0].equals(" ")) ) { String err = "Invalid search criteria entered."; session.setAttribute("err", err); ServletConfig cfg = this.getServletConfig(); ServletContext thisCxt = cfg.getServletContext(); RequestDispatcher rd = thisCxt.getRequestDispatcher( "/error.jsp" ); rd.forward( request, response ); } else{ Vector bookList = new Vector(); Vector decoy = new Vector(); //response.setContentType( "text/html" ); //PrintWriter out = response.getWriter(); String temp= "&PowerSearch="; boolean onlyISBN = false; if( !(isbn[0].equals("")) ){ onlyISBN = true; searchIsbn(isbn,bookList); if ( (!(bookList.isEmpty()) ) ){ decoy.add(0,bookList.elementAt(0));

89
session.setAttribute("decoy", decoy); } } else{ if(!(author[0].equals("")) ) temp = temp + "author:" + normalize(author); if(!(title[0].equals("")) && !(author[0].equals("")) ) temp = temp + "%20title:" + normalize(title); else if (!(title[0].equals(""))) temp = temp + "title:" + normalize(title); else; if(!(publisher[0].equals("")) && (!(title[0].equals("")) || !(author[0].equals("") )) ) temp = temp + "%20publisher:" + normalize(publisher); else if(!(publisher[0].equals(""))) temp = temp + "publisher:" + normalize(publisher); else; if(!(year[0].equals("")) && (!(publisher[0].equals("")) || !(title[0].equals("")) || !(author[0].equals("") ) )) temp = temp + "%20pubdate:" + normalize(year); else if (!(year[0].equals(""))) temp = temp + "pubdate:" + normalize(year); else; if(!(subject[0].equals("")) && (!(year[0].equals("")) || !(publisher[0].equals("")) || !(title[0].equals("")) || !(author[0].equals("") )) ) temp = temp + "%20subject:" + normalize(subject); else if (!(subject[0].equals(""))) temp = temp + "subject:" + normalize(subject); else; if(!(keyword[0].equals("")) && (!(subject[0].equals("")) || !(year[0].equals("")) || !(publisher[0].equals("")) || !(title[0].equals("")) || !(author[0].equals("") ) )) temp = temp + "%20keywords:" + normalize(keyword); else if (!(keyword[0].equals(""))) temp = temp + "keywords:" + normalize(keyword); else; amazon(temp, "Other", bookList); } if( (!(bookList.isEmpty() ))) Collections.sort(bookList); session.setAttribute("bookList", bookList); if(onlyISBN){ RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/results.jsp"); dispatcher.forward(request,response); } else{ RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/search.jsp"); dispatcher.forward(request,response); } } } protected void doGet(HttpServletRequest request, HttpServletResponse response)

90
throws ServletException, IOException { HttpSession session = request.getSession(true); Vector bookList = new Vector(); if( request.getParameter("textboxget") == null || request.getParameter("textboxget").equals("") ) { String err = "No option was selected."; session.setAttribute("err", err); ServletConfig cfg = this.getServletConfig(); ServletContext thisCxt = cfg.getServletContext(); RequestDispatcher rd = thisCxt.getRequestDispatcher( "/error.jsp" ); rd.forward( request, response ); } else{ String []searchTextGet = request.getParameterValues("textboxget");

searchIsbn(searchTextGet,bookList); if( (!(bookList.isEmpty() ))){ Vector decoy = new Vector(); decoy.add(0,bookList.elementAt(0)); session.setAttribute("decoy", decoy); } if( (!(bookList.isEmpty() ))) Collections.sort(bookList); session.setAttribute("bookList", bookList); RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/results.jsp"); dispatcher.forward(request,response); } } private void searchIsbn(String []isb, Vector bookList) throws ServletException, IOException { // remove dashes,spaces,etc String s = ""; for(int i = 0; i<isb.length; i++){ s = s + isb[i]; } StringTokenizer st = new StringTokenizer(s," ",false); String temp=""; while (st.hasMoreElements()) temp += st.nextElement(); st = new StringTokenizer(temp,"-",false); String temp2=""; while (st.hasMoreElements()) temp2 += st.nextElement(); String isbn = temp2; String x = "&PowerSearch=isbn:"+isbn; amazon(x,"ISBN",bookList); barnes(isbn,bookList); ecampus(isbn,bookList); powells(isbn,bookList); biggerBooks(isbn,bookList); booksMillion(isbn,bookList); blackwell(isbn,bookList); allDirect(isbn,bookList); deals(isbn,bookList); varsity(isbn,bookList); half(isbn,bookList); } // end searchIsbn method

private void amazon(String searchType, String format, Vector bookList) throws ServletException, IOException{

91
//amazon using xml over http String associatesID = "webservices-20"; String devToken = "DTC9V1J0AUUYV"; String mode = "books"; String type = "lite"; String amazonUrl= "http://xml.amazon.com/onca/xml3?t=" + associatesID + "&dev-t=" + devToken + searchType + "&mode=" + mode + "&offer=All&type=" + type +"&page=1&f=xml"; String tempPrice = null; String tempRetail = null; URL amazon = new URL(amazonUrl); URLConnection urlconn = amazon.openConnection(); urlconn.setDoInput(true); InputStream in = urlconn.getInputStream(); //parse amazon xml file Document doc = null; try { DocumentBuilderFactory docBuilderFact = DocumentBuilderFactory.newInstance(); DocumentBuilder docBuilder = docBuilderFact.newDocumentBuilder(); doc = docBuilder.parse(in); } catch (SAXException saxEx) {return;} catch (ParserConfigurationException pc) {return;} NodeList error = doc.getElementsByTagName("ErrorMsg"); if(error.item(0) != null){ if( error.item(0).getFirstChild().getNodeValue().equals("There are no exact matches for the search.")) return; } if(format.equals("ISBN")){ NodeList productName = doc.getElementsByTagName("ProductName"); NodeList imageMed = doc.getElementsByTagName("ImageUrlMedium"); NodeList imageSmall = doc.getElementsByTagName("ImageUrlSmall"); NodeList ourPrice = doc.getElementsByTagName("OurPrice"); NodeList usedPrice = doc.getElementsByTagName("UsedPrice"); NodeList retailPrice = doc.getElementsByTagName("ListPrice"); NodeList publisher = doc.getElementsByTagName("Manufacturer"); NodeList author = doc.getElementsByTagName("Author"); NodeList isbnq = doc.getElementsByTagName("Asin"); // in case of multiple authors StringBuffer sb = new StringBuffer(); for (int i = 0; i < author.getLength(); i++) { if (i != 0) sb.append(','); sb.append(author.item(i).getFirstChild().getNodeValue()); } if(ourPrice.getLength()!=0){ BookBean book = new BookBean(); book.setVendor("Amazon"); if(productName.getLength()>0) book.setTitle( productName.item(0).getFirstChild().getNodeValue()); if(imageMed.getLength()>0) book.setCover( imageMed.item(0).getFirstChild().getNodeValue()); if(imageSmall.getLength()>0) book.setCoverSmall(imageSmall.item(0).getFirstChild().getNodeValue()); tempPrice = ourPrice.item(0).getFirstChild().getNodeValue(); tempPrice = tempPrice.substring(1); book.setPrice(Double.parseDouble(tempPrice)); if(retailPrice.getLength()>0){ tempRetail = retailPrice.item(0).getFirstChild().getNodeValue();

92
tempRetail = tempRetail.substring(1); book.setRetail(Double.parseDouble(tempRetail)); }if(publisher.getLength()>0) book.setPublisher( publisher.item(0).getFirstChild().getNodeValue() ); book.setAuthor(sb.toString()); if(isbnq.getLength()>0) book.setIsbn( isbnq.item(0).getFirstChild().getNodeValue() ); book.setBuyLink("http://www.amazon.com/exec/obidos/ASIN/"+ book.getIsbn()); bookList.addElement(book); }// end inner if if(usedPrice.getLength()!=0){ BookBean book = new BookBean(); book.setVendor("Amazon-Used"); if(productName.getLength()>0) book.setTitle( productName.item(0).getFirstChild().getNodeValue() ); if(imageMed.getLength()>0) book.setCover( imageMed.item(0).getFirstChild().getNodeValue() ); if(imageSmall.getLength()>0) book.setCoverSmall(imageSmall.item(0).getFirstChild().getNodeValue() ); tempPrice = usedPrice.item(0).getFirstChild().getNodeValue(); tempPrice = tempPrice.substring(1); book.setPrice(Double.parseDouble(tempPrice)); if(retailPrice.getLength()>0){ tempRetail = retailPrice.item(0).getFirstChild().getNodeValue(); tempRetail = tempRetail.substring(1); book.setRetail(Double.parseDouble(tempRetail)); } if(publisher.getLength()>0) book.setPublisher( publisher.item(0).getFirstChild().getNodeValue() ); book.setAuthor(sb.toString()); if(isbnq.getLength()>0) book.setIsbn( isbnq.item(0).getFirstChild().getNodeValue() ); book.setBuyLink("http://www.amazon.com/exec/obidos/ASIN/"+ book.getIsbn()); bookList.addElement(book); } // end inner if } // end outer if else{ NodeList totalPages = doc.getElementsByTagName("TotalPages"); NodeList productName = doc.getElementsByTagName("ProductName"); NodeList imageSmall = doc.getElementsByTagName("ImageUrlSmall"); NodeList publisher = doc.getElementsByTagName("Manufacturer"); NodeList year = doc.getElementsByTagName("ReleaseDate"); NodeList isbnq = doc.getElementsByTagName("Asin"); NodeList authors = doc.getElementsByTagName("Authors"); int pages = Integer.parseInt(totalPages.item(0).getFirstChild().getNodeValue()); if (pages > 50) pages = 50; int pagesLeft = pages - 1; for(int z = 0; z < productName.getLength(); z++){ BookBean book = new BookBean(); if(productName.item(z) != null) book.setTitle( productName.item(z).getFirstChild().getNodeValue()); if(imageSmall.item(z) != null) book.setCoverSmall(imageSmall.item(z).getFirstChild().getNodeValue()); if(publisher.item(z) != null) book.setPublisher( publisher.item(z).getFirstChild().getNodeValue() ); else book.setPublisher( "Unavailable"); if(year.item(z) != null) book.setYear( year.item(z).getFirstChild().getNodeValue() );

93
else book.setYear( "Unavailable");

if(isbnq.item(z) != null) book.setIsbn( isbnq.item(z).getFirstChild().getNodeValue() ); String aa=""; if(authors.item(z) != null){ Element element = (Element) authors.item(z); NodeList author = element.getElementsByTagName("Author"); for (int c = 0; c < author.getLength(); c++) { Element line = (Element) author.item(c); aa = aa + getCharacterDataFromElement(line)+" "; } book.setAuthor(aa); } else book.setAuthor("NA"); bookList.addElement(book); } // end for loop // get more pages if any for(int m = 1; m <= pagesLeft; m++){ int count = m+1; String amUrl = "http://xml.amazon.com/onca/xml3?t="+ associatesID + "&dev-t=" + devToken + searchType + "&mode=" + mode +"&offer=All&type=" + type + "&page=" + count+"&f=xml"; amazon = new URL(amUrl); urlconn = amazon.openConnection(); urlconn.setDoInput(true); in = urlconn.getInputStream(); //parse amazon xml file doc = null; try { DocumentBuilderFactory docBuilderFact = DocumentBuilderFactory.newInstance(); DocumentBuilder docBuilder = docBuilderFact.newDocumentBuilder(); doc = docBuilder.parse(in); } catch (SAXException saxEx) {throw new ServletException("wrong xml", saxEx); } catch (ParserConfigurationException pc) { throw new ServletException("Servletexception, check jaxp configuration", pc);} totalPages = doc.getElementsByTagName("TotalPages"); productName = doc.getElementsByTagName("ProductName"); imageSmall = doc.getElementsByTagName("ImageUrlSmall"); publisher = doc.getElementsByTagName("Manufacturer"); year = doc.getElementsByTagName("ReleaseDate"); isbnq = doc.getElementsByTagName("Asin"); authors = doc.getElementsByTagName("Authors"); for(int z = 0; z < productName.getLength(); z++){ BookBean book = new BookBean(); if(productName.item(z) != null) book.setTitle( productName.item(z).getFirstChild().getNodeValue()); if(imageSmall.item(z) != null) book.setCoverSmall(imageSmall.item(z).getFirstChild().getNodeValue()); if(publisher.item(z) != null) book.setPublisher( publisher.item(z).getFirstChild().getNodeValue() ); else book.setPublisher( "Unavailable");

94
if(year.item(z) != null) book.setYear( year.item(z).getFirstChild().getNodeValue() ); else book.setYear( "Unavailable"); if(isbnq.item(z) != null) book.setIsbn( isbnq.item(z).getFirstChild().getNodeValue() ); String aa=""; if(authors.item(z) != null){ Element element = (Element) authors.item(z); NodeList author = element.getElementsByTagName("Author"); for (int c = 0; c < author.getLength(); c++) { Element line = (Element) author.item(c); aa = aa + getCharacterDataFromElement(line)+" "; } book.setAuthor(aa); } else book.setAuthor("NA"); bookList.addElement(book); } // end for loop } // end out for loop // end inner else

} // end amazon method private void barnes(String key, Vector bookList) throws ServletException, IOException{ String barnesUrl = "http://search.barnesandnoble.com/booksearch/isbnInquiry.asp?endeca=1&isbn="+ key; String inputBn = scrape(barnesUrl); if(inputBn.equals(null))return; String bnPivotPrice = "priceRightBNPrice\">"; String priceNew, priceUsed = null; String bnPivotPriceNew, bnPivotPriceUsed = null; int start,end,bnPivotStartNew,bnPivotStartUsed = 0; bnPivotStartNew = inputBn.indexOf(bnPivotPrice); bnPivotStartUsed = inputBn.lastIndexOf(bnPivotPrice); if( bnPivotStartNew == -1 && bnPivotStartUsed == -1 ); else{ if(bnPivotStartNew > -1){ BookBean book = new BookBean(); //get barnes new price start = inputBn.indexOf("$",bnPivotStartNew); end = inputBn.indexOf(".",start); priceNew = inputBn.substring(start+1,end+3); book.setPrice(Double.parseDouble(priceNew)); book.setVendor("Barnes & Noble"); book.setBuyLink(barnesUrl); bookList.addElement(book); } if(bnPivotStartUsed > -1 && bnPivotStartUsed != bnPivotStartNew){ BookBean book = new BookBean(); //get barnes used price start = inputBn.indexOf("$",bnPivotStartUsed); end = inputBn.indexOf("</SPAN>",bnPivotStartUsed); priceUsed = inputBn.substring(start+1,end); book.setPrice(Double.parseDouble(priceUsed)); book.setVendor("Barnes & Noble-Used"); book.setBuyLink(barnesUrl); bookList.addElement(book); } // inner if } // end else } // end barnes method

95
private void ecampus(String key, Vector bookList) throws ServletException, IOException{ String ecUrl = "http://www.ecampus.com/bk_detail.asp?ISBN="+key; String inputEc = scrape(ecUrl); if(inputEc.equals(null))return; String ecPivot = "Our Price"; String priceEc = null; String listPrice = null; int start,end,ecPivotStart = 0; ecPivotStart = inputEc.indexOf(ecPivot); if( ecPivotStart == -1); else{ //get ecamp price BookBean book = new BookBean(); start = inputEc.indexOf("$",ecPivotStart); end = inputEc.indexOf("</font>",start); priceEc = inputEc.substring(start+1,end); book.setPrice(Double.parseDouble(priceEc)); book.setVendor("eCampus"); book.setBuyLink(ecUrl); bookList.addElement(book); } // end else } // end ecampus method private void powells(String key, Vector bookList) throws ServletException, IOException{ String powUrl = "http://www.powells.com/cgi-bin/biblio?isbn="+key; String inputPow = scrape(powUrl); if(inputPow.equals(null))return; String powPivot = "<FONT FACE=\"Verdana, Helvetica, Arial, sans-serif\" COLOR=\"#990000\" SIZE=\"3\">"; String pricePow = null; int start,end,powPivotStart = 0; powPivotStart = inputPow.indexOf(powPivot); if( powPivotStart == -1); else{ //get price BookBean book = new BookBean(); start = inputPow.indexOf("$",powPivotStart); end = inputPow.indexOf("<",start); pricePow = inputPow.substring(start+1,end); book.setPrice(Double.parseDouble(pricePow)); book.setVendor("Powells"); book.setBuyLink(powUrl); bookList.addElement(book); } // end else

} // end powells method private void biggerBooks(String key, Vector bookList) throws ServletException, IOException{ String bigUrl = "http://www.biggerbooks.com/bk_detail.asp?ISBN="+key; String inputBig = scrape(bigUrl); if(inputBig.equals(null))return; String bigPivot = "Our Price"; String bigPivotRetail = "List Price"; String priceBig = null; String listPrice = null; int start,end,bigPivotStartPrice,bigPivotStartRetail = 0; bigPivotStartPrice = inputBig.indexOf(bigPivot); bigPivotStartRetail = inputBig.indexOf(bigPivotRetail); if( bigPivotStartPrice == -1); else{

96
//get price BookBean book = new BookBean(); start = inputBig.indexOf("$",bigPivotStartPrice); end = inputBig.indexOf("</span>",start); priceBig = inputBig.substring(start+1,end); book.setPrice(Double.parseDouble(priceBig)); book.setVendor("BiggerBooks"); book.setBuyLink(bigUrl); bookList.addElement(book); // end else

} // end biggerBooks method private void booksMillion(String key, Vector bookList) throws ServletException, IOException{ String milUrl = "http://www.booksamillion.com/ncom/books?isbn="+key; String inputMil = scrape(milUrl); if(inputMil.equals(null))return; String milPivot = "Our Price"; String priceMil = null; int start,end,milPivotStart = 0; milPivotStart = inputMil.indexOf(milPivot); if( milPivotStart == -1); else{ //get price BookBean book = new BookBean(); start = inputMil.indexOf("$",milPivotStart); end = inputMil.indexOf("</B>",start); priceMil = inputMil.substring(start+1,end); book.setPrice(Double.parseDouble(priceMil)); book.setVendor("BooksAMillion"); book.setBuyLink(milUrl); bookList.addElement(book); } // end else } // end booksMillion method private void blackwell(String key, Vector bookList) throws ServletException, IOException{ String blackUrl = "http://bookshop.blackwell.com/bobus/scripts/home.jsp?action=search&type=isbn&t erm="+key; String inputBlack = scrape(blackUrl); if(inputBlack.equals(null))return; String blackPivot = "strong"; String priceBlack = null; int start,end,blackPivotStart,blackPivotStartRetail = 0; blackPivotStart = inputBlack.indexOf(blackPivot); if( blackPivotStart == -1); else{ //get price BookBean book = new BookBean(); start = inputBlack.indexOf("$",blackPivotStart); end = inputBlack.indexOf("</B>",start); priceBlack = inputBlack.substring(start+1,end); book.setPrice(Double.parseDouble(priceBlack)); book.setVendor("Blackwell's"); book.setBuyLink(blackUrl); bookList.addElement(book); } // end else } // end blackwell method private void allDirect(String key, Vector bookList) throws ServletException, IOException{ String allUrl = "http://www.alldirect.com/book.asp?isbn="+key;

97
String inputAll = scrape(allUrl); if(inputAll.equals(null))return; String allPivot = "Direct's Price"; String priceAll = null; int start,end,allPivotStart,allPivotStartRetail = 0; allPivotStart = inputAll.indexOf(allPivot); if( allPivotStart == -1); else{ //get price BookBean book = new BookBean(); start = inputAll.indexOf("$",allPivotStart); end = inputAll.indexOf("</FONT>",start); priceAll = inputAll.substring(start+1,end); book.setPrice(Double.parseDouble(priceAll)); book.setVendor("AllDirect.com"); book.setBuyLink(allUrl); bookList.addElement(book); } // end else

} // end allDirect method private void deals(String key, Vector bookList) throws ServletException, IOException{ String dealUrl = "http://www.dealsdealsdeals.com/itemdetail.cfm?sku="+key; String inputDeal = scrape(dealUrl); if(inputDeal.equals(null))return; String dealPivot = "Our Price"; String priceDeal = null; int start,end,dealPivotStart,dealPivotStartRetail = 0; dealPivotStart = inputDeal.indexOf(dealPivot); if( dealPivotStart == -1); else{ //get price BookBean book = new BookBean(); start = inputDeal.indexOf("$",dealPivotStart); end = inputDeal.indexOf("</span>",start); priceDeal = inputDeal.substring(start+1,end); try{ book.setPrice(Double.parseDouble(priceDeal));} catch (NumberFormatException nfe){return;} book.setVendor("dealsdealsdeals.com"); book.setBuyLink(dealUrl); bookList.addElement(book); } // end else } // end deals method private void varsity(String key, Vector bookList) throws ServletException, IOException{ String varUrl = "http://www.varsitybooks.com/Search.aspx?SearchType=ISBN&SearchValue="+key; String inputVar = scrape(varUrl); if(inputVar.equals(null))return; String varPivot = "New Book"; String priceVar = null; int start,end,varPivotStart = 0; varPivotStart = inputVar.indexOf(varPivot); if( varPivotStart == -1); else{ //get price BookBean book = new BookBean(); start = inputVar.indexOf(">",varPivotStart); end = inputVar.indexOf("</span>",start); priceVar = inputVar.substring(start+1,end); book.setPrice(Double.parseDouble(priceVar));

98
book.setVendor("VarsityBooks"); book.setBuyLink(varUrl); bookList.addElement(book); // end else

} // end varsity method private void half(String key, Vector bookList) throws ServletException, IOException{ String halfUrl = "http://half.ebay.com/search/search.jsp?&product=books&keyword="+key; String inputHalf = scrape(halfUrl); if(inputHalf.equals(null))return; String halfPivot = "Best&nbsp;Price"; String priceHalf = null; int start,end,halfPivotStart,halfPivotStartRetail = 0; halfPivotStart = inputHalf.indexOf(halfPivot); if( halfPivotStart == -1); else{ //get price BookBean book = new BookBean(); start = inputHalf.indexOf("$",halfPivotStart); end = inputHalf.indexOf("</b>",start); priceHalf = inputHalf.substring(start+1,end); book.setPrice(Double.parseDouble(priceHalf)); book.setVendor("half.com"); book.setBuyLink(halfUrl); bookList.addElement(book); } // end else } // end half method

private String scrape(String locale) { String ll = locale; try{ URL u = new URL(ll); URLConnection urlconnx = u.openConnection(); urlconnx.setDoInput(true); InputStream inx = urlconnx.getInputStream(); BufferedReader bb = new BufferedReader(new InputStreamReader(u.openStream())); StringBuffer sb = new StringBuffer(); String input; while(((input = bb.readLine()) != null)) sb.append(input); bb.close(); input = sb.toString(); return input; }catch(IOException ie){return null;} } private String getCharacterDataFromElement(Element e) { Node child = e.getFirstChild(); if (child instanceof CharacterData) { CharacterData cd = (CharacterData) child; return cd.getData(); } return "Unknown"; } private String normalize(String []norm){ String ttt = ""; StringTokenizer t = new StringTokenizer(norm[0]," "); while(t.hasMoreTokens()){ ttt = ttt + t.nextToken() + "%20";

99
} int last = ttt.lastIndexOf("%20"); ttt = ttt.substring(0, last); return ttt; }

// end Controller class

100

APPENDIX 5
BookBean.java
package CWS; public class BookBean implements Comparable private String vendor; private double price; private String buyLink; private String title; private String cover; private String coverSmall; private double retail; private String publisher; private String year; private String author; private String isbn; {

/** Creates a new instance of BookBean */ public BookBean() { vendor=""; price=0.0; buyLink=""; title=""; cover="http://matrix.csis.pace.edu:23451/pace/noCoverM.jpg"; coverSmall="http://matrix.csis.pace.edu:23451/pace/noCoverS.bmp"; retail =0.0; publisher=""; year=""; author=""; isbn=""; } public void setVendor(String strv) { vendor=strv; } public String getVendor() { return vendor; } public void setPrice(double strp) { price=strp; } public double getPrice() { return price; } public void setBuyLink(String strb) { buyLink=strb; } public String getBuyLink() { return buyLink; } public void setTitle(String strt) { title=strt; } public String getTitle() { return title; } public void setCover(String strc) { cover=strc; } public String getCover() { return cover;

101
} public void setCoverSmall(String strcs) { coverSmall=strcs; } public String getCoverSmall() { return coverSmall; } public void setRetail(double strr) { retail=strr; } public double getRetail() { return retail; } public void setPublisher(String strpp) { publisher=strpp; } public String getPublisher() { return publisher; } public void setYear(String stry) { year=stry; } public String getYear() { return year; } public void setAuthor(String stra) { author=stra; } public String getAuthor() { return author; } public void setIsbn(String stri) { isbn=stri; } public String getIsbn() { return isbn; } public int compareTo(Object otherObject) throws ClassCastException { if (!(otherObject instanceof BookBean)) throw new ClassCastException("A BookBean object is expected."); BookBean anotherBook = (BookBean)otherObject; if(price < anotherBook.price) return -1; if(price > anotherBook.price) return 1; return 0; } }

102

APPENDIX 6
Error.jsp
<%@page contentType="text/html"%> <%@page pageEncoding="UTF-8"%> <html> <head><title>CWS.com Book Search</title></head> <body bgcolor="#BDB76B"> <center> <img src= "http://matrix.csis.pace.edu:23451/pace/logo.GIF" alt="CWS.com"> <p> <table width="80%" border="0" cellspacing="0" cellpadding="5"> <tr> <td align=center> <a href = "http://matrix.csis.pace.edu:23451/pace/aboutus.jsp" > <img src = "http://matrix.csis.pace.edu:23451/pace/about.GIF" name=aboutus alt="About Us"</a> </td> <td align=center> <a href = "mailto:mr13204w@pace.edu" </a> <img src = "http://matrix.csis.pace.edu:23451/pace/contact.GIF" name=contact alt="Contact Us"</a> </td> <td align=center> <a href = "http://matrix.csis.pace.edu:23451/pace/index.jsp" > <img src = "http://matrix.csis.pace.edu:23451/pace/home.GIF" name=home alt = "Home"</a> </td> </tr> </table>

<p> <p> <h2 align=center> <% String err = (String)session.getAttribute("err"); out.println(err); session.invalidate();%><br> <a href="http://matrix.csis.pace.edu:23451/pace/index.jsp">Click here to search again.</a> </h2> </body> </html>

103

APPENDIX 7
Search.jsp
<%@page contentType="text/html"%> <%@page pageEncoding="UTF-8"%> <%@page import="java.util.*, CWS.BookBean" %> <jsp:useBean id="bookList" class="java.util.Vector" scope="session"/> <html> <head><title>CWS.com Book Search</title></head> <body bgcolor="#BDB76B"> <center> <img src= "http://matrix.csis.pace.edu:23451/pace/logo.GIF" alt="CWS.com"> <p> <table width="80%" border="0" cellspacing="0" cellpadding="5"> <tr> <td align=center> <a href = "http://matrix.csis.pace.edu:23451/pace/aboutus.jsp" > <img src = "http://matrix.csis.pace.edu:23451/pace/about.GIF" name=aboutus alt="About Us"</a> </td> <td align=center> <a href = "mailto:mr13204w@pace.edu" </a> <img src = "http://matrix.csis.pace.edu:23451/pace/contact.GIF" name=contact alt="Contact Us"</a> </td> <td align=center> <a href = "http://matrix.csis.pace.edu:23451/pace/index.jsp" > <img src = "http://matrix.csis.pace.edu:23451/pace/home.GIF" name=home alt = "Home"</a> </td> </tr> </table> <hr> <h3><i>CWS.com is the ideal place to shop for the best book prices from various bookstores around the world</i></h3> <hr> <hr> <p> <% if (!bookList.isEmpty()){ int display = 20; int start = 0; String begin = request.getParameter("start"); try {start = Integer.parseInt(begin);} catch (Exception ex) {} int end = start + display;%> <a href="http://matrix.csis.pace.edu:23451/pace/index.jsp"> Click Here for New Search</a> <center> <h3 align=center><font color="#990000"> CWS search found <%= bookList.size()%> book(s):</h3> <p> <table align="center" border="0" cellpadding="0" width="100%" bgcolor="#ffff99"> <form name=shop action="http://matrix.csis.pace.edu:23451/pace/servlet/Controller" id="formx" method=get> <% if (end > bookList.size() ){ %> <tr><td><font color="#990000">Results <%= start+1 %>-<%= bookList.size() %></font></td></tr>

104
<% for (int index=start; index < bookList.size(); index++) { %> <tr><td align=left><hr><img src="<%= ((BookBean) bookList.elementAt(index)).getCoverSmall()%>"></td></tr> <tr><td align=left><%= ((BookBean) bookList.elementAt(index)).getTitle() %></td></tr> <tr><td align=left>Author(s):&nbsp&nbsp<%= ((BookBean) bookList.elementAt(index)).getAuthor() %></td></tr> <tr><td align=left>Publisher:&nbsp&nbsp<%= ((BookBean) bookList.elementAt(index)).getPublisher() %></td></tr> <tr><td align=left>ISBN:&nbsp&nbsp<%= ((BookBean) bookList.elementAt(index)).getIsbn() %></td></tr> <% if(bookList.size() == 1) { %> <tr><td align=left><input type="radio" name=textboxget value="<%= ((BookBean) bookList.elementAt(index)).getIsbn()%>"> <%} else { %> <tr><td align=left><input type="radio" name=textboxget value="<%= ((BookBean) bookList.elementAt(index)).getIsbn()%>"> <% } %> <input type="submit" value="Shop Prices!"></td></tr> <% } } else { %> <tr><td><font color="#990000">Results <%= start+1 %>-<%= end-1 %></font></td></tr> <% for (int index=start; index < end; index++) { %> <tr><td align=left><hr><img src="<%= ((BookBean) bookList.elementAt(index)).getCoverSmall()%>"></td></tr> <tr><td align=left><%= ((BookBean) bookList.elementAt(index)).getTitle() %></td></tr> <tr><td align=left>Author(s):&nbsp&nbsp<%= ((BookBean) bookList.elementAt(index)).getAuthor() %></td></tr> <tr><td align=left>Publisher:&nbsp&nbsp<%= ((BookBean) bookList.elementAt(index)).getPublisher() %></td></tr> <tr><td align=left>ISBN:&nbsp&nbsp<%= ((BookBean) bookList.elementAt(index)).getIsbn() %></td></tr> <% if(bookList.size() == 1) { %> <tr><td align=left><input type="radio" name=textboxget value="<%= ((BookBean) bookList.elementAt(index)).getIsbn()%>"> <%} else { %> <tr><td align=left><input type="radio" name=textboxget value="<%= ((BookBean) bookList.elementAt(index)).getIsbn()%>"> <% } %> <input type="submit" value="Shop Prices!"></td></tr> <% } %> <table align="center"> <a href="<%= request.getRequestURI() %>?start=<%= end %>">Next <%= display %> results</a> </table> <% } %> </form> </table> <% } else out.println("Sorry, your book search was unsuccessful. Please try again."); %> <br> <hr> <p> <a href="http://matrix.csis.pace.edu:23451/pace/index.jsp"> Click Here for New Search</a> </body> </html>

105

APPENDIX 8
CWS.wsdl
<?xml version="1.0" encoding="UTF-8"?> <wsdl:definitions targetNamespace="http://matrix.csis.pace.edu:23451/axis/BookServerImpl.jws" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="http://matrix.csis.pace.edu:23451/axis/BookServerImpl.jws" xmlns:intf="http://matrix.csis.pace.edu:23451/axis/BookServerImpl.jws" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <wsdl:message name="searchAllResponse"> <wsdl:part name="searchAllReturn" type="xsd:string"/> </wsdl:message> <wsdl:message name="searchAllRequest"> <wsdl:part name="author" type="xsd:string"/> <wsdl:part name="title" type="xsd:string"/> <wsdl:part name="publisher" type="xsd:string"/> <wsdl:part name="year" type="xsd:string"/> <wsdl:part name="subject" type="xsd:string"/> <wsdl:part name="keyword" type="xsd:string"/> </wsdl:message> <wsdl:message name="searchIsbnResponse"> <wsdl:part name="searchIsbnReturn" type="xsd:string"/> </wsdl:message> <wsdl:message name="searchIsbnRequest"> <wsdl:part name="isbn" type="xsd:string"/> </wsdl:message> <wsdl:portType name="BookServerImpl"> <wsdl:operation name="searchIsbn" parameterOrder="isbn"> <wsdl:input message="impl:searchIsbnRequest" name="searchIsbnRequest"/> <wsdl:output message="impl:searchIsbnResponse" name="searchIsbnResponse"/> </wsdl:operation> <wsdl:operation name="searchAll" parameterOrder="author title publisher year subject keyword"> <wsdl:input message="impl:searchAllRequest" name="searchAllRequest"/> <wsdl:output message="impl:searchAllResponse" name="searchAllResponse"/> </wsdl:operation> </wsdl:portType> <wsdl:binding name="BookServerImplSoapBinding" type="impl:BookServerImpl"> <wsdlsoap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/> <wsdl:operation name="searchIsbn"> <wsdlsoap:operation soapAction=""/> <wsdl:input name="searchIsbnRequest"> <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://DefaultNamespace" use="encoded"/> </wsdl:input> <wsdl:output name="searchIsbnResponse"> <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://matrix.csis.pace.edu:23451/axis/BookServerImpl.jws" use="encoded"/> </wsdl:output> </wsdl:operation> <wsdl:operation name="searchAll"> <wsdlsoap:operation soapAction=""/> <wsdl:input name="searchAllRequest">

106
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://DefaultNamespace" use="encoded"/> </wsdl:input> <wsdl:output name="searchAllResponse"> <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://matrix.csis.pace.edu:23451/axis/BookServerImpl.jws" use="encoded"/> </wsdl:output> </wsdl:operation> </wsdl:binding> <wsdl:service name="BookServerImplService"> <wsdl:port binding="impl:BookServerImplSoapBinding" name="BookServerImpl"> <wsdlsoap:address location="http://matrix.csis.pace.edu:23451/axis/BookServerImpl.jws"/> </wsdl:port> </wsdl:service> </wsdl:definitions>

107

APPENDIX 9
Aboutus.jsp
<%@page contentType="text/html"%> <%@page pageEncoding="UTF-8"%> <html> <head><title>CWS.com Book Search</title></head> <body bgcolor="#BDB76B"> <center> <img src= "http://matrix.csis.pace.edu:23451/pace/logo.GIF" alt="CWS.com"> <p> <table width="80%" border="0" cellspacing="0" cellpadding="5"> <tr> <td align=center> <a href = "http://matrix.csis.pace.edu:23451/pace/aboutus.jsp" > <img src = "http://matrix.csis.pace.edu:23451/pace/about.GIF" name=aboutus alt="About Us"</a> </td> <td align=center> <a href = "mailto:mr13204w@pace.edu" </a> <img src = "http://matrix.csis.pace.edu:23451/pace/contact.GIF" name=contact alt="Contact Us"</a> </td> <td align=center> <a href = "http://matrix.csis.pace.edu:23451/pace/index.jsp" > <img src = "http://matrix.csis.pace.edu:23451/pace/home.GIF" name=home alt = "Home"</a> </td> </tr> </table> <p> <h1>About our Firm</h1> <p align=left> CWS.com, a small firm headquarterd in New York City, has been in business for over 20 years. We specialize in providing Web Service tools for consumers all over the world. These tools range from public interfaces to applicationto-application functionality. CWS.com provides one stop shopping from numerous vendors which include Amazon, Ebay and Barnes and Noble. Enjoy Shopping with CWS.com.!!!!!!!!!!!!<br> <br> <br> Michael Ryan CEO

</body> </html>

108

APPENDIX 10
BookServerImpl.jws
import import import import import import java.io.*; java.util.*; //for Vector java.net.*; //for URL,URLConnection javax.xml.parsers.*; org.w3c.dom.*; org.xml.sax.*;

public class BookServerImpl implements IBookSearch { public String searchIsbn(String isbn) { StringBuffer sb = new StringBuffer(); sb.append("<?xml version=\"1.0\"?>"); sb.append("<Results>"); // remove dashes,spaces,etc StringTokenizer st = new StringTokenizer(isbn," ",false); String temp=""; while (st.hasMoreElements()) temp += st.nextElement(); st = new StringTokenizer(temp,"-",false); String temp2=""; while (st.hasMoreElements()) temp2 += st.nextElement(); isbn = temp2; String x = "&PowerSearch=isbn:"+isbn; try{ amazon(x,"ISBN",sb); barnes(isbn,sb); ecampus(isbn,sb); powells(isbn,sb); biggerBooks(isbn,sb); booksMillion(isbn,sb); blackwell(isbn,sb); allDirect(isbn,sb); deals(isbn,sb); varsity(isbn,sb); half(isbn,sb); sb.append("</Results>"); }catch (IOException io){} if(sb.length() == 0){ sb = null; sb.append("<?xml version=\"1.0\"?><Results><Books>No </Results>"); return sb.toString(); } else{ int ind=sb.indexOf("&"); while(ind != -1){ sb.replace(ind,ind+1,"&amp;"); ind=sb.indexOf("&",ind+1); } return sb.toString(); } } // end searchIsbn method

books

found

</Books>

public String searchAll(String author,String title, String publisher, String year, String subject, String keyword) { StringBuffer sb = new StringBuffer();

109
if ( (author.equals("") && title.equals("") && publisher.equals("") && year.equals("") && subject.equals("") && keyword.equals("")) || (author.equals(" ") || title.equals(" ") || publisher.equals(" ") || year.equals(" ") || subject.equals(" ") || keyword.equals(" ")) ) { sb.append("<?xml version=\"1.0\"?><Results><Error>Invalid search criteria </Error> </Results>"); return sb.toString(); } else{ String temp = "&PowerSearch="; if(!(author.equals("")) ) temp = temp + "author:" + normalize(author); if(!(title.equals("")) && !(author.equals("")) ) temp = temp "%20title:" + normalize(title); else if (!(title.equals(""))) temp = temp+"title:"+ normalize (title); else; if(!(publisher.equals("")) && (!(title.equals("")) !(author.equals("") )) ) temp = temp + "%20publisher:" + normalize(publisher); else if(!(publisher.equals(""))) temp = temp + "publisher:" normalize(publisher); else; if(!(year.equals("")) && (!(publisher.equals("")) !(title.equals("")) || !(author.equals("") ) )) temp = temp + "%20pubdate:" + normalize(year); else if (!(year.equals(""))) temp = temp + "pubdate:" normalize(year); else; if(!(subject.equals("")) && (!(year.equals("")) !(publisher.equals("")) || !(title.equals("")) || !(author.equals("") )) ) temp = temp + "%20subject:" + normalize(subject); else if (!(subject.equals(""))) temp = temp + "subject:" normalize(subject); else; if(!(keyword.equals("")) && (!(subject.equals("")) !(year.equals("")) || !(publisher.equals("")) || !(title.equals("")) !(author.equals("") ) )) temp = temp + "%20keywords:" + normalize(keyword); else if (!(keyword.equals(""))) temp = temp + "keywords:" normalize(keyword); else; try{amazon(temp, "Other", sb);}catch(IOException io){} if(sb.length() == 0){ sb.append("<?xml version=\"1.0\"?><Results><Books>No found</Books></Results>"); return sb.toString(); } else{ int ind=sb.indexOf("&"); while(ind != -1){ sb.replace(ind,ind+1,"&amp;"); ind=sb.indexOf("&",ind+1); } return sb.toString(); } // end inner else

||

||

||

|| ||

books

110
} // end outer else // end searchAll method

private void amazon(String searchType, String format, StringBuffer sb) throws IOException{ String associatesID = "webservices-20"; String devToken = "DTC9V1J0AUUYV"; String mode = "books"; String type = "lite"; String amazonUrl= "http://xml.amazon.com/onca/xml3?t=" + associatesID + "&dev-t=" + devToken + searchType + "&mode=" + mode + "&offer=All&type=" + type +"&page=1&f=xml"; String tempPrice = null; String tempRetail = null; URL amazon = new URL(amazonUrl); URLConnection urlconn = amazon.openConnection(); urlconn.setDoInput(true); InputStream in = urlconn.getInputStream(); //parse amazon xml file Document doc = null; try { DocumentBuilderFactory docBuilderFact DocumentBuilderFactory.newInstance(); DocumentBuilder docBuilder = docBuilderFact.newDocumentBuilder(); doc = docBuilder.parse(in); } catch (SAXException saxEx) {} catch (ParserConfigurationException pc) {}

NodeList error = doc.getElementsByTagName("ErrorMsg"); if(error.item(0) != null){ if( error.item(0).getFirstChild().getNodeValue().equals("There are no exact matches for the search.")) return; } if(format.equals("ISBN")){ NodeList productName = doc.getElementsByTagName("ProductName"); NodeList imageMed = doc.getElementsByTagName("ImageUrlMedium"); NodeList imageSmall = doc.getElementsByTagName("ImageUrlSmall"); NodeList ourPrice = doc.getElementsByTagName("OurPrice"); NodeList usedPrice = doc.getElementsByTagName("UsedPrice"); NodeList retailPrice = doc.getElementsByTagName("ListPrice"); NodeList publisher = doc.getElementsByTagName("Manufacturer"); NodeList author = doc.getElementsByTagName("Author"); NodeList isbnq = doc.getElementsByTagName("Asin"); // in case of multiple authors StringBuffer sa = new StringBuffer(); for (int i = 0; i < author.getLength(); i++) { if (i != 0) sa.append(','); sa.append(author.item(i).getFirstChild().getNodeValue()); } sb.append("<Book>"); if(productName.getLength()>0){ sb.append("<Title>"); sb.append(productName.item(0).getFirstChild().getNodeValue()); sb.append("</Title>"); sb.append("<Authors>"); sb.append(sa.toString()); sb.append("</Authors>"); }

111
if(publisher.getLength()>0){ sb.append("<Publisher>"); sb.append(publisher.item(0).getFirstChild().getNodeValue() ); sb.append("</Publisher>"); } if(isbnq.getLength()>0){ sb.append("<ISBN>"); sb.append( isbnq.item(0).getFirstChild().getNodeValue() ); sb.append("</ISBN>"); } if(retailPrice.getLength()>0){ sb.append("<RetailPrice>"); tempRetail = retailPrice.item(0).getFirstChild().getNodeValue(); tempRetail = tempRetail.substring(1); sb.append(tempRetail); sb.append("</RetailPrice>"); } sb.append("</Book>"); if(ourPrice.getLength()!=0){ sb.append("<Vendor>Amazon</Vendor>"); tempPrice = ourPrice.item(0).getFirstChild().getNodeValue(); tempPrice = tempPrice.substring(1); sb.append("<Price>"); sb.append(tempPrice); sb.append("</Price>"); sb.append("<Link>"); sb.append("http://www.amazon.com/exec/obidos/ASIN/" + isbnq.item(0).getFirstChild().getNodeValue()); sb.append("</Link>"); } // end inner if if(usedPrice.getLength()!=0){ sb.append("<Vendor>Amazon-Used</Vendor>"); tempPrice = usedPrice.item(0).getFirstChild().getNodeValue(); tempPrice = tempPrice.substring(1); sb.append("<Price>"); sb.append(tempPrice); sb.append("</Price>"); sb.append("<Link>"); sb.append("http://www.amazon.com/exec/obidos/ASIN/"+ isbnq.item(0).getFirstChild().getNodeValue() ); sb.append("</Link>"); } // end inner if // outer if

else{ NodeList totalPages = doc.getElementsByTagName("TotalPages"); NodeList productName = doc.getElementsByTagName("ProductName"); NodeList imageSmall = doc.getElementsByTagName("ImageUrlSmall"); NodeList publisher = doc.getElementsByTagName("Manufacturer"); NodeList isbnq = doc.getElementsByTagName("Asin"); NodeList authors = doc.getElementsByTagName("Authors"); NodeList year = doc.getElementsByTagName("ReleaseDate"); NodeList error2 = doc.getElementsByTagName("ErrorMsg"); if(error2.item(0) != null){ if( error2.item(0).getFirstChild().getNodeValue().equals("There are no exact matches for the search.")) return; } int pages = Integer.parseInt(totalPages.item(0).getFirstChild().getNodeValue());

112
if (pages > 50) pages = 50; int pagesLeft = pages - 1; sb.append("<?xml version=\"1.0\"?>"); sb.append("<Results>"); for(int z = 0; z < productName.getLength(); z++){ sb.append("<Book>"); sb.append("<Title>"); if(productName.item(z) != null){ sb.append( productName.item(z).getFirstChild().getNodeValue()); sb.append("</Title>"); } sb.append("<Authors>"); String aa=""; if(authors.item(z) != null){ Element element = (Element) authors.item(z); NodeList author = element.getElementsByTagName("Author"); for (int c = 0; c < author.getLength(); c++) { Element line = (Element) author.item(c); aa = aa + getCharacterDataFromElement(line)+" "; } sb.append(aa); } else sb.append("NA"); sb.append("</Authors>"); sb.append("<Publisher>"); if(publisher.item(z) != null){ sb.append(publisher.item(z).getFirstChild().getNodeValue() ); } else sb.append("Unavailable"); sb.append("</Publisher>"); sb.append("<PublishYear>"); if(year.item(z) != null){ sb.append( year.item(z).getFirstChild().getNodeValue() ); } else sb.append("Unavailable"); sb.append("</PublishYear>"); sb.append("<ISBN>"); if(isbnq.item(z) != null){ sb.append(isbnq.item(z).getFirstChild().getNodeValue()); } else sb.append("NA"); sb.append("</ISBN>"); sb.append("</Book>"); // end for loop

// get more pages if any for(int m = 1; m <= pagesLeft; m++){ int count = m+1; String amUrl ="http://xml.amazon.com/onca/xml3?t=" + associatesID + "&dev-t=" + devToken + searchType + "&mode="+mode+"&offer=All&type="+type+"&page="+count+"&f=xml"; amazon = new URL(amUrl); urlconn = amazon.openConnection(); urlconn.setDoInput(true); in = urlconn.getInputStream(); //parse amazon xml file doc = null; try { DocumentBuilderFactory docBuilderFact =

113
DocumentBuilderFactory.newInstance(); DocumentBuilder docBuilder = docBuilderFact.newDocumentBuilder(); doc = docBuilder.parse(in); } catch(SAXException saxEx){} catch (ParserConfigurationException pc) {} totalPages = doc.getElementsByTagName("TotalPages"); productName = doc.getElementsByTagName("ProductName"); imageSmall = doc.getElementsByTagName("ImageUrlSmall"); publisher = doc.getElementsByTagName("Manufacturer"); isbnq = doc.getElementsByTagName("Asin"); authors = doc.getElementsByTagName("Authors"); year = doc.getElementsByTagName("ReleaseDate"); for(int z = 0; z < productName.getLength(); z++){ sb.append("<Book>"); sb.append("<Title>"); if(productName.item(z) != null){ sb.append( productName.item(z).getFirstChild().getNodeValue()); sb.append("</Title>"); } sb.append("<Authors>"); String aa=""; if(authors.item(z) != null){ Element element = (Element) authors.item(z); NodeList author = element.getElementsByTagName("Author"); for (int c = 0; c < author.getLength(); c++) { Element line = (Element) author.item(c); aa = aa + getCharacterDataFromElement(line)+" "; } sb.append(aa); } else sb.append("NA"); sb.append("</Authors>"); sb.append("<Publisher>"); if(publisher.item(z) != null){ sb.append(publisher.item(z).getFirstChild().getNodeValue() ); } else sb.append("Unavailable"); sb.append("</Publisher>"); sb.append("<PublishYear>"); if(year.item(z) != null){ sb.append( year.item(z).getFirstChild().getNodeValue() ); } else sb.append("Unavailable"); sb.append("</PublishYear>"); sb.append("<ISBN>"); if(isbnq.item(z) != null){ sb.append(isbnq.item(z).getFirstChild().getNodeValue()); } else sb.append("NA"); sb.append("</ISBN>"); sb.append("</Book>"); } // end for loop

114
} // end out for loop sb.append("</Results>"); // end inner else // end amazon method

} }

private void barnes(String key, StringBuffer sb) throws IOException{ String barnesUrl = "http://search.barnesandnoble.com/booksearch/isbnInquiry.asp?endeca=1&isbn="+ key; String inputBn = scrape(barnesUrl); if(inputBn.equals(null))return; String bnPivotPrice = "priceRightBNPrice\">"; String priceNew, priceUsed = null; String bnPivotPriceNew, bnPivotPriceUsed = null; int start,end,bnPivotStartNew,bnPivotStartUsed = 0; bnPivotStartNew = inputBn.indexOf(bnPivotPrice); bnPivotStartUsed = inputBn.lastIndexOf(bnPivotPrice); if( bnPivotStartNew == -1 && bnPivotStartUsed == -1 ); else{ if(bnPivotStartNew > -1){ sb.append("<Vendor>"); sb.append("Barnes and Noble"); sb.append("</Vendor>"); //get barnes new price start = inputBn.indexOf("$",bnPivotStartNew); end = inputBn.indexOf(".",start); priceNew = inputBn.substring(start+1,end+3); sb.append("<Price>"); sb.append(priceNew); sb.append("</Price>"); sb.append("<Link>"); sb.append("http://search.barnesandnoble.com/booksearch/isbnInquiry.asp?endeca=1 &isbn="+ key); sb.append("</Link>"); } if(bnPivotStartUsed > -1 && bnPivotStartUsed != bnPivotStartNew){ sb.append("<Vendor>"); sb.append("Barnes & Noble-Used"); sb.append("</Vendor>"); //get barnes used price start = inputBn.indexOf("$",bnPivotStartUsed); end = inputBn.indexOf("</SPAN>",bnPivotStartUsed); priceUsed = inputBn.substring(start+1,end); sb.append("<Price>"); sb.append(priceUsed); sb.append("</Price>"); sb.append("<Link>"); sb.append("http://search.barnesandnoble.com/booksearch/isbnInquiry.asp?endeca=1 &isbn="+ key); sb.append("</Link>"); } // inner if } // end else } // end barnes method private void ecampus(String key, StringBuffer sb) throws IOException{ String ecUrl = "http://www.ecampus.com/bk_detail.asp?ISBN="+key; String inputEc = scrape(ecUrl); if(inputEc.equals(null))return; String ecPivot = "Our Price"; String priceEc = null;

115
String listPrice = null; int start,end,ecPivotStart = 0; ecPivotStart = inputEc.indexOf(ecPivot); if( ecPivotStart == -1); else{ //get ecamp price sb.append("<Vendor>"); sb.append("eCampus"); sb.append("</Vendor>"); start = inputEc.indexOf("$",ecPivotStart); end = inputEc.indexOf("</font>",start); priceEc = inputEc.substring(start+1,end); sb.append("<Price>"); sb.append(priceEc); sb.append("</Price>"); sb.append("<Link>"); sb.append(ecUrl); sb.append("</Link>"); } // end else } // end ecampus method private void powells(String key, StringBuffer sb) throws IOException{ String powUrl = "http://www.powells.com/cgi-bin/biblio?isbn="+key; String inputPow = scrape(powUrl); if(inputPow.equals(null))return; String powPivot = "<FONT FACE=\"Verdana, Helvetica, Arial, sans-serif\" COLOR=\"#990000\" SIZE=\"3\">"; String pricePow = null; int start,end,powPivotStart = 0; powPivotStart = inputPow.indexOf(powPivot); if( powPivotStart == -1); else{ //get price sb.append("<Vendor>"); sb.append("Powells"); sb.append("</Vendor>"); start = inputPow.indexOf("$",powPivotStart); end = inputPow.indexOf("<",start); pricePow = inputPow.substring(start+1,end); sb.append("<Price>"); sb.append(pricePow); sb.append("</Price>"); sb.append("<Link>"); sb.append(powUrl); sb.append("</Link>"); } // end else

} // end powells method private void biggerBooks(String key, StringBuffer sb) throws IOException{ String bigUrl = "http://www.biggerbooks.com/bk_detail.asp?ISBN="+key; String inputBig = scrape(bigUrl); if(inputBig.equals(null))return; String bigPivot = "Our Price"; String bigPivotRetail = "List Price"; String priceBig = null; String listPrice = null; int start,end,bigPivotStartPrice,bigPivotStartRetail = 0; bigPivotStartPrice = inputBig.indexOf(bigPivot); bigPivotStartRetail = inputBig.indexOf(bigPivotRetail); if( bigPivotStartPrice == -1);

116
else{ //get price sb.append("<Vendor>"); sb.append("BiggerBooks"); sb.append("</Vendor>"); start = inputBig.indexOf("$",bigPivotStartPrice); end = inputBig.indexOf("</span>",start); priceBig = inputBig.substring(start+1,end); sb.append("<Price>"); sb.append(priceBig); sb.append("</Price>"); sb.append("<Link>"); sb.append(bigUrl); sb.append("</Link>"); } // end else

} // end biggerBooks method private void booksMillion(String key, StringBuffer sb) throws IOException{ String milUrl = "http://www.booksamillion.com/ncom/books?isbn="+key; String inputMil = scrape(milUrl); if(inputMil.equals(null))return; String milPivot = "Our Price"; String priceMil = null; int start,end,milPivotStart = 0; milPivotStart = inputMil.indexOf(milPivot); if( milPivotStart == -1); else{ //get price sb.append("<Vendor>"); sb.append("BooksAMillion"); sb.append("</Vendor>"); start = inputMil.indexOf("$",milPivotStart); end = inputMil.indexOf("</B>",start); priceMil = inputMil.substring(start+1,end); sb.append("<Price>"); sb.append(priceMil); sb.append("</Price>"); sb.append("<Link>"); sb.append(milUrl); sb.append("</Link>"); } // end else

} // end booksMillion method private void blackwell(String key, StringBuffer sb) throws IOException{ String blackUrl = "http://bookshop.blackwell.com/bobus/scripts/home.jsp?action=search&type=isbn&t erm="+key; String inputBlack = scrape(blackUrl); if(inputBlack.equals(null))return; String blackPivot = "strong"; String priceBlack = null; int start,end,blackPivotStart,blackPivotStartRetail = 0; blackPivotStart = inputBlack.indexOf(blackPivot); if( blackPivotStart == -1); else{ //get price sb.append("<Vendor>"); sb.append("Blackwell's"); sb.append("</Vendor>"); start = inputBlack.indexOf("$",blackPivotStart); end = inputBlack.indexOf("</B>",start);

117
priceBlack = inputBlack.substring(start+1,end); sb.append("<Price>"); sb.append(priceBlack); sb.append("</Price>"); sb.append("<Link>"); sb.append(blackUrl); sb.append("</Link>"); } // end else

} // end blackwell method private void allDirect(String key, StringBuffer sb) throws IOException{ String allUrl = "http://www.alldirect.com/book.asp?isbn="+key; String inputAll = scrape(allUrl); if(inputAll.equals(null))return; String allPivot = "Direct's Price"; String priceAll = null; int start,end,allPivotStart,allPivotStartRetail = 0; allPivotStart = inputAll.indexOf(allPivot); if( allPivotStart == -1); else{ //get price sb.append("<Vendor>"); sb.append("AllDirect.com"); sb.append("</Vendor>"); start = inputAll.indexOf("$",allPivotStart); end = inputAll.indexOf("</FONT>",start); priceAll = inputAll.substring(start+1,end); sb.append("<Price>"); sb.append(priceAll); sb.append("</Price>"); sb.append("<Link>"); sb.append(allUrl); sb.append("</Link>"); } // end else

} // end allDirect method private void deals(String key, StringBuffer sb) throws IOException{ String dealUrl = "http://www.dealsdealsdeals.com/itemdetail.cfm?sku="+key; String inputDeal = scrape(dealUrl); if(inputDeal.equals(null))return; String dealPivot = "Our Price"; String priceDeal = null; int start,end,dealPivotStart,dealPivotStartRetail = 0; dealPivotStart = inputDeal.indexOf(dealPivot); if( dealPivotStart == -1); else{ //get price sb.append("<Vendor>"); sb.append("dealsdealsdeals.com"); sb.append("</Vendor>"); start = inputDeal.indexOf("$",dealPivotStart); end = inputDeal.indexOf("</span>",start); priceDeal = inputDeal.substring(start+1,end); sb.append("<Price>"); sb.append(priceDeal); sb.append("</Price>"); sb.append("<Link>"); sb.append(dealUrl); sb.append("</Link>"); } // end else

118

} // end deals method private void varsity(String key, StringBuffer sb) throws IOException{ String varUrl = "http://www.varsitybooks.com/Search.aspx?SearchType=ISBN&SearchValue="+key; String inputVar = scrape(varUrl); if(inputVar.equals(null))return; String varPivot = "New Book"; String priceVar = null; int start,end,varPivotStart = 0; varPivotStart = inputVar.indexOf(varPivot); if( varPivotStart == -1); else{ //get price sb.append("<Vendor>"); sb.append("VarsityBooks"); sb.append("</Vendor>"); start = inputVar.indexOf(">",varPivotStart); end = inputVar.indexOf("</span>",start); priceVar = inputVar.substring(start+1,end); sb.append("<Price>"); sb.append(priceVar); sb.append("</Price>"); sb.append("<Link>"); sb.append(varUrl); sb.append("</Link>"); } // end else

} // end varsity method private void half(String key, StringBuffer sb) throws IOException{ String halfUrl = "http://half.ebay.com/search/search.jsp?&product=books&keyword="+key; String inputHalf = scrape(halfUrl); if(inputHalf.equals(null))return; String halfPivot = "Best&nbsp;Price"; String priceHalf = null; int start,end,halfPivotStart,halfPivotStartRetail = 0; halfPivotStart = inputHalf.indexOf(halfPivot); if( halfPivotStart == -1); else{ //get price sb.append("<Vendor>"); sb.append("half.com"); sb.append("</Vendor>"); start = inputHalf.indexOf("$",halfPivotStart); end = inputHalf.indexOf("</b>",start); priceHalf = inputHalf.substring(start+1,end); sb.append("<Price>"); sb.append(priceHalf); sb.append("</Price>"); sb.append("<Link>"); sb.append(halfUrl); sb.append("</Link>"); } // end else

} // end half method

private String scrape(String locale) { String ll = locale; try{

119
URL u = new URL(ll); URLConnection urlconnx = u.openConnection(); urlconnx.setDoInput(true); InputStream inx = urlconnx.getInputStream(); BufferedReader bb = new BufferedReader(new InputStreamReader(u.openStream())); StringBuffer sb = new StringBuffer(); String input; while(((input = bb.readLine()) != null)) sb.append(input); bb.close(); input = sb.toString(); return input; }catch(IOException ie){return null;} } private String getCharacterDataFromElement(Element e) { Node child = e.getFirstChild(); if (child instanceof org.w3c.dom.CharacterData) { org.w3c.dom.CharacterData cd = (org.w3c.dom.CharacterData) child; return cd.getData(); } return "Unknown"; } private String normalize(String norm){ String ttt = ""; StringTokenizer t = new StringTokenizer(norm," "); while(t.hasMoreTokens()){ ttt = ttt + t.nextToken() + "%20"; } int last = ttt.lastIndexOf("%20"); ttt = ttt.substring(0, last); return ttt; }

// end BookServer class

120

APPENDIX 11
IBookSearch.java
public interface IBookSearch { public String searchIsbn(String isbn); public String searchAll(String author,String title, String publisher, String year, String subject, String keyword); }

121

APPENDIX 12
CWSBookSearchClient.java
package cwsclient; import import import import import import import import import import import java.util.*; java.text.*; java.awt.*; java.awt.event.*; javax.swing.*; org.apache.axis.client.Call; org.apache.axis.client.Service; org.apache.axis.encoding.XMLType; javax.xml.namespace.QName; javax.xml.rpc.ParameterMode; java.net.URL;

public class CWSBookSearchClient extends JFrame{ public static final int WIDTH = 700; public static final int HEIGHT = 700; public static final String TITLE = "CWS Book Search"; private Container contentPane; private JTextField authorText, titleText, publisherText, yearText, subjectText, keywordText, isbnText; private JTextArea results; private JButton searchButton; private JPanel paneldetails; private boolean selectionEnabled = true; private static final String endPoint = "http://matrix.csis.pace.edu:23451/axis/BookServerImpl.jws"; String author, title, publisher, year, subject, keyword, isbn = "";

public static void main(String[] args) { CWSBookSearchClient client = new CWSBookSearchClient();

// end main method

public CWSBookSearchClient() { setTitle(TITLE); setSize(WIDTH, HEIGHT); contentPane = getContentPane(); paneldetails = new JPanel(); contentPane.add(paneldetails, BorderLayout.CENTER); paneldetails.setBorder(BorderFactory.createEtchedBorder()); Box box = Box.createVerticalBox(); paneldetails.add(box); box.add(Box.createVerticalStrut(6)); Box box1 = Box.createHorizontalBox(); box1.setAlignmentX(Component.LEFT_ALIGNMENT); box1.add(new JLabel("Author: ")); authorText = new JTextField("",2); box1.add(authorText);

122
box.add(box1); Box box2 = Box.createHorizontalBox(); box2.setAlignmentX(Component.LEFT_ALIGNMENT); box2.add(new JLabel("Title: ")); titleText = new JTextField("",2); box2.add(titleText); box.add(box2); Box box3 = Box.createHorizontalBox(); box3.setAlignmentX(Component.LEFT_ALIGNMENT); box3.add(new JLabel("Publisher: ")); publisherText = new JTextField("",2); box3.add(publisherText); box.add(box3); Box box4 = Box.createHorizontalBox(); box4.setAlignmentX(Component.LEFT_ALIGNMENT); box4.add(new JLabel("Publish Year: ")); yearText = new JTextField("",2); box4.add(yearText); box.add(box4); Box box5 = Box.createHorizontalBox(); box5.setAlignmentX(Component.LEFT_ALIGNMENT); box5.add(new JLabel("Subject: ")); subjectText = new JTextField("",2); box5.add(subjectText); box.add(box5); Box box6 = Box.createHorizontalBox(); box6.setAlignmentX(Component.LEFT_ALIGNMENT); box6.add(new JLabel("Keyword: ")); keywordText = new JTextField("",2); box6.add(keywordText); box.add(box6); Box box7 = Box.createHorizontalBox(); box7.setAlignmentX(Component.LEFT_ALIGNMENT); box7.add(new JLabel("ISBN: ")); isbnText = new JTextField("",2); box7.add(isbnText); box.add(box7); // Create the button Box box8 = Box.createHorizontalBox(); box8.setAlignmentX(Component.LEFT_ALIGNMENT); box.add(Box.createVerticalStrut(10)); box.add(box8); // "Search" button searchButton = new JButton("Search"); box8.add(searchButton); searchButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { author = authorText.getText(); title = titleText.getText(); publisher = publisherText.getText(); year = yearText.getText(); subject = subjectText.getText(); keyword = keywordText.getText(); isbn = isbnText.getText();

123

if ( !isbn.equals("") ){ searchIsbn(isbn); } else if(!author.equals("") ||!title.equals("") ||!publisher.equals("")|| !year.equals("") || !subject.equals("") || !keyword.equals("")){ searchAll(author, title, publisher, year, subject, keyword); } else results.setText("Select at least one search criteria"); } }); Box box9 = Box.createHorizontalBox(); box9.setAlignmentX(Component.LEFT_ALIGNMENT); box9.add(new JLabel("Search Results: ")); results = new JTextArea("",20,40); results.setBorder(BorderFactory.createEtchedBorder()); box9.add(results); box9.add(new JScrollPane(results)); box.add(box9); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); show();

// end constructor

public void searchIsbn(String isbn) { String ret = null; try { Service service = new Service(); Call call = (Call) service.createCall(); call.setTargetEndpointAddress(new java.net.URL(endPoint)); call.setOperationName( new QName("BookServer", "searchIsbn") ); call.addParameter("isbn", XMLType.XSD_STRING,ParameterMode.IN); call.setReturnType(XMLType.XSD_STRING); ret = (String)call.invoke(new Object[] {isbn}); results.setText(ret); results.setCaretPosition(0); } catch (Exception e) {results.setText("Unable to process searchIsbn request at this time. Please try again.");} } // end searchIsbn method public void searchAll(String author, String title, String publisher, String year, String subject, String keyword){ String ret = null; try { Service service = new Service(); Call call = (Call) service.createCall(); call.setTargetEndpointAddress(new java.net.URL(endPoint)); call.setOperationName( new QName("BookServer", "searchAll") ); call.addParameter("author", XMLType.XSD_STRING,ParameterMode.IN); call.addParameter("title", XMLType.XSD_STRING,ParameterMode.IN); call.addParameter("publisher", XMLType.XSD_STRING,ParameterMode.IN); call.addParameter("year", XMLType.XSD_STRING,ParameterMode.IN); call.addParameter("subject", XMLType.XSD_STRING,ParameterMode.IN); call.addParameter("keyword", XMLType.XSD_STRING,ParameterMode.IN); call.setReturnType(XMLType.XSD_STRING); Object[] params = new Object[6]; params[0] = author; params[1] = title;

124
params[2] params[3] params[4] params[5] = = = = publisher; year; subject; keyword;

ret = (String)call.invoke(params); results.setText(ret); results.setCaretPosition(0); } catch (Exception e) { results.setText("Unable to process searchAll request at this time. try again."); e.printStackTrace(); } } Please

// end CWSBookSearchClient class

125

APPENDIX 13
cwsForm.cs
using using using using using using System; System.Drawing; System.Collections; System.ComponentModel; System.Windows.Forms; System.Data;

namespace Search { /// <summary> /// Summary description for Form1. /// </summary> public class cwsForm : System.Windows.Forms.Form { private System.Windows.Forms.Label label1; private System.Windows.Forms.Label label2; private System.Windows.Forms.Label label3; private System.Windows.Forms.Label label4; private System.Windows.Forms.Label label5; private System.Windows.Forms.Label label6; private System.Windows.Forms.Label label7; private System.Windows.Forms.Button button1; private System.Windows.Forms.TextBox authorx; private System.Windows.Forms.TextBox titlex; private System.Windows.Forms.TextBox publisherx; private System.Windows.Forms.TextBox yearx; private System.Windows.Forms.TextBox subjectx; private System.Windows.Forms.TextBox keywordx; private System.Windows.Forms.TextBox isbnx; private System.Windows.Forms.RichTextBox display; private System.ComponentModel.Container components = null; public cwsForm() { InitializeComponent(); } protected override void Dispose( bool disposing ) { if( disposing ) { if (components != null) { components.Dispose(); } } base.Dispose( disposing ); } #region Windows Form Designer generated code /// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() {

126
this.label1 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label(); this.label3 = new System.Windows.Forms.Label(); this.label4 = new System.Windows.Forms.Label(); this.label5 = new System.Windows.Forms.Label(); this.label6 = new System.Windows.Forms.Label(); this.label7 = new System.Windows.Forms.Label(); this.authorx = new System.Windows.Forms.TextBox(); this.titlex = new System.Windows.Forms.TextBox(); this.publisherx = new System.Windows.Forms.TextBox(); this.yearx = new System.Windows.Forms.TextBox(); this.subjectx = new System.Windows.Forms.TextBox(); this.keywordx = new System.Windows.Forms.TextBox(); this.isbnx = new System.Windows.Forms.TextBox(); this.button1 = new System.Windows.Forms.Button(); this.display = new System.Windows.Forms.RichTextBox(); this.SuspendLayout(); // // label1 // this.label1.Location = new System.Drawing.Point(40, 32); this.label1.Name = "label1"; this.label1.TabIndex = 0; this.label1.Text = "Author:"; // // label2 // this.label2.Location = new System.Drawing.Point(40, 62); this.label2.Name = "label2"; this.label2.TabIndex = 1; this.label2.Text = "Title:"; // // label3 // this.label3.Location = new System.Drawing.Point(40, 92); this.label3.Name = "label3"; this.label3.TabIndex = 2; this.label3.Text = "Publisher:"; // // label4 // this.label4.Location = new System.Drawing.Point(40, 122); this.label4.Name = "label4"; this.label4.TabIndex = 3; this.label4.Text = "Publish Year:"; // // label5 // this.label5.Location = new System.Drawing.Point(40, 152); this.label5.Name = "label5"; this.label5.TabIndex = 4; this.label5.Text = "Subject:"; // // label6 // this.label6.Location = new System.Drawing.Point(40, 182); this.label6.Name = "label6"; this.label6.TabIndex = 5; this.label6.Text = "Keyword:"; // // label7 // this.label7.Location = new System.Drawing.Point(40, 212);

127
this.label7.Name = "label7"; this.label7.TabIndex = 6; this.label7.Text = "ISBN:"; // // author // this.authorx.Location = new System.Drawing.Point(200, 32); this.authorx.Name = "author"; this.authorx.Size = new System.Drawing.Size(152, 20); this.authorx.TabIndex = 7; this.authorx.Text = ""; // // title // this.titlex.Location = new System.Drawing.Point(200, 62); this.titlex.Name = "title"; this.titlex.Size = new System.Drawing.Size(152, 20); this.titlex.TabIndex = 8; this.titlex.Text = ""; // // publisher // this.publisherx.Location = new System.Drawing.Point(200, 92); this.publisherx.Name = "publisher"; this.publisherx.Size = new System.Drawing.Size(152, 20); this.publisherx.TabIndex = 9; this.publisherx.Text = ""; // // year // this.yearx.Location = new System.Drawing.Point(200, 122); this.yearx.Name = "year"; this.yearx.Size = new System.Drawing.Size(152, 20); this.yearx.TabIndex = 10; this.yearx.Text = ""; // // subject // this.subjectx.Location = new System.Drawing.Point(200, 152); this.subjectx.Name = "subject"; this.subjectx.Size = new System.Drawing.Size(152, 20); this.subjectx.TabIndex = 11; this.subjectx.Text = ""; // // keyword // this.keywordx.Location = new System.Drawing.Point(200, 182); this.keywordx.Name = "keyword"; this.keywordx.Size = new System.Drawing.Size(152, 20); this.keywordx.TabIndex = 12; this.keywordx.Text = ""; // // isbn // this.isbnx.Location = new System.Drawing.Point(200, 212); this.isbnx.Name = "isbn"; this.isbnx.Size = new System.Drawing.Size(152, 20); this.isbnx.TabIndex = 13; this.isbnx.Text = ""; this.isbnx.TextChanged += new System.EventHandler(this.textBox7_TextChanged); // // button1

128
// this.button1.Location = new System.Drawing.Point(144, 248); this.button1.Name = "button1"; this.button1.TabIndex = 14; this.button1.Text = "Search"; this.button1.Click += new System.EventHandler(this.button1_Click); // // display // this.display.Location = new System.Drawing.Point(40, 296); this.display.Name = "display"; this.display.Size = new System.Drawing.Size(312, 208); this.display.TabIndex = 16; this.display.Text = ""; // // cwsForm // this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); this.ClientSize = new System.Drawing.Size(384, 558); this.Controls.AddRange(new System.Windows.Forms.Control[] { this.display, this.button1, this.isbnx, this.keywordx, this.subjectx, this.yearx, this.publisherx, this.titlex, this.authorx, this.label7, this.label6, this.label5, this.label4, this.label3, this.label2, this.label1}); this.Name = "cwsForm"; this.Text = "CWS Book Search"; this.Load += new System.EventHandler(this.Form1_Load); this.ResumeLayout(false); } #endregion [STAThread] static void Main() { Application.Run(new cwsForm()); } private void Form1_Load(object sender, System.EventArgs e) { } private void label1_Click(object sender, System.EventArgs e) { } private void textBox7_TextChanged(object sender, System.EventArgs e) {

129

} private void textBox8_TextChanged(object sender, System.EventArgs e) { } private void button1_Click(object sender, System.EventArgs e) { try { display.Clear(); string result = null; BookServerImplService svc = new BookServerImplService(); if(!isbnx.Text.Equals("")) { result = svc.searchIsbn(isbnx.Text); display.AppendText(result); result = null; authorx.Text = ""; titlex.Text = ""; publisherx.Text = ""; yearx.Text = ""; subjectx.Text = ""; keywordx.Text = ""; isbnx.Text = ""; } else { result = svc.searchAll(authorx.Text,titlex.Text, publisherx.Text,yearx.Text,subjectx.Text, keywordx.Text); display.AppendText(result); result = null; authorx.Text = ""; titlex.Text = ""; publisherx.Text = ""; yearx.Text = ""; subjectx.Text = ""; keywordx.Text = ""; isbnx.Text = ""; } } catch(Exception ee) { display.AppendText("Unable to process requests at this time."); display.AppendText("Please try again."); } } } }

130

APPENDIX 14
BookServerImplService.cs
//----------------------------------------------------------------------------// <autogenerated> // This code was generated by a tool. // Runtime Version: 1.0.3705.6018 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. // </autogenerated> //----------------------------------------------------------------------------// // This source code was auto-generated by wsdl, Version=1.0.3705.6018. // namespace Search { using System.Diagnostics; using System.Xml.Serialization; using System; using System.Web.Services.Protocols; using System.ComponentModel; using System.Web.Services;

/// <remarks/> [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] [System.Web.Services.WebServiceBindingAttribute(Name="BookServerImplSoapBinding ", Namespace="http://matrix.csis.pace.edu:23451/axis/BookServerImpl.jws")] public class BookServerImplService : System.Web.Services.Protocols.SoapHttpClientProtocol { /// <remarks/> public BookServerImplService() { this.Url = "http://matrix.csis.pace.edu:23451/axis/BookServerImpl.jws"; } /// <remarks/> [System.Web.Services.Protocols.SoapRpcMethodAttribute("", RequestNamespace="http://DefaultNamespace", ResponseNamespace="http://matrix.csis.pace.edu:23451/axis/BookServerImpl.jws")] [return: System.Xml.Serialization.SoapElementAttribute("searchAllReturn")] public string searchAll(string author, string title, string publisher, string year, string subject, string keyword) { object[] results = this.Invoke("searchAll", new object[] { author, title, publisher, year,

131

subject, keyword}); return ((string)(results[0])); } /// <remarks/> public System.IAsyncResult BeginsearchAll(string author, string title, string publisher, string year, string subject, string keyword, System.AsyncCallback callback, object asyncState) { return this.BeginInvoke("searchAll", new object[] { author, title, publisher, year, subject, keyword}, callback, asyncState); } /// <remarks/> public string EndsearchAll(System.IAsyncResult asyncResult) { object[] results = this.EndInvoke(asyncResult); return ((string)(results[0])); } /// <remarks/> [System.Web.Services.Protocols.SoapRpcMethodAttribute("", RequestNamespace="http://DefaultNamespace", ResponseNamespace="http://matrix.csis.pace.edu:23451/axis/BookServerImpl.jws")] [return: System.Xml.Serialization.SoapElementAttribute("searchIsbnReturn")] public string searchIsbn(string isbn) { object[] results = this.Invoke("searchIsbn", new object[] { isbn}); return ((string)(results[0])); } /// <remarks/> public System.IAsyncResult BeginsearchIsbn(string isbn, System.AsyncCallback callback, object asyncState) { return this.BeginInvoke("searchIsbn", new object[] { isbn}, callback, asyncState); } /// <remarks/> public string EndsearchIsbn(System.IAsyncResult asyncResult) { object[] results = this.EndInvoke(asyncResult); return ((string)(results[0])); } } }

132

APPENDIX 15
AssemblyInfo.cs
using System.Reflection; using System.Runtime.CompilerServices; // // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. // [assembly: AssemblyTitle("")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("")] [assembly: AssemblyCopyright("")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] // // Version information for an assembly consists of the following four values: // // Major Version // Minor Version // Build Number // Revision // // You can specify all the values or you can default the Revision and Build // // Numbers by using the '*' as shown below: [assembly: AssemblyVersion("1.0.*")] // In order to sign your assembly you must specify a key to use. Refer to the // Microsoft .NET Framework documentation for more information on assembly signing. // Use the attributes below to control which key is used for signing. // // Notes: // (*) If no key is specified, the assembly is not signed. // (*) KeyName refers to a key that has been installed in the Crypto Service // Provider (CSP) on your machine. KeyFile refers to a file which // contains a key. // (*) If the KeyFile and the KeyName values are both specified, the // following processing occurs: // (1) If the KeyName can be found in the CSP, that key is used. // (2) If the KeyName does not exist and the KeyFile does exist, the key // in the KeyFile is installed into the CSP and used. // (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility. // When specifying the KeyFile, the location of the KeyFile should be // relative to the project output directory which is // %Project Directory%\obj\<configuration>. For example, if your KeyFile // is located in the project directory, you would specify the // AssemblyKeyFile attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")] // (*) Delay Signing is an advanced option - see the Microsoft .NET Framework // documentation for more information on this. [assembly: AssemblyDelaySign(false)] [assembly: AssemblyKeyFile("")] [assembly: AssemblyKeyName("")]

133

APPENDIX 16
PublishCWS.java
import import import import import import org.uddi4j.client.*; org.uddi4j.datatype.*; org.uddi4j.datatype.business.*; org.uddi4j.datatype.tmodel.*; org.uddi4j.response.*; org.uddi4j.util.*;

import java.util.*; public class PublishCWS { // Location of UDDI registry String publishURL = "https://uddi.ibm.com/testregistry/publishapi";

//Create the businessEntity and then process the save_business operation. protected void saveBusiness(String userid, String password) throws Exception { UDDIProxy uddiProxy = null; // Add SSL support (this is IBM's SSL support but it can be replaced // with other implementations) //System.setProperty("java.protocol.handler.pkgs", // "com.ibm.net.ssl.internal.www.protocol"); //java.security.Security.addProvider(new com.ibm.jsse.JSSEProvider()); // Create UDDI proxy uddiProxy = new UDDIProxy(); uddiProxy.setPublishURL(publishURL); // Create businessEntity BusinessEntity businessEntity = new BusinessEntity(); businessEntity.setBusinessKey(""); // Set name and description businessEntity.setDefaultNameString("CWS", "en"); Vector description = new Vector(); description.add(new Description("UDDI businessEntity for CWS.", "en")); businessEntity.setDescriptionVector(description); // Create first contact Contact ceo = new Contact("Michael Ryan"); ceo.setUseType("Technical Information"); ceo.setDefaultDescriptionString("CEO for technical information"); Vector phoneList = new Vector(); Phone mainPhone = new Phone("1.914.422.4191"); mainPhone.setUseType("Main Office"); phoneList.add(mainPhone); ceo.setPhoneVector(phoneList); Vector emailList = new Vector(); Email email = new Email("mr13204w@pace.edu"); email.setUseType("CEO"); emailList.add(email); ceo.setEmailVector(emailList);

// Set contacts Contacts contacts = new Contacts(); contacts.add(ceo);

134
businessEntity.setContacts(contacts); // Obtain authToken using get_authToken UDDI API AuthToken authToken = uddiProxy.get_authToken(userid, password); // Save businessEntity Vector businessEntityList = new Vector(); businessEntityList.add(businessEntity); BusinessDetail businessDetail = uddiProxy.save_business(authToken.getAuthInfoString(), businessEntityList); // Get businessKey for published businessEntity String businessKey = ((BusinessEntity) businessDetail.getBusinessEntityVector().elementAt(0)).getBusinessKey(); // Display businessKey System.out.println("Published businessEntity key: " + businessKey + "."); } public static void main(String[] args) { try { PublishCWS publishCWS = new PublishCWS(); publishCWS.saveBusiness("mr13204w@pace.edu", "cwspacepass"); } catch (Exception e) { System.out.println("EXCEPTION: " + e.toString()); } System.exit(0); } }

135

APPENDIX 17
FindCWS.java
/* * The source code contained herein is licensed under the IBM Public License * Version 1.0, which has been approved by the Open Source Initiative. * Copyright (C) 2001, International Business Machines Corporation * Copyright (C) 2001, Hewlett-Packard Company * All Rights Reserved. * */ import java.util.Properties; import java.util.Vector; import import import import import import import import import org.uddi4j.UDDIException; org.uddi4j.client.UDDIProxy; org.uddi4j.datatype.Name; org.uddi4j.response.BusinessInfo; org.uddi4j.response.BusinessList; org.uddi4j.response.DispositionReport; org.uddi4j.response.Result; org.uddi4j.util.FindQualifier; org.uddi4j.util.FindQualifiers;

/** * Sample code that exercises the Enquiry API. Attempts * to find a business by name. * * <OL> * <LI>Sets up a UDDIProxy object * <LI>Finds businesses by name. * </OL> * * @author David Melgar (dmelgar@us.ibm.com) * @author Rajesh Sumra (rajesh_sumra@hp.com) */ public class FindCWS { Properties config = null; public static void main (String args[]) { FindCWS app = new FindCWS(); System.out.println("\n*********** Running FindCWS ***********"); app.run(); System.exit(0); } public void run() { // Load samples configuration config = Configurator.load(); // Construct a UDDIProxy object. UDDIProxy proxy = new UDDIProxy(); try

136
{ // Select the desired UDDI server node proxy.setInquiryURL(config.getProperty("inquiryURL")); proxy.setPublishURL(config.getProperty("publishURL")); //creating vector of Name Object Vector names = new Vector(); names.add(new Name("CWS")); // Setting FindQualifiers to 'caseSensitiveMatch' FindQualifiers findQualifiers = new FindQualifiers(); Vector qualifier = new Vector(); qualifier.add(new FindQualifier("caseSensitiveMatch")); findQualifiers.setFindQualifierVector(qualifier); // Find businesses by name // And setting the maximum rows to be returned as 5. BusinessList businessList = proxy.find_business(names, null,null,findQualifiers,10);

null,

null,

Vector businessInfoVector = businessList.getBusinessInfos().getBusinessInfoVector(); for( int i = 0; i < businessInfoVector.size(); i++ ) { BusinessInfo businessInfo = (BusinessInfo)businessInfoVector.elementAt(i); // Print name for each business System.out.println(businessInfo.getDefaultNameString()); } } // Handle possible errors catch( UDDIException e ) { DispositionReport dr = e.getDispositionReport(); if( dr!=null ) { System.out.println("UDDIException faultCode:" + e.getFaultCode() + "\n operator:" + dr.getOperator() + "\n generic:" + dr.getGeneric() ); Vector results = dr.getResultVector(); for( int i=0; i<results.size(); i++ ) { Result r = (Result)results.elementAt(i); System.out.println("\n errno:" + r.getErrno() ); if( r.getErrInfo()!=null ) { System.out.println("\n errCode:" + r.getErrInfo().getErrCode() + "\n errInfoText:" + r.getErrInfo().getText()); } } } e.printStackTrace(); } // Catch any other exception that may occur catch( Exception e ) { e.printStackTrace(); } } }

137

APPENDIX 18
Configurator.java
/* * The source code contained herein is licensed under the IBM Public License * Version 1.0, which has been approved by the Open Source Initiative. * Copyright (C) 2001, International Business Machines Corporation * Copyright (C) 2001, Hewlett-Packard Company * All Rights Reserved. * */ import java.util.Properties; import org.uddi4j.transport.TransportFactory; /** * Configures the environment for UDDI4J * <OL> * <LI>Reads samples property file. * <LI>Sets SOAP transport according to property file. * <LI>Configures SSL/JSSE provider * </OL> * * @author David Melgar (dmelgar@us.ibm.com) */ public class Configurator { /** * Loads configuration file. File may require * modification before running samples. * * @return Loaded properties object */ public static Properties load() { Properties config = new Properties(); try { config.load(new java.io.FileInputStream("C:\\Documents and Settings\\Web\\CWSws\\src\\propCWS.properties")); } catch (Exception e) { System.out.println("Error loading samples property file\n" + e); } // Configure UDDI4J system properties. Normally set on commandline or elsewhere // SOAP transport being used if (System.getProperty(TransportFactory.PROPERTY_NAME)==null) { System.setProperty(TransportFactory.PROPERTY_NAME, config.getProperty("TransportClassName")); } // Logging if (System.getProperty("org.uddi4j.logEnabled")==null) { System.setProperty("org.uddi4j.logEnabled", config.getProperty("logEnabled")); } // Configure JSSE support try { System.setProperty("java.protocol.handler.pkgs", config.getProperty("handlerPackageName"));

138
// Dynamically loads security provider based on properties. Typically configured in JRE java.security.Security.addProvider((java.security.Provider) Class.forName(config.getProperty("securityClassName")).newInstance()); } catch (Exception e) { System.out.println("Error configuring JSSE provider. Make sure JSSE is in classpath.\n" + e); } return config; } }

139

APPENDIX 19
PropCWS.properties
# Property file used to set parameters for UDDI4J # ----------------------------------------------------------------------# inquiryURL: The URL for the inquiry API of the target UDDI registry # publishURL: URL for the publish API of the target UDDI registry # A list of UDDI URLs is on the UDDI4J website http://www.uddi4j.org/ # # A typical entry would be of the form # inquiryURL=http://company.com/uddi_node # publishURL=https://company.com/uddi_publish_node # ----------------------------------------------------------------------# UDDI site # inquiryURL = http://uddi.ibm.com/beta/inquiryapi # publishURL = https://uddi.ibm.com/beta/publishapi inquiryURL = http://uddi.microsoft.com/inquire publishURL = https://uddi.microsoft.com/publish # ----------------------------------------------------------------------# Userid/passwords should not generally be stored in clear text # ----------------------------------------------------------------------userid = mr13204w@pace.edu password = cwspacepass1 # ----------------------------------------------------------------------# Transport classname. Typically defined on commandline as # -Dorg.uddi4j.TransportClassName=xxx. # ----------------------------------------------------------------------# TransportClassName=org.uddi4j.transport.ApacheSOAPTransport TransportClassName=org.uddi4j.transport.ApacheAxisTransport # TransportClassName=org.uddi4j.transport.HPSOAPTransport # ----------------------------------------------------------------------# Debug log enabled or not. Typically defined on command line as # -Dorg.uddi4j.logEnabled=true # ----------------------------------------------------------------------logEnabled=false # logEnabled=true # ----------------------------------------------------------------------# Values used to determine the implementation of JSSE to use. Provided # for convenience, this is typically configured within the jdk # in JAVA_HOME\jre\lib\security # ----------------------------------------------------------------------# Sun JSSE implementation handlerPackageName=com.sun.net.ssl.internal.www.protocol securityClassName=com.sun.net.ssl.internal.ssl.Provider # IBM JSSE implementation # handlerPackageName=com.ibm.net.ssl.internal.www.protocol # securityClassName=com.ibm.jsse.JSSEProvider # ----------------------------------------------------------------------# UDDI names to use. # ----------------------------------------------------------------------businessName= serviceName= tmodelName= sampleEntityName=

140
assertionRelationship=peer-peer # # # # ----------------------------------------------------------------------Additional values can be added as needed as a convenient repository for data relevant to the UDDI4J samples -----------------------------------------------------------------------

141

APPENDIX 20
CWS Build Manual

Tomcat Installation 1) Download the Apache Tomcat Server and Tomcat installation instructions from http://jakarta.apache.org/tomcat/index.html. (Certain IDEs, like Netbeans, come with Tomcat Server and the Sun JDK, which facilitate creating a Web Service locally) SSH Tectia Client Installation 1) Assuming use of an account on matrix.csis.pace.edu, download SSH Tectia Client from http://www.ssh.com/support/downloads/tectia-client. Tectia Client assists with performing operations on the Web Server and secure file transfers from a local computer to the Web Server Axis Installation 1) Download Axis 1.1 from http://ws.apache.org/axis/releases.html 2) Complete instructions are located at http://ws.apache.org/axis/java/install.html 3) After expanding the Axis 1.1 file, copy the webapps/axis folder to Tomcats webapp directory using SSH File Transfer 4) Using SSH File Transfer, copy jaxrpc.jar and saaj.jar from $CATALINA_HOME/webapps/axis/WEB-INF to $CATALINA_HOME/common/lib folder 5) Restart Tomcat 6) To verify correct installation, visit http://matrix.csis.pace.edu:port#/axis (port# is an assigned Tomcat port number from a system administrator) 7) Select Validate. Correct any errors before continuing by referencing Axis guide 8) Using SSH Terminal Window, add Axis jar files from the Tomcat root directory to the Java CLASSPATH as follows:
export AXIS_HOME=$CATALINA_HOME/webapps export AXIS_LIB=$AXIS_HOME/axis/WEB-INF/lib export AXISCLASSPATH=$AXIS_LIB/axis.jar:$AXIS_LIB/commons-discovery.jar: $AXIS_LIB/commons-logging.jar:$AXIS_LIB/jaxrpc.jar: $AXIS_LIB/saaj.jar:$AXIS_LIB/log4j-1.2.8.jar: $AXIS_LIB/wsdl4j.jar:$AXIS_LIB/axis-ant.jar export CLASSPATH=$CLASSPATH:$AXISCLASSPATH

9) If XML parsing capabilities are required, ensure XERCES libraries are in the CLASSPATH

142 CWS Web User Interface (CWSUI) Build 1) Using SSH File Transfer, place all .gif, .jpg, .html, and .jsp files in the $CATALINA_HOME/webapps/pace directory. For CWS, all required .gif files and the following .jsp files are to be uploaded:
error.jsp index.jsp search.jsp 2) Using SSH File Transfer, upload Controller.java to the aboutus.jsp results.jsp

$CATALINA_HOME/webapps/pace/WEB-INF/classes directory and BookBean.java to the $CATALINA_HOME/webapps/pace/WEBINF/classes/CWS directory 3) Using SSH Terminal, navigate to the corresponding directories and compile the two java files as follows: javac Controller.java javac BookBean.java 4) Using SSH Terminal, navigate to $CATALINA_HOME/bin directory and stop and start the Tomcat Server with the following commands: ./shutdown.sh ./startup.sh. CWS Composite Web Service (CWSWS) Build 1) Rename BookServerImpl.java to BookServerImpl.jws and using SSH File Transfer, place the .jws file into the $CATALINA_HOME/webapps/axis folder.

143

APPENDIX 21
CWS User Guide

CWS Web User Interface (CWSUI) CWS is accessible via a browser at http://matrix.csis.pace.edu:23451/pace/index.jsp. Book searches can be performed using author(s) name, title, publisher, year of publication, subject, keyword and ISBN. A user can provide any combination of criteria. As more search parameters are entered by a user, the more refined the search becomes. CWS searches are not case sensitive, so criteria can be entered in all lowercase or uppercase characters. The use of quotation marks, commas, etc., (unless its consistent with a specific search criteria) is discouraged and results in unsuccessful searches. Follow the search syntax below: Author Title Publisher Publish Year Subject Keyword ISBN edgar allan poe war and peace prentice hall 2002 computer science baseball 0672326418

Once search criteria is entered, a user selects the CWS Search button to initiate a search. A user can opt to select the Clear button to erase all search criteria and begin a new search. For Non-ISBN searches, search results are displayed with 20 books per page. Click on Next 20 Results to view subsequent pages or utilize the Back button on the browser to view previous pages. A user can make a book selection by clicking with their mouse on a specific radio button and selecting the Shop Prices button. This launches the CWS price-search tool (Searches with an ISBN parameter launch the price-search tool directly). Book prices are displayed and sorted in ascending order. Select the corresponding vendor book image to navigate to the vendors web site to make a purchase. A new search can be initiated at any time by clicking on the Click Here For New Search link. In the event of an error, an error message is displayed and the Click here to search again link is provided to begin a new search.

144 CWS Composite Web Service (CWSWS) CWS can be discovered programmatically or via a Web browser using IBMs and Microsofts UDDI. To search CWS via a browser use the following link(s): http://uddi.microsoft.com/search/ select Business, starting with CW to search http://uddi.microsoft.com/search/ select Services tab to perform CWS search To search CWS via an application, use the following link(s): http://www-.ibm.com/services/uddi/inquiryapi http://uddi.microsoft.com/inquire Both provide the access point to the CWS wsdl file: http://matrix.csis.pace.edu:23451/axis/BookServerImpl.jws?wsdl CWS exposes two methods:
searchIsbn() searchAll()

for client requests that specify an ISBN parameter for all other request types

Both methods return book results as XML. The following sample, browser-based request demonstrates the XML that is returned from invoking CWS searchIsbn method: Request http://matrix.csis.pace.edu:23451/axis/BookServerImpl.jws?method=searchIsbn& isbn=0672326418 XML Response
. . . <?xml version="1.0"?> <Results> <Book> <Title>Building Web Services with Java : Making Sense of XML, SOAP, WSDL, and UDDI (2nd Edition) (Developer's Library)</Title> <Authors>Steve Graham,Doug Davis,Simeon Simeonov,Glen Daniels,Peter Brittenham,Yuichi Nakamura,Paul Fremantle,Dieter Koenig,Claudia Zentner</Authors> <Publisher>Sams</Publisher> <ISBN>0672326418</ISBN> <RetailPrice>49.99</RetailPrice> </Book> <Vendor>Amazon</Vendor> <Price>34.97</Price>

145
<Link>http://www.amazon.com/exec/obidos/ASIN/067232 6418</Link> <Vendor>Amazon-Used</Vendor> <Price>25.11</Price> <Link>http://www.amazon.com/exec/obidos/ASIN/067232 6418</Link> <Vendor>Barnes and Noble</Vendor> <Price>49.99</Price> <Link>http://search.barnesandnoble.com/booksearch/isbnI nquiry.asp?endeca=1&amp;isbn=0672326418</Link> . . . </Results>

CWS Maintenance Manual

CWS MVC architecture consists of a Controller class, BookBean class, and three presentation classes: index.jsp, results.jsp, search.jsp, and error.jsp. The Controller is the workhorse of the group containing all the key vendor methods and supporting methods. A majority of the vendor data is accessed via html scraping, and therefore such methods require continuous housekeeping. In the event that a vendor alters their web page, the corresponding method must be adjusted with changes entailing resetting stable identifiers which target specific book prices or altering access URLs. Additional vendors and business partners may be added to the Controller class. After such changes, the Tomcat server must be stopped and started again for changes to take effect. Using SSH Terminal, navigate to $CATALINA_HOME/bin directory and stop and start the Tomcat Server with the following commands: ./shutdown.sh ./startup.sh.

146

REFERENCES
[1] Freeman, Adam and Allen Jones. Microsoft .NET XML Web Services Step by Step. Redmond: Microsoft Press, 2003. p.9.

[2]

Barlas, Demir. Web Services Update. Line56.com (Oct. 2004), http://www.line56.com/articles/default.asp?articleid=6028

[3]

Java Skyline, http://www.javaskyline.com/webservices

[4]

Petschulat, Stephen. JSPs or Servlets-Which Architecture is Right for You?. ADTmag.com (Mar. 2001), http://www.adtmag.com/java/article.asp?id=354&mon=3&yr=2001

[5]

http://www.ebuilt.com/fielding/pubs/dissertation/top.htm

[6]

Developer.com, http://www.developer.com/services/article.php/1602051

[7]

Bau, David. JWS: Web Services in Java-Making Integration easier. Web Services Journal (Apr. 2002), http://www.sys-con.com/webservices/articleprint.cfm?id=211

[8]

WS-I Basic Profile 1.0: http://ws-i.org/Profiles/Basic/2003-08/BasicProfile-1.0a.htm

147 [9] The Radicati Group. Web Services Market, 2004-2008. (Sep. 2004) http://www.radicati.com/

[10]

Jenz, Dieter E. A View at Total Cost of Ownership and Return on Investment Parts 1-4. WebServices.Org (Mar. 2002), http://www.webservices.org/ws/content/view/full/1605

[11]

LaMonica, Martin. Wheres the Simplicity in Web Services. News.com (Oct 2004), http://news.com.com/Wheres+the+simplicity+in+Web+services/21007345_3-5395630.html

[12]

Seeley, Rich. Binary XML is Fast in Theory but Slow in Adoption. ADTmag.com (Jan. 2005), http://www.adtmag.com/print.asp?id=10475

[13]

Graham, Steve. Building Web Services with Java: Making sense of XML, WSDL, and UDDI. Second Edition. Indianapolis: Sams, 2005. p.723.

[14]

National Information Standards Organization: http://www.niso.org/standards/resources/ISBN.html

[15]

Web Services Pipeline, http://www.webservicespipeline.com/news/51202359

También podría gustarte