Programming WCF Services Mastering WCF and the Azure AppFabric Service Bus Third Edition Juval Lowy download
Programming WCF Services Mastering WCF and the Azure AppFabric Service Bus Third Edition Juval Lowy download
https://ebookname.com/product/programming-wcf-services-mastering-
wcf-and-the-azure-appfabric-service-bus-third-edition-juval-lowy/
https://ebookname.com/product/programming-net-3-5-build-n-tier-
applications-with-wpf-ajax-silverlight-linq-wcf-and-more-1st-
edition-jesse-liberty/
https://ebookname.com/product/com-and-net-component-services-1st-
edition-juval-lowy/
https://ebookname.com/product/pro-wcf-4-practical-microsoft-soa-
implementation-2nd-ed-2nd-edition-nishith-pathak/
https://ebookname.com/product/all-rise-somebodies-nobodies-and-
the-politics-of-dignity-bk-currents-hardcover-robert-w-fuller/
Nonlinear Random Vibration Analytical Techniques and
Applications 2nd Edition Cho W.S. To
https://ebookname.com/product/nonlinear-random-vibration-
analytical-techniques-and-applications-2nd-edition-cho-w-s-to/
https://ebookname.com/product/ancestors-of-worthy-life-
plantation-slavery-and-black-heritage-at-mount-clare-1st-edition-
teresa-s-moyer/
https://ebookname.com/product/clojure-for-finance-1st-edition-
washington/
https://ebookname.com/product/instrumentation-theory-and-
applications-1st-edition-satya-sheel/
https://ebookname.com/product/intercultural-utopias-public-
intellectuals-cultural-experimentation-and-ethnic-pluralism-in-
colombia-1st-edition-joanne-rappaport/
Water Related Death Investigation Practical Methods and
Forensic Applications 1st Edition Erica J. Armstrong
https://ebookname.com/product/water-related-death-investigation-
practical-methods-and-forensic-applications-1st-edition-erica-j-
armstrong/
Download from Library of Wow! eBook <www.wowebook.com>
Download from Library of Wow! eBook <www.wowebook.com>
Programming WCF Services
Juval Löwy
Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472.
O’Reilly books may be purchased for educational, business, or sales promotional use. Online editions
are also available for most titles (http://my.safaribooksonline.com). For more information, contact our
corporate/institutional sales department: (800) 998-9938 or [email protected].
Editors: Mike Hendrickson and Laurel Ruma Indexer: Newgen North America, Inc.
Production Editor: Teresa Elsey Cover Designer: Karen Montgomery
Proofreader: Teresa Elsey Interior Designer: David Futato
Illustrator: Robert Romano
Printing History:
February 2007: First Edition.
November 2008: Second Edition.
August 2010: Third Edition.
Nutshell Handbook, the Nutshell Handbook logo, and the O’Reilly logo are registered trademarks of
O’Reilly Media, Inc. Programming WCF Services, Third Edition, the image of an angelfish, and related
trade dress are trademarks of O’Reilly Media, Inc.
Many of the designations used by manufacturers and sellers to distinguish their products are claimed as
trademarks. Where those designations appear in this book, and O’Reilly Media, Inc., was aware of a
trademark claim, the designations have been printed in caps or initial caps.
While every precaution has been taken in the preparation of this book, the publisher and author assume
no responsibility for errors or omissions, or for damages resulting from the use of the information con-
tained herein.
ISBN: 978-0-596-80548-7
[M]
1281631550
Foreword . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xvii
Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxi
1. WCF Essentials . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
What Is WCF? 1
Services 2
Service Execution Boundaries 3
WCF and Location Transparency 4
Addresses 4
TCP Addresses 5
HTTP Addresses 6
IPC Addresses 6
MSMQ Addresses 7
Service Bus Addresses 7
Contracts 7
The Service Contract 8
Hosting 11
IIS 5/6 Hosting 12
Self-Hosting 13
WAS Hosting 19
Custom Hosting in IIS/WAS 19
Windows Server AppFabric 20
Choosing a Host 22
Bindings 24
The Common Bindings 25
Choosing a Binding 26
Additional Bindings 27
Using a Binding 29
Endpoints 29
Administrative Endpoint Configuration 30
vii
2. Service Contracts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
Operation Overloading 83
Contract Inheritance 86
Client-Side Contract Hierarchy 87
Service Contract Factoring and Design 90
Contract Factoring 90
Factoring Metrics 93
Contract Queries 95
Programmatic Metadata Processing 95
The MetadataHelper Class 98
Table of Contents | ix
5. Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225
Request-Reply Operations 225
One-Way Operations 226
Configuring One-Way Operations 226
One-Way Operations and Reliability 227
One-Way Operations and Sessionful Services 227
One-Way Operations and Exceptions 228
Callback Operations 230
The Callback Contract 231
Client Callback Setup 232
Service-Side Callback Invocation 235
Callback Connection Management 239
The Duplex Proxy and Type Safety 241
The Duplex Factory 244
Callback Contract Hierarchy 246
Events 247
Streaming 251
I/O Streams 251
Streaming and Binding 252
Streaming and Transport 253
6. Faults . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255
Error Isolation and Decoupling 255
Error Masking 256
x | Table of Contents
7. Transactions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 293
The Recovery Challenge 293
Transactions 294
Transactional Resources 295
Transaction Properties 295
Transaction Management 297
Resource Managers 301
Transaction Propagation 301
Transaction Flow and Bindings 301
Transaction Flow and the Operation Contract 302
One-Way Calls 304
Transaction Protocols and Managers 305
Protocols and Bindings 306
Transaction Managers 307
Transaction Manager Promotion 310
The Transaction Class 311
The Ambient Transaction 312
Local Versus Distributed Transactions 312
Transactional Service Programming 314
Setting the Ambient Transaction 314
Transaction Propagation Modes 316
Voting and Completion 324
Transaction Isolation 327
Transaction Timeout 329
Explicit Transaction Programming 331
The TransactionScope Class 331
Transaction Flow Management 333
Non-Service Clients 340
Service State Management 342
The Transaction Boundary 343
Instance Management and Transactions 343
Table of Contents | xi
Table of Contents | xv
C. Discovery . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 723
Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 855
When Juval Löwy asked me to write the foreword for the first edition of this book, I
was working in a Community Program Manager role for the brand-new Windows
Communication Foundation (WCF) framework at Microsoft. WCF was the result of
a multiyear effort to write a unified communication framework for Windows. It was
also the result of a multiyear effort to create an interoperable messaging standards
framework centered around XML and the SOAP envelope model, with a common
model for addressing; a transport-independent abstraction for session management and
ordered delivery semantics; and a common model for message and session protection,
for federated authentication and authorization, and for many more capabilities. This
industry-wide standardization effort is still in progress with Microsoft and partners
across the industry, refining and updating this common messaging framework (sum-
marily nicknamed “WS-*”), more than 10 years after the SOAP 1.1 specification was
submitted as a note to W3C, which started this process.
As I write the foreword to the new edition, I’m filling an Architect role on the Windows
Azure AppFabric team at Microsoft. More precisely, I’m contributing to the architec-
ture of the service bus, a service offering that’s part of the Windows Azure Platform
and which Juval covers in Chapter 11 and the appendixes of this book. The way I
commonly describe the effort of building a commercial web services infrastructure, like
the service bus or its sibling service, Windows Azure AppFabric Access Control, is to
use the familiar iceberg analogy. The “above the water” features that the customers get
to interact with on the public protocol and API surface area make up a relatively small
portion of the overall effort. The rest, all the things beneath the waterline, quite closely
resembles a large-scale, mission-critical Enterprise application infrastructure—with the
special quality and challenge of running on a public cloud-based infrastructure.
When you create a Windows Azure account, your data and the provisioning jobs run
through WCF SOAP services. When you create a new service namespace in our system,
the messages flow between data centers using WCF SOAP services, creating resources
in the places where you ask for them to be created. Monitoring happens via WCF SOAP
services; diagnostics happens via WCF SOAP services; billing data collection, consol-
idation, and handoff happens using WCF SOAP services.
xvii
xviii | Foreword
Foreword | xix
In August 2001, I first learned the details of a Microsoft effort to rewrite COM+ using
managed code. Nothing much happened after that. Then, during a C# 2.0 Strategic
Design Review in July 2002, the remoting program manager outlined in broad strokes
plans to rework remoting into something that developers should actually use. At the
same time, Microsoft was also working on incorporating the new security specs for web
services into the ASMX stack and actively working with others on drafting a score of
additional web services specs.
In July 2003, I was given access to a new transactional infrastructure that improved on
the deficiencies in transactional .NET programming. At the time, there was no cohesive
programming model that unified these distinct technologies. Toward the end of 2003,
I was privileged to be invited to join a small team of outside industry experts and to
participate in the strategic design review of a new development platform codenamed
Indigo. Some of the smartest and nicest people I know were part of that team. Over the
next two to three years, Indigo went through some three generations of programming
models. The final declarative, endpoint-driven object model debuted in early 2005, was
stabilized by August of that year, and was named the Windows Communication Foun-
dation (WCF). WCF was released in November 2006 as part of .NET 3.0.
As I am writing these lines in late 2010, I find it hard to believe the past four years have
gone so quickly, and that I have a third edition of the book to correspond with the third
release of WCF and .NET 4.0.
It is difficult to get a consistent answer from different people on what WCF is. To the
web service developer, it is the ultimate interoperability solution, an implementation
of a long list of industry standards. To the distributed application developer, it is the
easiest way of making remote calls and even queued calls. To the system developer, it
is the next generation of productivity-oriented features, such as transactions and host-
ing, that provide off-the-shelf plumbing for applications. To the application developer,
it is a declarative programming model for structuring applications. And to the architect,
it is a tool for building service-oriented applications. WCF is, in actuality, all of those,
simply because it was designed that way—to be the unified next generation of Micro-
soft’s disparate technologies.
xxi
xxii | Preface
Preface | xxiii
There was a strong fortress situated at the head of the pier or mole
leading to the island of Pharos, which was without Cæsar’s lines, and
still in the hands of the Egyptian authorities. The Egyptians thus
commanded the entrance to the mole. The island itself, also, with
the fortress at the other end of the pier, was still in the possession of
the Egyptian authorities, who seemed disposed to hold it for Achillas.
The mole was very long, as the island was nearly a mile from the
shore. There was quite a little town upon the island itself, besides
the fortress or castle built there to defend the place. The garrison of
this castle was strong, and the inhabitants of the town, too,
constituted a somewhat formidable population, as they consisted of
fishermen, sailors, wreckers, and such other desperate characters as
usually congregate about such a spot. Cleopatra and Cæsar, from
the windows of their palace within the city, looked out upon this
island, with the tall light-house rising in the center of it and the
castle at its base, and upon the long and narrow isthmus connecting
it with the main land, and concluded that it was very essential that
they should get possession of the post, commanding, as it did, the
entrance to the harbor.
In the harbor, too, which, as will be seen from the engraving, was on
the south side of the mole, and, consequently, on the side opposite
to that from which Achillas was advancing toward the city, there
were lying a large number of Egyptian vessels, some dismantled,
and others manned and armed more or less effectively. These
vessels had not yet come into Achillas’s hands, but it would be
certain that he would take possession of them as soon as he should
gain admittance to those parts of the city which Cæsar had
abandoned. This it was extremely important to prevent; for, if
Achillas held this fleet, especially if he continued to command the
island of Pharos, he would be perfect master of all the approaches to
the city on the side of the sea. He could then not only receive re-
enforcements and supplies himself from that quarter, but he could
also effectually cut off the Roman army from all possibility of
receiving any. It became, therefore, as Cæsar thought, imperiously
necessary that he should protect himself from this danger. This he
did by sending out an expedition to burn all the shipping in the
harbor, and, at the same time, to take possession of a certain fort
upon the island of Pharos which commanded the entrance to the
port. This undertaking was abundantly successful. The troops
burned the shipping, took the fort, expelled the Egyptian soldiers
from it, and put a Roman garrison into it instead, and then returned
in safety within Cæsar’s lines. Cleopatra witnessed these exploits
from her palace windows with feelings of the highest admiration for
the energy and valor which her Roman protectors displayed.
The burning of the Egyptian ships in this action, however fortunate
for Cleopatra and Cæsar, was attended with a catastrophe which has
ever since been lamented by the whole civilized world. Some of the
burning ships were driven by the wind to the shore, where they set
fire to the buildings which were contiguous to the water. The flames
spread and produced an extensive conflagration, in the course of
which the largest part of the great library was destroyed. This library
was the only general collection of the ancient writings that ever had
been made, and the loss of it was never repaired.
The destruction of the Egyptian fleet resulted also in the downfall
and ruin of Achillas. From the time of Arsinoë’s arrival in the camp
there had been a constant rivalry and jealousy between himself and
Ganymede, the eunuch who had accompanied Arsinoë in her flight.
Two parties had been formed in the army, some declaring for
Achillas and some for Ganymede. Arsinoë advocated Ganymede’s
interests, and when, at length, the fleet was burned, she charged
Achillas with having been, by his neglect or incapacity, the cause of
the loss. Achillas was tried, condemned, and beheaded. From that
time Ganymede assumed the administration of Arsinoë’s government
as her minister of state and the commander-in-chief of her armies.
About the time that these occurrences took place, the Egyptian army
advanced into those parts of the city from which Cæsar had
withdrawn, producing those terrible scenes of panic and confusion
which always attend a sudden and violent change of military
possession within the precincts of a city. Ganymede brought up his
troops on every side to the walls of Cæsar’s citadels and
intrenchments, and hemmed him closely in. He cut off all avenues of
approach to Cæsar’s lines by land, and commenced vigorous
preparations for an assault. He constructed engines for battering
down the walls. He opened shops and established forges in every
part of the city for the manufacture of darts, spears, pikes, and all
kinds of military machinery. He built towers supported upon huge
wheels, with the design of filling them with armed men when finally
ready to make his assault upon Cæsar’s lines, and moving them up
to the walls of the citadels and palaces, so as to give to his soldiers
the advantage of a lofty elevation in making their attacks. He levied
contributions on the rich citizens for the necessary funds, and
provided himself with men by pressing all the artisans, laborers, and
men capable of bearing arms into his service. He sent messengers
back into the interior of the country, in every direction, summoning
the people to arms, and calling for contributions of money and
military stores.
These messengers were instructed to urge upon the people that,
unless Cæsar and his army were at once expelled from Alexandria,
there was imminent danger that the national independence of Egypt
would be forever destroyed. The Romans, they were to say, had
extended their conquests over almost all the rest of the world. They
had sent one army into Egypt before, under the command of Mark
Antony, under the pretense of restoring Ptolemy Auletes to the
throne. Now another commander, with another force, had come,
offering some other pretexts for interfering in their affairs. These
Roman encroachments, the messengers were to say, would end in
the complete subjugation of Egypt to a foreign power, unless the
people of the country aroused themselves to meet the danger
manfully, and to expel the intruders.
As Cæsar had possession of the island of Pharos and of the harbor,
Ganymede could not cut him off from receiving such re-
enforcements of men and arms as he might make arrangements for
obtaining beyond the sea; nor could he curtail his supply of food, as
the granaries and magazines within Cæsar’s quarter of the city
contained almost inexhaustible stores of corn. There was one
remaining point essential to the subsistence of an army besieged,
and that was an abundant supply of water. The palaces and citadels
which Cæsar occupied were supplied with water by means of
numerous subterranean aqueducts, which conveyed the water from
the Nile to vast cisterns built under ground, whence it was raised by
buckets and hydraulic engines for use. In reflecting upon this
circumstance, Ganymede conceived the design of secretly digging a
canal, so as to turn the waters of the sea by means of it into these
aqueducts. This plan he carried into effect. The consequence was,
that the water in the cisterns was gradually changed. It became first
brackish, then more and more salt and bitter, until, at length, it was
wholly impossible to use it. For some time the army within could not
understand these changes; and when, at length, they discovered the
cause, the soldiers were panic-stricken at the thought that they were
now apparently wholly at the mercy of their enemies, since, without
supplies of water, they must all immediately perish. They considered
it hopeless to attempt any longer to hold out, and urged Cæsar to
evacuate the city, embark on board his galleys, and proceed to sea.
Instead of doing this, however, Cæsar, ordering all other operations
to be suspended, employed the whole laboring force of his
command, under the direction of the captains of the several
companies, in digging wells in every part of his quarter of the city.
Fresh water, he said, was almost invariably found, at a moderate
depth, upon sea-coasts, even upon ground lying in very close
proximity with the sea. The diggings were successful. Fresh water, in
great abundance, was found. Thus this danger was passed, and the
men’s fears effectually relieved.
A short time after these transactions occurred, there came into the
harbor one day, from along the shore west of the city, a small sloop,
bringing the intelligence that a squadron of transports had arrived
upon the coast to the westward of Alexandria, and had anchored
there, being unable to come up to the city on account of an easterly
wind which prevailed at that season of the year. This squadron was
one which had been sent across the Mediterranean with arms,
ammunition, and military stores for Cæsar, in answer to requisitions
which he had made immediately after he had landed. The transports
being thus wind-bound on the coast, and having nearly exhausted
their supplies of water, were in distress; and they accordingly sent
forward the sloop, which was probably propelled by oars, to make
known their situation to Cæsar, and to ask for succor. Cæsar
immediately went, himself, on board of one of his galleys, and
ordering the remainder of his little fleet to follow him, he set sail out
of the harbor, and then turned to the westward, with a view of
proceeding along the coast to the place where the transports were
lying.
All this was done secretly. The land is so low in the vicinity of
Alexandria that boats or galleys are out of sight from it at a very
short distance from the shore. In fact, travelers say that, in coming
upon the coast, the illusion produced by the spherical form of the
surface of the water and the low and level character of the coast is
such that one seems actually to descend from the sea to the land.
Cæsar might therefore have easily kept his expedition a secret, had
it not been that, in order to be provided with a supply of water for
the transports immediately on reaching them, he stopped at a
solitary part of the coast, at some distance from Alexandria, and
sent a party a little way into the interior in search for water. This
party were discovered by the country people, and were intercepted
by a troop of horse and made prisoners. From these prisoners the
Egyptians learned that Cæsar himself was on the coast with a small
squadron of galleys. The tidings spread in all directions. The people
flocked together from every quarter. They hastily collected all the
boats and vessels which could be obtained at the villages in that
region and from the various branches of the Nile. In the mean time,
Cæsar had gone on to the anchorage ground of the squadron, and
had taken the transports in tow to bring them to the city; for the
galleys, being propelled by oars, were in a measure independent of
the wind. On his return, he found quite a formidable naval
armament assembled to dispute the passage.
A severe conflict ensued, but Cæsar was victorious. The navy which
the Egyptians had so suddenly got together was as suddenly
destroyed. Some of the vessels were burned, others sunk, and
others captured; and Cæsar returned in triumph to the port with his
transports and stores. He was welcomed with the acclamations of his
soldiers, and, still more warmly, by the joy and gratitude of
Cleopatra, who had been waiting during his absence in great anxiety
and suspense to know the result of the expedition, aware as she was
that her hero was exposing himself in it to the most imminent
personal danger.
The arrival of these re-enforcements greatly improved Cæsar’s
condition, and the circumstance of their coming forced upon the
mind of Ganymede a sense of the absolute necessity that he should
gain possession of the harbor if he intended to keep Cæsar in check.
He accordingly determined to take immediate measures for forming
a naval force. He sent along the coast, and ordered every ship and
galley that could be found in all the ports to be sent immediately to
Alexandria. He employed as many men as possible in and around the
city in building more. He unroofed some of the most magnificent
edifices to procure timber as a material for making benches and
oars. When all was ready, he made a grand attack upon Cæsar in
the port, and a terrible contest ensued for the possession of the
harbor, the mole, the island, and the citadels and fortresses
commanding the entrances from the sea. Cæsar well knew that this
contest would be a decisive one in respect to the final result of the
war, and he accordingly went forth himself to take an active and
personal part in the conflict. He felt doubtless, too, a strong emotion
of pride and pleasure in exhibiting his prowess in the sight of
Cleopatra, who could watch the progress of the battle from the
palace windows, full of excitement at the dangers which he incurred,
and of admiration at the feats of strength and valor which he
performed. During this battle the life of the great conqueror was
several times in the most imminent danger. He wore a habit or
mantle of the imperial purple, which made him a conspicuous mark
for his enemies; and, of course, wherever he went, in that place was
the hottest of the fight. Once, in the midst of a scene of most
dreadful confusion and din, he leaped from an overloaded boat into
the water and swam for his life, holding his cloak between his teeth
and drawing it through the water after him, that it might not fall into
the hands of his enemies. He carried, at the same time, as he swam,
certain valuable papers which he wished to save, holding them
above his head with one hand, while he propelled himself through
the water with the other.
The result of this contest was another decisive victory for Cæsar. Not
only were the ships which the Egyptians had collected defeated and
destroyed, but the mole, with the fortresses at each extremity of it,
and the island, with the light-house and the town of Pharos, all fell
into Cæsar’s hands.
The Egyptians now began to be discouraged. The army and the
people, judging, as mankind always do, of the virtue of their military
commanders solely by the criterion of success, began to be tired of
the rule of Ganymede and Arsinoë. They sent secret messengers to
Cæsar avowing their discontent, and saying that, if he would liberate
Ptolemy—who, it will be recollected, had been all this time held as a
sort of prisoner of state in Cæsar’s palaces—they thought that the
people generally would receive him as their sovereign, and that then
an arrangement might easily be made for an amicable adjustment of
the whole controversy. Cæsar was strongly inclined to accede to this
proposal.
He accordingly called Ptolemy into his presence, and, taking him
kindly by the hand, informed him of the wishes of the people of
Egypt, and gave him permission to go. Ptolemy, however, begged
not to be sent away. He professed the strongest attachment to
Cæsar, and the utmost confidence in him, and he very much
preferred, he said, to remain under his protection. Cæsar replied
that, if those were his sentiments, the separation would not be a
lasting one. “If we part as friends,” he said, “we shall soon meet
again.” By these and similar assurances he endeavored to encourage
the young prince, and then sent him away. Ptolemy was received by
the Egyptians with great joy, and was immediately placed at the
head of the government. Instead, however, of endeavoring to
promote a settlement of the quarrel with Cæsar, he seemed to enter
into it now himself, personally, with the utmost ardor, and began at
once to make the most extensive preparations both by sea and land
for a vigorous prosecution of the war. What the result of these
operations would have been can now not be known, for the general
aspect of affairs was, soon after these transactions, totally changed
by the occurrence of a new and very important event which
suddenly intervened, and which turned the attention of all parties,
both Egyptians and Romans, to the eastern quarter of the kingdom.
The tidings arrived that a large army, under the command of a
general named Mithradates, whom Cæsar had dispatched into Asia
for this purpose, had suddenly appeared at Pelusium, had captured
that city, and were now ready to march to Alexandria.
The Egyptian army immediately broke up its encampments in the
neighborhood of Alexandria, and marched to the eastward to meet
these new invaders. Cæsar followed them with all the forces that he
could safely take away from the city. He left the city in the night and
unobserved, and moved across the country with such celerity that he
joined Mithradates before the forces of Ptolemy had arrived. After
various marches and maneuvers, the armies met, and a great battle
was fought. The Egyptians were defeated. Ptolemy’s camp was
taken. As the Roman army burst in upon one side of it, the guards
and attendants of Ptolemy fled upon the other, clambering over the
ramparts in the utmost terror and confusion. The foremost fell
headlong into the ditch below, which was thus soon filled to the brim
with the dead and the dying; while those who came behind pressed
on over the bridge thus formed, trampling remorselessly, as they
fled, on the bodies of their comrades, who lay writhing, struggling,
and shrieking beneath their feet. Those who escaped reached the
river. They crowded together into a boat which lay at the bank and
pushed off from the shore. The boat was overloaded, and it sank as
soon as it left the land. The Romans drew the bodies which floated
to the shore up upon the bank again, and they found among them
one, which, by the royal cuirass which was upon it, the customary
badge and armor of the Egyptian kings, they knew to be the body of
Ptolemy.
The victory which Cæsar obtained in this battle and the death of
Ptolemy ended the war. Nothing now remained but for him to place
himself at the head of the combined forces and march back to
Alexandria. The Egyptian forces which had been left there made no
resistance, and he entered the city in triumph. He took Arsinoë
prisoner. He decreed that Cleopatra should reign as queen, and that
she should marry her youngest brother, the other Ptolemy—a boy at
this time about eleven years of age. A marriage with one so young
was, of course, a mere form. Cleopatra remained, as before, the
companion of Cæsar.
Cæsar had, in the mean time, incurred great censure at Rome, and
throughout the whole Roman world, for having thus turned aside
from his own proper duties as the Roman consul, and the
commander-in-chief of the armies of the empire, to embroil himself
in the quarrels of a remote and secluded kingdom, with which the
interests of the Roman commonwealth were so little connected. His
friends and the authorities at Rome were continually urging him to
return. They were especially indignant at his protracted neglect of
his own proper duties, from knowing that he was held in Egypt by a
guilty attachment to the queen—thus not only violating his
obligations to the state, but likewise inflicting upon his wife
Calpurnia, and his family at Rome, an intolerable wrong. But Cæsar
was so fascinated by Cleopatra’s charms, and by the mysterious and
unaccountable influence which she exercised over him, that he paid
no heed to any of these remonstrances. Even after the war was
ended he remained some months in Egypt to enjoy his favorite’s
society. He would spend whole nights in her company, in feasting
and revelry. He made a splendid royal progress with her through
Egypt after the war was over, attended by a numerous train of
Roman guards. He formed a plan for taking her to Rome, and
marrying her there; and he took measures for having the laws of the
city altered so as to enable him to do so, though he was already
married.
All these things produced great discontent and disaffection among
Cæsar’s friends and throughout the Roman army. The Egyptians,
too, strongly censured the conduct of Cleopatra. A son was born to
her about this time, whom the Alexandrians named, from his father,
Cæsarion. Cleopatra was regarded in the new relation of mother,
which she now sustained, not with interest and sympathy, but with
feelings of reproach and condemnation.
Cleopatra was all this time growing more and more accomplished
and more and more beautiful; but her vivacity and spirit, which had
been so charming while it was simple and childlike, now began to
appear more forward and bold. It is the characteristic of pure and
lawful love to soften and subdue the heart, and infuse a gentle and
quiet spirit into all its action; while that which breaks over the
barriers that God and nature have marked out for it, tends to make
woman masculine and bold, to indurate all her sensibilities, and to
destroy that gentleness and timidity of demeanor which have so
great an influence in heightening her charms. Cleopatra was
beginning to experience these effects. She was indifferent to the
opinions of her subjects, and was only anxious to maintain as long
as possible her guilty ascendency over Cæsar.
Cæsar, however, finally determined to set out on his return to the
capital. Leaving Cleopatra, accordingly, a sufficient force to secure
the continuance of her power, he embarked the remainder of his
forces in his transports and galleys, and sailed away. He took the
unhappy Arsinoë with him, intending to exhibit her as a trophy of his
Egyptian victories on his arrival at Rome.
Chapter VIII.
Cleopatra a Queen.
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.
ebookname.com