100% found this document useful (7 votes)
19 views

(Ebook) Service Oriented Architecture with Java: Using SOA and web services to build powerful Java applications by Christudas, Binildas A., Barai, Malhar, Caselli, Vincenzo ISBN 9781847193216, 1847193218download

The document is an ebook titled 'Service Oriented Architecture with Java,' which focuses on using SOA and web services to develop robust Java applications. It includes contributions from authors Binildas A. Christudas, Malhar Barai, and Vincenzo Caselli, and covers various aspects of SOA, web services, and Java implementation techniques. The book is published by Packt Publishing and is available for download along with other related ebooks.

Uploaded by

fallaylapka
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (7 votes)
19 views

(Ebook) Service Oriented Architecture with Java: Using SOA and web services to build powerful Java applications by Christudas, Binildas A., Barai, Malhar, Caselli, Vincenzo ISBN 9781847193216, 1847193218download

The document is an ebook titled 'Service Oriented Architecture with Java,' which focuses on using SOA and web services to develop robust Java applications. It includes contributions from authors Binildas A. Christudas, Malhar Barai, and Vincenzo Caselli, and covers various aspects of SOA, web services, and Java implementation techniques. The book is published by Packt Publishing and is available for download along with other related ebooks.

Uploaded by

fallaylapka
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 56

(Ebook) Service Oriented Architecture with Java:

Using SOA and web services to build powerful


Java applications by Christudas, Binildas A.,
Barai, Malhar, Caselli, Vincenzo ISBN
9781847193216, 1847193218 download
https://ebooknice.com/product/service-oriented-architecture-with-
java-using-soa-and-web-services-to-build-powerful-java-
applications-55588372

Explore and download more ebooks at ebooknice.com


We believe these products will be a great fit for you. Click
the link to download now, or visit ebooknice.com
to discover even more!

(Ebook) Biota Grow 2C gather 2C cook by Loucas, Jason; Viles,


James ISBN 9781459699816, 9781743365571, 9781925268492,
1459699815, 1743365578, 1925268497

https://ebooknice.com/product/biota-grow-2c-gather-2c-cook-6661374

(Ebook) Matematik 5000+ Kurs 2c Lärobok by Lena Alfredsson, Hans


Heikne, Sanna Bodemyr ISBN 9789127456600, 9127456609

https://ebooknice.com/product/matematik-5000-kurs-2c-larobok-23848312

(Ebook) SAT II Success MATH 1C and 2C 2002 (Peterson's SAT II


Success) by Peterson's ISBN 9780768906677, 0768906679

https://ebooknice.com/product/sat-ii-success-math-1c-and-2c-2002-peterson-
s-sat-ii-success-1722018

(Ebook) Master SAT II Math 1c and 2c 4th ed (Arco Master the SAT
Subject Test: Math Levels 1 & 2) by Arco ISBN 9780768923049,
0768923042

https://ebooknice.com/product/master-sat-ii-math-1c-and-2c-4th-ed-arco-
master-the-sat-subject-test-math-levels-1-2-2326094
(Ebook) Cambridge IGCSE and O Level History Workbook 2C - Depth
Study: the United States, 1919-41 2nd Edition by Benjamin
Harrison ISBN 9781398375147, 9781398375048, 1398375144,
1398375047
https://ebooknice.com/product/cambridge-igcse-and-o-level-history-
workbook-2c-depth-study-the-united-states-1919-41-2nd-edition-53538044

(Ebook) Service Oriented Java Business Integration: Enterprise


Service Bus integration solutions for Java developers by
Binildas, A. Christudas ISBN 9781847194404, 1847194400

https://ebooknice.com/product/service-oriented-java-business-integration-
enterprise-service-bus-integration-solutions-for-java-developers-5399210

(Ebook) Service-Oriented Java Business Integration by Binildas A


Christudas ISBN 9781847194404, 9781847194411, 1847194400,
1847194419

https://ebooknice.com/product/service-oriented-java-business-
integration-1729692

(Ebook) SOA using Java Web Services by Hansen, Mark D. ISBN


9780130449689, 9781546343547, 0130449687, 1546343547

https://ebooknice.com/product/soa-using-java-web-services-22123520

(Ebook) Practical Microservices Architectural Patterns - Event-


Based Java Microservices with Spring Boot and Spring Cloud by
Binildas Christudas ISBN 9781484245019, 1484245016

https://ebooknice.com/product/practical-microservices-architectural-
patterns-event-based-java-microservices-with-spring-boot-and-spring-
cloud-10416632
Service Oriented Architecture
with Java

Using SOA and web services to build powerful


Java applications

Binildas CA
Malhar Barai
Vincenzo Caselli

BIRMINGHAM - MUMBAI
Service Oriented Architecture with Java

Copyright © 2008 Packt Publishing

All rights reserved. No part of this book may be reproduced, stored in a retrieval
system, or transmitted in any form or by any means, without the prior written
permission of the publisher, except in the case of brief quotations embedded in
critical articles or reviews.

Every effort has been made in the preparation of this book to ensure the accuracy of
the information presented. However, the information contained in this book is sold
without warranty, either express or implied. Neither the authors, Packt Publishing,
nor its dealers or distributors will be held liable for any damages caused or alleged to
be caused directly or indirectly by this book.

Packt Publishing has endeavored to provide trademark information about all the
companies and products mentioned in this book by the appropriate use of capitals.
However, Packt Publishing cannot guarantee the accuracy of this information.

First published: June 2008

Production Reference: 1180608

Published by Packt Publishing Ltd.


32 Lincoln Road
Olton
Birmingham, B27 6PA, UK.

ISBN 978-1-847193-21-6

www.packtpub.com

Cover Image by Nik Lawrence ([email protected])


Credits

Authors Project Manager


Binildas CA Abhijeet Deobhakta
Malhar Barai
Vincenzo Caselli Project Coordinator
Abhijeet Deobhakta
Reviewer
Shyam Sankar S Indexer
Monica Ajmera
Acquisition Editor
Bansari Barot Proofreader
Petula Wright
Technical Editor
Dhiraj Chandiramani Production Coordinator
Shantanu Zagade
Editorial Team Leader
Akshara Aware Cover Work
Shantanu Zagade
About the Authors

Malhar Barai is a senior systems analyst with Satyam Computer Services Ltd.,
one of India's leading IT services organizations. He has more than seven years of
experience in the industry working for leading organizations across India.
Malhar has interest in service-oriented technologies and application integration tools.
He has worked on EAI toolset of webMethods and Cast Iron, Java technologies.
You can catch him on various forums that deal with SOA and some of
the webMethods forums, or you can read about him on his blog
http://malharbarai.blogspot.com

He gets spurred by the daily challenges at work, finding solutions to the problems,
and trying his hand at improving processes and solutions.

I would like to acknowledge and dedicate this book to my parents


for being sources of inspiration and for guiding me on the right path
when it mattered the most. To Jalpa, my lovely wife for, being a
constant support and carving out a wonderful life for us. My
ex-manager Ajay Mulkalwar for his guidance and encouragement,
and the most important person—my soul, my sweet daughter
Preisha whose lovely smile makes my time wonderful…
Vincenzo Caselli graduated with a degree in electrical engineering in 1991 from
the University of Bologna. He has worked as an independent consultant and a
Java trainer for several Italian software houses since 1996. He began working as a
developer in Delphi and other visual IDE's with AS/400-based companies. Soon he
shifted his focus on Java and began to propose Swing client/server multi-layered
solutions to his customers. He also worked in the web development area with
several frameworks (Struts, Hibernate, Spring, JSF, and GWT) in different fields
(banking, manufacturing, healthcare, e-learning). Recently, he collaborated with
IBM in projects based on Eclipse RCP and SOA. He is interested in consultancy and
training activities aimed to improve the productivity and quality of the software
development process by using open-source products.

I would like to thank my wife Silvia and my daughter Linda for


being patient while I worked on this book. I also want to thank my
friend Luca Masini for his precious technical advice and help.

Binildas C. A. provides Technical Architecture consultancy for IT solutions. He


has more than 13 years of IT experience, mostly in Microsoft and Sun technologies.
Distributed Computing and Service Oriented Integration are his mainstream skills,
with extensive hands-on experience in Java and C#.NET programming. Binil holds
a Bachelor of Technology degree in mechanical engineering from the College of
Engineering, Trivandrum (www.cet.ac.in) and an MBA in systems management
from Institute of Management, Kerala (www.imk.ac.in). A well-known and a highly
sought-after thought leader, Binil has designed and built many highly scalable
middle-tier and integration solutions for several top-notch clients including Fortune
500 companies. He has been previously employed by multiple IT consulting firms
including IBS Software Services (www.ibsplc.com) and Tata Consultancy Services
(www.tcs.com), and he currently works for Infosys Technologies (www.infosys.
com) as a Principal Architect where he heads the J2EE Architects group servicing
Communications Service Provider clients.

Binil is a Sun Certified Programmer (SCJP), Developer (SCJD), Business Component


Developer (SCBCD) and Enterprise Architect (SCEA), Microsoft Certified
Professional (MCP), and Open Group (TOGAF8) Certified Enterprise Architecture
Practitioner. He is also a Licensed Zapthink Architect (LZA) in SOA. Besides
Technical Architecture, Binil also practices Enterprise Architecture.

When not in software, Binil spends time with wife Sowmya and daughter Ann in
'God's Own Country', Kerala (www. en.wikipedia.org/wiki/Kerala). Binil is a
long distance runner and is a national medalist in power lifting. You may contact
Binil at [email protected] or [email protected].
About the Reviewer

Shyam Sankar S is currently working as a Technical Architect with Allianz


Cornhill Information Services, Trivandrum. He has around 11 years of experience
in the IT industry and has worked in companies like IBS, Verizon, and Infosys. He
has been working on Java technologies since 1999 and has been the lead architect for
many JEE systems. Shyam, an Industrial Engineer from the University of Kerala, is
also a Sun Certified Enterprise Architect and a Sun Certified Java Developer.
Table of Contents
Preface 1
Chapter 1: The Mantra of SOA 5
Architecture 5
Application Architecture 7
Client-Server Architecture 8
1-Tier Application 9
2-Tier Application 9
3-Tier Application 10
N-Tier application 11
Enterprise Computing or Architecture 12
Business 13
Application 14
Information 14
Technical 15
The Design 15
Security 16
Administration 16
EA for Managers 16
EA for Developers 17
Analogy of SOA 19
Web Services for SOA 20
'Orientation' of Web Services 20
History of SOA 21
The SOA Bandwagon 21
Why SOA? 24
How SOA… 26
Summary 31
Table of Contents

Chapter 2: Web Services and SOA 33


The SOA Approach 33
XML—Advantages and Disadvantages 35
XML Pitfalls 35
Introduction to Web Services, RESTful Services, and Other Transport with
XML 37
Basic SOA With XML Over HTTP Protocol 38
A Basic Java Implementation of POX-over-HTTP 42
REST—Exploiting the HTTP Protocol 47
SOAP 52
RPC and Document Based-WS: How to Communicate, Pros and Cons of
the Two Approach 55
RPC / Literal 56
Document / Literal 60
Document / Literal Wrapped 63
Why We Should Use Doc-WS? 64
The RPC Inheritance 64
The Document-Oriented Way 65
Document Style 65
Implementations: JAX-WS 2, Axis2, Spring-WS, and XFire/CXF 2.0 66
JAX-WS 2 66
Axis 2 67
Spring-WS 69
XFire / CXF 70
Summary 70
Chapter 3: Web Service Implementations 71
Web Service Using JAX-WS 2.0 72
JAX-WS 2.0—A Primer 72
Web Service Implementation in Java SE 6 73
Code Server and Client 73
Run the Server and Client 75
Web Service Implementation in Java EE Server 77
Install and Start the Server 77
Code Server and Client 78
Run the Server and Client 79
Web Service Using Apache Axis 81
Contract-First versus Contract-Last 81
Web Service Implementation in Axis 82
Code Server and Client 82
Run the Server and Client 89
Web Service Using Spring 91
Spring-WS—A Primer 91

[ ii ]
Table of Contents

Web Service Implementation in Spring 92


Code Server and Client 92
web.xml 94
Run the Server and Client 96
Web Service Using XFire 97
Web Service Implementation in XFire 98
Code Server and Client 98
Run the Server and Client 100
Summary 101
Chapter 4: Data and Services—All Roads Lead to
Enterprise Service Bus 103
JDO 104
Why JDO? 104
JPOX—Java Persistent Objects 105
JDO Sample Using JPOX 105
BDOM for the Sample 106
Code BDOM Entities for JDO 106
Build and Run the JDO Sample 110
Data Services 113
Service Data Objects 114
Why SDO? 114
SDO Architecture 114
Apache Tuscany SDO 115
SDO Sample Using Tuscany SDO 116
Code the Sample Artifacts 116
Build and Run the SDO Sample 121
Service Component Architecture 123
What is SCA? 123
Apache Tuscany SCA Java 124
SCA Sample Using Tuscany SCA Java 124
Code the Sample Artifacts 124
Build and Run the SCA Sample 127
Message-Oriented Middleware 128
What is MOM? 128
Benefits of Using MOM 130
Enterprise Service Bus 131
EAI and ESB 131
Java Business Integration 134
OpenESB 134
Summary 136

[ iii ]
Table of Contents

Chapter 5: Traditional Integration Technology 137


Case Study #1—Based on EAI 137
Customer Information 137
Business Need 137
Solution 138
Hub and Spoke Architecture 140
Goals Achieved 145
Goal #1—Integration between Internal Business Processes and Business Partners 145
Goal #2—Avoid Duplicity 145
Goal #3—Achieve Re-Usability, Flexibility, and Scalability 145
Goal #4—Platform Independence 146
Goal #5—Setting up Messaging Exchange 146
Goal #6—Less Manual Intervention 146
Goal #7—Cost Effective 146
EAI Drawbacks 146
Proprietary Architecture 147
Messaging Bottlenecks 147
Tight Coupling 147
Non-Flexible Architecture 147
Manpower 147
SOA to Rescue 147
Case Study #2—Based on SOA 149
Step One—Defining Organization Assets 150
Step Two—Generate Services 151
Information is eXtensible 152
Information Represented in Textual Form 153
Information is Structured 153
Platform Independency 153
Step Three—Model 157
Co-relation of Events 158
Co-relation of Services and Information 158
Step Four—Integrate 158
ESB—Enterprise Service Bus 158
Goals Achieved 160
Goal #1—Proprietary Architecture 160
Goal #2—Eliminating Messaging Bottlenecks 160
Goal #3—Loose Coupling of Applications 161
Goal #4—Flexible Architecture 161
Goal #5—Return On Investment (ROI) 161
Summary 162

[ iv ]
Table of Contents

Chapter 6: Goals We Can Achieve with SOA 163


Loose Coupling 163
Reusability 167
Seamless Integration 168
Return on Investment (ROI) 168
Summary 169
Index 171

[]
Preface
Service Oriented Architecture is mainly a mindset, an enterprise strategy whose
natural implementation is represented by web services. SOA is not a single product
or single reference architecture to be followed, but SOA is all about best practices,
reference architectures, processes, toolsets, and frameworks, along with many other
things which will help you and your organization to increase the responsiveness and
agility of your enterprise architecture. Standards and frameworks play a greater role
in enabling easy and widespread industry adoption of SOA.

This book will help you learn the importance of designing a sound architecture
for successful implementation of any business solution, different types of C/S
architecture, and various tenets of SOA, explaining the fundamentals and explaining
the advantage of using the Service Oriented Architecture in designing of the business
solution. From a basic XML-over-HTTP approach to the REST and SOAP protocols,
we get into the details of how web services can be implemented with various degrees
of complexity and flexibility using JAVA.

This book will explain the concepts of business layer that is 'The SOA core'. You
will also learn when SOA will define as an asset to your project with the help of
practical examples.

In the early years when the WS-approach began to emerge it suffered from
difficulties due to many factors, for instance, complex adoption process and poor
standardization. Now, with little effort times are mature for using this technology
and also getting great advantages, both immediate and as an investment for our
future works. The book concludes with the focus on explanation of these assets.
Preface

What This Book Covers


In Chapter 1 we will discuss the role of Architecture for successful implementation of
any business solution followed by brief discussion on different types of client-server
architecture and SOA.

In Chapter 2 we will examine the relationship between the SOA methodology and
the web service implementation basics. We will also discuss how XML can be used
as the common language to decouple the communication between web service
implementations and their consumer clients.

In Chapter 3 we will introduce major web service implementations available


specifically in the Java and J2EE world, WS using JAX-WS 2.0, WS using Apache
Axis, WS using Spring, and WS using XFire.

In Chapter 4 we shall see few emerging standards like SDO and SCA, addressing
from data integration to service and component integration.

In Chapter 5 we will look into a couple of case studies where one of the solutions is
based on principles of Enterprise Application Integration and in the second one we
shall build our solution based on SOA fundamentals.

In Chapter 6 we will explore in detail the advantages that the SOA approach can
lead to. Basically a concluding chapter discussing what we can and what we have
achieved with SOA approach.

Conventions
In this book, you will find a number of styles of text that distinguish between
different kinds of information. Here are some examples of these styles, and an
explanation of their meaning.

There are three styles for code. Code words in text are shown as follows: "On the
other hand, having a filled item into the response is meaningful just for the
findById method."

A block of code will be set as follows:


public interface IHello{
String sayHello (String name);
}

[]
Preface

When we wish to draw your attention to a particular part of a code block, the
relevant lines or items will be made bold:
@XmlRootElement(name="ItemAction")
public class ItemAction{
private String method;
private Item item;
...
@XmlRootElement(name="ItemActionResponse")
public class ItemActionResponse {
private String retCode
private Item item;
...

New terms and important words are introduced in a bold-type font. Words that you
see on the screen, in menus or dialog boxes for example, appear in our text like this:
"clicking the Next button moves you to the next screen".

Important notes appear in a box like this.

Tips and tricks appear like this.

Reader Feedback
Feedback from our readers is always welcome. Let us know what you think about
this book, what you liked or may have disliked. Reader feedback is important for us
so that we may develop titles that you get the most out of.

To send us general feedback, simply drop an email to [email protected],


making sure to mention the book title in the subject of your message.

If there is a book that you need and would like to see us publish, please send
us a note in the SUGGEST A TITLE form on www.packtpub.com or
email [email protected].

If there is a topic that you have expertise in and you are interested in either writing
or contributing to a book, see our author guide on www.packtpub.com/authors.

[]
Customer Support
Now that you are the proud owner of a Packt book, we have a number of things to
help you to get the most from your purchase.

Downloading the Example Code for the Book


Visit http://www.packtpub.com/files/code/3216_Code.zip to directly
download the example code.

The downloadable files contain instructions on how to use them.

Errata
Although we have taken every care to ensure the accuracy of our contents, mistakes
do happen. If you find a mistake in one of our books—maybe a mistake in text or
code—we would be grateful if you would report this to us. By doing this you can
save other readers from frustration, and help to improve subsequent versions of
this book. If you find any errata, report them by visiting http://www.packtpub.
com/support, selecting your book, clicking on the let us know link, and entering
the details of your errata. Once your errata are verified, your submission will be
accepted and the errata are added to the list of existing errata. The existing errata can
be viewed by selecting your title from http://www.packtpub.com/support.

Questions
You can contact us at [email protected] if you are having a problem with
some aspect of the book, and we will do our best to address it.
The Mantra of SOA
Today, we are living in a world, where 'the age of information technology' is erasing
the boundaries of cities, states, and countries. This age is all about M and A's and key
to the success of such partnerships would depend on how well current independent
resources of each of these entities is re-used. But the biggest challenge would be
aligning these independent solutions into components that can be re-used across
the enterprise.

The answer lies in "architecting" a design that would take care of inter-enterprise
communication in a scalable form. But before getting into that, let's first try to
understand the term 'architecture' in the broader sense. This is one of the most
under-valued but the most important building block for any solution.

Architecture
"Architecture" is a Holy Grail for any design solution. It shows the major components
of the software solution and serves as a blueprint for the entire design. It is like a core
to the design of complex software solution.

Solution
Design

Architecture
The Mantra of SOA

It can be defined as a representation group(s) of relationship between various


components of a complex software solution. The solution is decomposed into
smaller, self-describing components and represented as structural relationships
to provide a high-level overview of the entire system. The system is divided into
runtime elements, which in itself could have architecture as well.

Consumer

Presentation Layer(HTML, CSS)

Application Layer(WSDL, SOAP)

Data

Oracle Db2

Shown here is a typical architecture for a database driven, web-based solution. It


provides us with a high-level overview of the entire system. The consumer only has
a view of the 'presentation layer' and other layers are tightly encapsulated. Each
layer would have its own characteristics as well as its own architecture.

Architecture can be compounded as a logical set of decisions to describe the life


of the project. These decisions will have a cascading affect on the selection and
integration of components such as the selection of software, hardware, and
behavior of the system. A good architecture will also take care of the future needs
of the project.

But then, why is architecture so important? Without proper architecture in place, it


would be difficult to achieve the following:

• Achieve our designed goal


• Decompose our requirements into smaller entities
• Quality solutions

[]
Chapter 1

• Change management
• Re-usable or extendable solutions
• Achieve business goals

Moving on from architecture, we will now dive into different architecture paradigms.

Application Architecture
At the most granular level in a system, you will always find sets of applications
running to achieve some business goals. These applications are developed using
different kinds of blueprints that we refer to as architecture. They provide an abstract
view of the entire application, or let us say a high-level overview of the system.

Application architecture can be considered as a representation of the structure


of components and the interaction between them in the system. They provide a
framework within which the business objectives are represented.

HTML/JSP

Java

MySQL

The previous figure shows a typical architecture of a web-based application. The


business requirements are converted into a high-level design where the:

• First layer of 'HTML or JSP' acts as the presentation layer.


• The business logic is encapsulated in the middle layer that could be built on
Servlets or EJB.
• Finally, the data is handled in the third layer 'MySQL'

Each organization will have multiple application architectures, which would cater to
the need of different business goals. These applications could be web–based, or even
the custom client server applications.

[]
The Mantra of SOA

Client-Server Architecture
The client-server architecture also known as two-tier architecture separates the client
from the server. Client is the system requesting a service from the provider (in our
case, server). The client will always initiate the request, which the server processes
and responds to. The client could send the request to one or more than one server
at a time.

Using this architecture, you can divide the responsibilities of the requester from the
provider. Earlier, as seen in monolithic systems, objectives were divided into smaller
pieces, and then tightly coupled into an application. Due to this, it was difficult to
process multiple clients. But, with the client-server architecture in place, business
process is done within the provider. This enables multiple clients to be plugged in at
the same time.

Large organizations usually have more than one application to support their
business goals. These are well supported by mainframes. Mainframes act as the core
business-processing unit with capacity to handle large chunks of data transactions.
Other computers in the organizations access the mainframe to achieve the business
goals. So in a way, the mainframes act as a server, and cater to different clients across
the organization. With the advent of monolithic computing, where applications were
tied to the data sources, the client-server architecture had become a welcome sign
for the industry.

The main advantage of the client-server architecture is that it is scalable. With


minimal performance impact, either the client or the server could be added.

Client-server architecture can be divided further into 1, 2, 3….n-tier architecture.


We will glance through each of these. The architecture is made up of three basic
layers—the presentation layer, the business layer, and the database or services layer.

Presentation layer is the one with which the client will interact. The consumer shall
either move through a click-based solution, or will input data into the front-end to
initiate the business process.

This layer could either be a thin or a fat client.

Business layer will enumerate the consumer action(s) and process the information
supplied by the 'presentation layer' to accomplish a business goal with a set of
business rules.

Data layer stores the data and logic that would be used to successfully achieve
business goals.

[]
Chapter 1

1-Tier Application
The single tier application would have the three layers, that is, the presentation, the
business, and the data layer tightly coupled which runs out of a single processing
unit. The application is designed in a way that the interaction between the layers
is interwoven.

Presentation
Business
Data

Within the tenets of client-server architecture, the single tier application can share the
data layer in a multi-user environment and achieve the client-server capabilities. The
limitations of 1-tier application in client-server architecture are as follows:

• Changes to the database, in case it is being edited by multiple users


• Difficulty in scalability, as the application is running on a single machine.

2-Tier Application
Within the 2-tier application, the presentation and the business layer combine on the
client side, while the data layer acts as the server. This enables the business logic to
be separated from the data services.

The 2-tier application would generally consist of a 'fat' client and a 'thin' server – 'fat'
client because it will embed the presentation as well as the business logic of the
application, and a 'thin' server, as it will only cater to the data needs of the client.

Presentation+Business Client

Data Server

[]
Random documents with unrelated
content Scribd suggests to you:
The Project Gutenberg eBook of The
Surprising and Singular Adventures of a Hen
as Related by Herself to Her Family of
Chickens
This ebook is for the use of anyone anywhere in the United
States and most other parts of the world at no cost and with
almost no restrictions whatsoever. You may copy it, give it away
or re-use it under the terms of the Project Gutenberg License
included with this ebook or online at www.gutenberg.org. If you
are not located in the United States, you will have to check the
laws of the country where you are located before using this
eBook.

Title: The Surprising and Singular Adventures of a Hen as


Related by Herself to Her Family of Chickens

Author: Anonymous

Release date: April 7, 2016 [eBook #51683]


Most recently updated: October 23, 2024

Language: English

Credits: Produced by David Edwards, readbueno and the Online


Distributed Proofreading Team at http://www.pgdp.net
(This
file was produced from images generously made
available
by The Internet Archive)

*** START OF THE PROJECT GUTENBERG EBOOK THE SURPRISING


AND SINGULAR ADVENTURES OF A HEN AS RELATED BY HERSELF
TO HER FAMILY OF CHICKENS ***
This cover was produced by the transcriber
and remains in the public domain.
FRONTISPIECE.

ADVENTURES OF A HEN.
THE

SURPRISING AND SINGULAR

Adventures

OF

A HEN

AS RELATED BY HERSELF TO HER FAMILY


OF CHICKENS.
LONDON:
PUBLISHED BY WHITTINGHAM AND ARLISS,
Juvenile Library,
PATER-NOSTER ROW.

1815.
ADVENTURES OF A HEN.

In the beautiful vale of Ravensworth, is situated a commodious


farm house: the proprietors treat all their domestic animals with
humanity, and provide every possible convenience for them. The
poultry yard is large and clean, at the bottom of it runs a clear
brook, in which you may always see a number of ducks and geese
sporting.
One day, as an old speckled hen was scratching up some grubs for
her numerous family, one of her chicks came running up to her. Oh,
mother, pray do go and kill the young bantam cock! Why? replied
the mother. Oh! he has behaved to me worse than ever any chicken
behaved to another, and I will be revenged; I know I cannot fight
him myself, but I hope you will. Not till I know how he has offended.
Why, I had just scratched up a fine fat worm, and was cackling with
delight, thinking what a nice feast I should have, when the nasty
little bantum came, snatched it from me, ran away with it, and eat it,
even before my face.
Doubtless he has behaved very improperly, replied the old hen;
but that is no reason you should; the best way of revenging yourself,
is to take no notice of him, or ever play with him again; instead of
wasting your time in quarrelling, search for another. What! and not
punish him for so very unjust an action! did you ever hear of any
thing so shameful before? Oh yes, many things. I should like to hear
one of them. Well, my dear, I have no objection; but as it is so very
hot, it would be better to go under the shade of the laburnum, and I
will then relate to you the chief occurrences of my eventful life. The
old hen then walked stately on, followed by her chickens; and having
got upon a stone, to be a little higher than her audience, the young
ones ranged themselves round her, and she began as follows:
I was hatched with six more in a large nest, formed by my
mother; as soon as we broke the shell, she carefully threw out every
thing she thought would hurt our tender bodies, spread her warm
wings over us, and prattled us to sleep: when we awoke, we
complained of hunger; she immediately went forth in search of food,
but, alas! we never saw her more.
There chanced to be a large strange dog in the yard, my mother
thinking he came to destroy us, flew at him, the contest was
unequal, the dog provoked, seized my mother by the neck, and
strangled her.
We lay cold and comfortless, wondering what had become of our
parent. Before night, two of my brothers died; and we should all
soon have shared their fate, had not a little girl, the farmer's
daughter, found us: she took us to the fire, and fed us with a little
warm milk and bread, which revived us; she then wrapped us up in
flannel, and put us in a little basket, which she put in the chimney
corner. She fed us very regularly; but I suppose not with proper
food, as all my poor sisters and brothers died, probably I was
stronger than they. My little mistress grew very fond of me, as I
would eat out of her hand, and when she called chickee, would run
to her.
As I grew large, I was very troublesome in flying upon the tables,
and pecking at every thing; many severe blows I got from the
farmer and his servants; who always ended by saying, if that
troublesome fowl is not sent into the poultry yard, it shall certainly
be killed; but my mistress always begged that I might stay a little
longer, for she feared the other fowls would drive me away.
And indeed I had not endeavoured to make friends of any of
them; but when the door was open, and I could see them, I insulted
them, with calling out, poor creatures! you are obliged to work hard
all day, and can scarcely get enough to eat, while I am fed plentifully
with the greatest dainties, and have nothing to do but amuse myself.
An old hen who had been a friend of my mother's, offered to supply
her place, in teaching me how to scratch for myself; but I rejected
her kind advice with disdain.

Nursing the chicken.

At last my young mistress could keep me no longer, her father


insisted that I should either be killed, or go with the rest of my
species, and setting open the door they fairly hunted me out.
Now it was my turn to experience mortification: numbers had
been witnesses of my disgraceful exit, and taunted me with, so her
ladyship is obliged to come among the working people; I suppose
food will come flying to her, as she is of too much consequence to
work; I wonder if her claws are differently made to ours?
In the evening, when the servant came to scatter corn, I was very
hungry, and thought that would be a nice treat for me; but, alas!
coarse as the food was, it was denied me; no one would suffer me
to partake, but flew at, and pecked me whenever I attempted it,
saying, no, no, mistress, you shall have none of this, we who have
done our duty, may be rewarded; but what have you done? nothing.
Thus was I driven from society, a thousand times did I wish that I
had never known any other pleasure than the rest, and that my
mistress had not nursed me so tenderly; but she did it from
kindness, and I shall ever respect her memory.
One morning I was rudely seized, and put with several more into a
small wicker basket, to be taken to market: my sensations upon that
occasion, no words can describe; to the market we came, and were
exposed for sale.
Putting the hen into the basket.

Numbers came to inquire our price, I was lifted up, and pricked,
and pulled about, to see whether I was fat; but the distress I had of
late been in, had made me very thin, I was therefore always thrown
down again, with this observation, why, what a bag of bones this
hussey is, I would not have her if you would give her to me.
All my companions were sold, and I remained till night tired and
hungry. Towards the close of the market, when the people were
preparing to return home, a little girl passed by me with a piece of
bread in her hand; urged by hunger I pecked at it, and when she
patted me, though my poor sides were all over bruises, I would not
appear as if she hurt me, but rubbed my head against her hand; she
seemed much delighted with me, crying out, Oh! what a nice tame
little creature, how I wish you were mine, but I fear I have not
money enough to buy you. Why what can you give? (said the man
who brought me from the farm.) I have but one shilling; but I will
give you all that. Very well, you shall have it then, for I am sure
there is not any use in taking it back.
Little Ann, my new mistress, took me directly home; her mother
lived in a thatched cottage, and was very poor: when she heard Ann
had given all her money for me, she was very angry. Oh dear
mother! you know it will soon lay eggs, which we can sell, and get
chickens besides. You foolish girl, you cannot get both, what do you
intend to feed it with? and we have no place to keep it in. Oh, we
can keep it very well in the wood house, I will put up a perch for it,
we will give it some crumbs to night, and to morrow it will provide
for itself.
Purchasing the hen.

I accordingly had a good supper and went to rest in a clay hovel,


very different to what I had been accustomed to, but I thought how
much worse my situation might have been; my fatigue and anxiety
soon put me into a sound sleep, from which I was awakened, by
being violently laid hold of. When I opened my eyes, I saw a great
ugly man who held a sack and lanthorn in his hand. Oh! oh! mistress
hen, I did not expect such luck, you will be a nice addition to my
stock: he then threw me into the sack, which he flung over his
shoulder, and walked a considerable way; this mode of carrying me,
together with my sore bruises, produced such violent pain, that I
grew quite insensible; when I recovered, I found myself confined
with several of my fellow creatures in a large hen-coop, they told me
they had all been stolen by the same man, some had been torn from
their children, husbands, or parents. I asked for what purpose.
What! can you be ignorant that he intends taking us to market to be
killed, and eaten? At the thought of being exposed in my present
miserable condition to be handled by the multitude, my blood froze
in my veins.
Stealing the hen.

I passed about a week in this coop; we were well fed, as our


keeper wished to make us fat. One night we were alarmed with a
tremendous noise, I turned to inquire the cause, when I saw the
brave white cock trembling like a chick: oh! said he, give yourselves
over now, nothing can save us from destruction, we shall all be
devoured; no sooner had he said this, but a large fox entered; Oh!
my children, how can I describe the horrors of the bloody scene
which followed, even at this distance of time, the recollection draws
tears from my eyes; I alone remained of all my companions; he was
advancing to me, when some noise in the yard frightened him, and
he ran away, leaving me more dead than alive with fright.
After he had been gone some time, I considered that if I stayed
where I was, in a few days I should be taken to market: the board
which the fox had broken down, offered the way to escape; but
where was I to go to, how should I know the way to the cottage of
Ann? but the market was worse to my imagination than any other
thing. I went through the opening, flew down, and found myself in
the open road, I ran as fast as possible, only stopping to take
breath, or a mouthful of food; many frights had I before night, from
dogs, boys, &c. As the sun was setting, I came to a fine large
garden, with a high wall round it; I flew to the top, and not seeing
any person in it, I thought I would look out for some grubs, or
worms, in a fine bed of newly turned up mould, and then go to rest
upon one of the trees; I had scarcely began my search, when I
found in the ground some very pleasant tasted seeds, which I began
to devour, when I received a blow upon my wing from a stone, and
looking up, I beheld the gardener coming forward in a furious
passion. So I have now discovered who it is that scratches up all my
seeds; but these are the last you shall ever taste, believe me; saying
this, he seized me in the most brutal manner. I screamed violently;
by this time, another man came up, and said, Why, Thomas, what
will you do with it? if it had been a cock, you might have had fine
sport with it, in throwing sticks at it. And why can't I at a hen, pray?
Oh, why nobody ever does. Well then, I will be the first to throw; I
will take her to the village, tie her to a stake, and the boys shall
have a throw for a halfpenny a piece.
While they were carrying me away, a lovely looking boy asked
them what they were going to do with me. To make a cock-shye.
Master, what is that? To throw sticks at it till it is killed. Oh, heavens!
you surely are jesting, you cannot have so much barbarity? As to
that, it has had the barbarity to eat up my seeds, to repay me for
them, the nasty creature shall pay its life.
The young gentleman, whose name was Augustus Manly,
entreated that he might purchase me, and offered half a crown; but
the man determined I should have a few blows, and tied me to the
stake, when Augustus seeming to be inspired with more than
ordinary courage, threw down his half crown, and lifting me from the
ground, when the barbarous gardeners were not looking, ran off
with me in his arms: the men could not overtake him by running,
but were cowardly enough to throw a stone, which struck me on the
breast; but by the care of this humane boy, I soon entirely
recovered.
Taking away the hen.

My master was a pupil in a very large school; the house in which


he boarded, accommodated twelve more, but none so kind as
himself; many slight injuries I received, but I considered how much
worse my lot had been, and felicitated myself accordingly; but too
soon I felt the most acute torments.
My master was often laughed at by the other boys for his
fondness for me: I loved him so much, that whenever he came into
the yard, I ran to meet him, would feed out of his hand, or fly upon
his shoulder, but this I would never do to any other boy, and by this
I suppose it was which made them hate me.
One day two of them came into the garden to read, the story they
fixed upon was, unfortunately for me, that cruel one of Diogenes
stripping a cock of all its feathers, and throwing it into the middle of
the school where Plato was instructing his disciples; crying, 'there is
Plato's man for you.' They laughed heartily at this, and one of them
cried out, Oh! the most admirable thought has struck me! let us
serve Manly's hen in the same way, and when he is in bed to night,
we will open the door, and throw it at him, and cry out, 'there is
Manly's lady for you.' This was highly approved of, and I was
accordingly seized, and stripped of my feathers. Oh! Dickey, was not
this far more unjust than the young bantum's taking your worm from
you? that could give you no pain, but the tortures I endured, no one
can possibly imagine; the blood flowed copiously, the skin was torn
from the flesh, I wished for death to put an end to my torments, but
that was denied.
At night they fulfilled their intention, my benefactor was truly
distressed to see my miserable condition, and taking me to the
mistress of the house, and implored her assistance to cure me; she
wished to have me killed instantly, but that he would not consent to.
As she was a humane woman, she endeavoured to cure me; and got
some oil, which she carefully rubbed over me, and I was kept in a
place where these wicked boys could not come to me. I had the
pleasure of hearing that these boys had been expelled from the
school, the greatest disgrace that could befall them.
It was long before I was entirely recovered; the next holidays
Augustus determined to take me home with him, and leave me in
charge of his amiable sister, whom he knew would nurse me
tenderly. There I may say I was perfectly happy for some time. I
became a mother, and had the delight of seeing my children beloved
by Augustus and his sister.
Once, owing to the carelessness of a servant, I hatched some
duck eggs, I did not perceive the mistake, till taking my chickens (as
I thought them) out, to teach them to scratch, they all ran towards
the water; in vain I called after them to stop, that they would be
drowned if they attempted to go in; deaf to my entreaties, they
threw themselves in, I came to the pond in all the agonies of
despair, expecting to see all my precious little ones dead; but, to my
astonishment, they were all swimming merrily. A duck with whom I
was intimate (for I made it a rule to treat all the domestic fowls with
civility) came up and assured me she would take care of my young
charge while they were on the water, and teach them to swim.
Soon after, Augustus intended giving a supper to some of his
friends, and it was proposed that each one should bring his favourite
dish; Charles Mellish, Manly's cousin, was staying with him, he was a
boy of an ardent temper, and would do any thing by way of frolic, or
what he called fun; from the time this supper was proposed, he
determined his dish should differ from every other persons, he
accordingly procured from the cook a large pie dish and cover, and
when the party assembled, he came into the poultry yard, seized
me, and in spite of my peeking and scratching, forced me into it,
covered me over with leaves, and placed the lid on; when he
entered the parlour, I heard a number of little voices say, I wonder
what Charles has got. He replied, something different to any one
else I think; but before I let you see what it is, I must make an
agreement that if it is different, every one of the ladies shall give me
a kiss; but if any other person ever thought of bringing the same,
every one in the room shall have the liberty to give me a slap on the
face. This being agreed to, he set the dish upon the table, and took
off the lid; I, who had been sadly cramped, immediately flew out, to
the great astonishment of all present. I suppose master Charles
received the reward from the ladies, but of that I did not wait to be
witness; but ran out of the room as fast as possible.
Charles's dish.

Not long after, I was again seized by the same gentleman, who
having discovered that miss Manly, and a party of her friends were
assembled round a small fire, telling terrible stories of ghosts and
murders, resolved to frighten them; he placed a ladder by the side
of the chimney, and mounting it, put me in at the top. I was glad to
escape from him, so I flew down the chimney, carrying the soot with
me, which suddenly put out the fire; and when I entered the room,
the most terrible screams were heard from all quarters; the servants
soon came in with lights, to know what misfortune had happened, to
occasion such an uproar. I had hidden myself in a corner of the
room; one of the young ladies said it must be a ghost, that they had
been sitting very quietly, when suddenly they heard a tremendous
noise, the fire was extinguished in an instant, that a thick cloud of
smoke followed, and a great black thing, the shape of which she
could not distinguish, knocked against her face, and threw her
down. By this time, Charles had joined them, and hearing such
exaggerated stories, burst into a hearty laugh. You may laugh, said
one of the ladies, but had you been here when it happened, you
would have been as frightened as we were, it could not be fancy, for
see the fire is out, and what a strong smell of sulphur is in the room.
The fright.

What would you think of me, if I discovered the cause of this


wonderful affair? I should think you very clever indeed. Well then,
give me a candle and I will soon find the ghost; he then took one off
the table and by its assistance, soon discovered poor me sitting
disconsolate under the table; at this the whole party joined in a
hearty laugh; except myself, who had got some soot in my eyes,
which made them very painful. Augustus took me in his arms, my
poor hen, said he, you have had many strange adventures, and if
you should ever take it into your head to write them (for all animals
write their lives now-a-days), you shall make good mention of me,
for I will now give you a good supper after your troubles.
At the idea of a hen's writing her adventures, the party was highly
diverted; no, said they, that can never be, as a domestic fowl can
know nothing out of the poultry yard, and that would never be worth
reading; but I think, my children, that some of the adventures I have
gone through, are almost as wonderful as those of cats and dogs,
which I hear are published in little books: talking of cats, I once had
a severe combat with one of them, in which I nearly lost one of my
eyes, and had many feathers torn off: as to dogs, I was always
afraid of approaching them, remembering the melancholy fate of my
poor mother.
One time, when the family was paying a visit, orders were sent to
the servant to fatten one of the fowls, then kill it, and send it to a
poor neighbour who was sick; I was the one pitched upon, and was
confined in a little coop, where I could scarcely turn round, much
less take that exercise which is necessary to health, my confinement
was still more distressing, when looking out, I could see all my
companions enjoying themselves, how I longed to join in their
sports.
I loathed the quantities of food brought me, and would freely have
given a saucer full of delicious white bread softened with cream, for
the delight of scratching up a worm for myself; but though I had no
appetite I ate, because I had nothing else to do; and that being such
voluptuous food, soon made me excessively fat, which caused me
much pain, as I could scarcely breathe. I look forward with joy to
the time, when the murderer's knife would end my miseries; the day
was fixed.
On the morning of that day, to my astonishment, I saw Augustus
enter the yard, he had returned from his visit much sooner than was
expected: when I saw him, I thought of all his kindness, and wished
to hear him speak once more before I died; for which purpose, I
called as intelligibly as I could to him; at last I had the pleasure of
hearing him say, what can be the matter with that poor hen which is
confined, I never heard so pitiful a cry! Upon seeing it was his old
favourite, Oh! my poor bird, said he, were you so near being killed;
but I am very glad I have come in time to save you; saying this, he
opened the door, and gave me liberty, that greatest of all blessings.
I was expressing, in my language, my thanks, when Susan
entered with her knife; Oh! Susan, how could you think of killing this
my favourite? Pray sir, how should I know which you please to call
your favourite? All hens are alike to me, I caught the one which was
nearest to me, and as it is now fattened, we must have it, and you
may take another favourite. No, this one you shall never kill; it is
cruel to destroy any, but this which knows me so well, and is so
tame, I never will have it killed; so saying, he carried me away,
leaving Sue in a great passion.
Soon after, my young master had to go to a boarding school, near
London; his mamma accompanied him, and shut up her house; what
was to be done with me, engaged much of his thoughts; at last he
determined to place me here, with this worthy farmer, till his return.
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.

Let us accompany you on the journey of exploring knowledge and


personal growth!

ebooknice.com

You might also like