100% found this document useful (1 vote)
14 views

Programming WCF Services Mastering WCF and the Azure AppFabric Service Bus Third Edition Juval Lowy download

The document provides information about the book 'Programming WCF Services, Third Edition' by Juval Löwy, which covers essential concepts and techniques for building Windows Communication Foundation (WCF) services. It includes details on service contracts, data contracts, instance management, operations, faults, and transactions, among other topics. The book is published by O'Reilly Media and is available for download in various formats.

Uploaded by

nietomogilh0
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
14 views

Programming WCF Services Mastering WCF and the Azure AppFabric Service Bus Third Edition Juval Lowy download

The document provides information about the book 'Programming WCF Services, Third Edition' by Juval Löwy, which covers essential concepts and techniques for building Windows Communication Foundation (WCF) services. It includes details on service contracts, data contracts, instance management, operations, faults, and transactions, among other topics. The book is published by O'Reilly Media and is available for download in various formats.

Uploaded by

nietomogilh0
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 64

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/

Get Instant Ebook Downloads – Browse at https://ebookname.com


Instant digital products (PDF, ePub, MOBI) available
Download now and explore formats that suit you...

Programming NET 3 5 Build N Tier Applications with WPF


AJAX Silverlight LINQ WCF and More 1st Edition Jesse
Liberty

https://ebookname.com/product/programming-net-3-5-build-n-tier-
applications-with-wpf-ajax-silverlight-linq-wcf-and-more-1st-
edition-jesse-liberty/

COM and NET Component Services 1st Edition Juval Löwy

https://ebookname.com/product/com-and-net-component-services-1st-
edition-juval-lowy/

Pro WCF 4 Practical Microsoft SOA Implementation 2nd ed


2nd Edition Nishith Pathak

https://ebookname.com/product/pro-wcf-4-practical-microsoft-soa-
implementation-2nd-ed-2nd-edition-nishith-pathak/

All Rise Somebodies Nobodies and the Politics of


Dignity BK Currents Hardcover Robert W Fuller

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/

Ancestors of Worthy Life Plantation Slavery and Black


Heritage at Mount Clare 1st Edition Teresa S. Moyer

https://ebookname.com/product/ancestors-of-worthy-life-
plantation-slavery-and-black-heritage-at-mount-clare-1st-edition-
teresa-s-moyer/

Clojure for Finance 1st Edition Washington

https://ebookname.com/product/clojure-for-finance-1st-edition-
washington/

Instrumentation Theory and Applications 1st Edition


Satya Sheel

https://ebookname.com/product/instrumentation-theory-and-
applications-1st-edition-satya-sheel/

Intercultural Utopias Public Intellectuals Cultural


Experimentation and Ethnic Pluralism in Colombia 1st
Edition Joanne Rappaport

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

Download from Library of Wow! eBook <www.wowebook.com>


Download from Library of Wow! eBook <www.wowebook.com>
THIRD EDITION

Programming WCF Services

Juval Löwy

Beijing • Cambridge • Farnham • Köln • Sebastopol • Taipei • Tokyo

Download from Library of Wow! eBook <www.wowebook.com>


Programming WCF Services, Third Edition
by Juval Löwy

Copyright © 2010 Juval Löwy. All rights reserved.


Printed in the United States of America.

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

Download from Library of Wow! eBook <www.wowebook.com>


To my family

Download from Library of Wow! eBook <www.wowebook.com>


Download from Library of Wow! eBook <www.wowebook.com>
Table of Contents

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

Download from Library of Wow! eBook <www.wowebook.com>


Programmatic Endpoint Configuration 34
Default Endpoints 36
Metadata Exchange 39
Metadata over HTTP-GET 39
The Metadata Exchange Endpoint 42
The Metadata Explorer 49
More on Behavior Configuration 51
Client-Side Programming 53
Generating the Proxy 53
Administrative Client Configuration 57
Programmatic Client Configuration 64
The WCF-Provided Test Client 64
Programmatic Versus Administrative Configuration 67
WCF Architecture 67
Host Architecture 69
Working with Channels 70
The InProcFactory Class 71
Transport-Level Sessions 75
Transport Session and Binding 76
Transport Session Termination 76
Reliability 77
Bindings, Reliability, and Ordered Messages 78
Configuring Reliability 79
Requiring Ordered Delivery 80

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

3. Data Contracts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103


Serialization 103
.NET Serialization 105
The WCF Formatters 107
Data Contract via Serialization 110
Data Contract Attributes 111
Importing a Data Contract 113

viii | Table of Contents

Download from Library of Wow! eBook <www.wowebook.com>


Data Contracts and the Serializable Attribute 116
Inferred Data Contracts 117
Composite Data Contracts 118
Data Contract Events 119
Shared Data Contracts 123
Data Contract Hierarchy 123
Known Types 124
Service Known Types 126
Multiple Known Types 128
Configuring Known Types 129
Data Contract Resolvers 129
Objects and Interfaces 141
Data Contract Equivalence 143
Serialization Order 144
Versioning 146
New Members 146
Missing Members 147
Versioning Round-Trip 151
Enumerations 154
Delegates and Data Contracts 155
Generics 156
Collections 160
Concrete Collections 160
Custom Collections 162
The CollectionDataContract Attribute 163
Referencing a Collection 164
Dictionaries 165

4. Instance Management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169


Behaviors 169
Per-Call Services 171
Benefits of Per-Call Services 171
Configuring Per-Call Services 172
Per-Call Services and Transport Sessions 173
Designing Per-Call Services 174
Choosing Per-Call Services 177
Per-Session Services 177
Configuring Private Sessions 178
Sessions and Reliability 182
The Session ID 184
Session Termination 185
Singleton Service 185
Initializing a Singleton 187

Table of Contents | ix

Download from Library of Wow! eBook <www.wowebook.com>


Choosing a Singleton 189
Demarcating Operations 190
Instance Deactivation 193
Configuring with ReleaseInstanceMode.None 194
Configuring with ReleaseInstanceMode.BeforeCall 194
Configuring with ReleaseInstanceMode.AfterCall 195
Configuring with ReleaseInstanceMode.BeforeAndAfterCall 196
Explicit Deactivation 197
Using Instance Deactivation 198
Durable Services 198
Durable Services and Instance Management Modes 199
Instance IDs and Durable Storage 199
Explicit Instance IDs 201
Instance IDs in Headers 203
Context Bindings for Instance IDs 205
Automatic Durable Behavior 210
Throttling 217
Configuring Throttling 219

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

Download from Library of Wow! eBook <www.wowebook.com>


Channel Faulting 257
Fault Propagation 261
Fault Contracts 263
Fault Debugging 267
Faults and Callbacks 273
Error-Handling Extensions 276
Providing a Fault 277
Handling a Fault 280
Installing Error-Handling Extensions 282
The Host and Error Extensions 285
Callbacks and Error Extensions 289

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

Download from Library of Wow! eBook <www.wowebook.com>


Per-Call Transactional Services 345
Per-Session Transactional Services 348
Transactional Durable Services 362
Transactional Behavior 365
Transactional Singleton Service 371
Instancing Modes and Transactions 374
Callbacks 375
Callback Transaction Modes 376
Callback Voting 378
Using Transactional Callbacks 378

8. Concurrency Management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 383


Instance Management and Concurrency 383
Service Concurrency Modes 384
ConcurrencyMode.Single 384
ConcurrencyMode.Multiple 385
ConcurrencyMode.Reentrant 389
Instances and Concurrent Access 392
Per-Call Services 392
Sessionful and Singleton Services 393
Resources and Services 393
Deadlocked Access 394
Deadlock Avoidance 395
Resource Synchronization Context 396
.NET Synchronization Contexts 397
The UI Synchronization Context 400
Service Synchronization Context 405
Hosting on the UI Thread 406
A Form as a Service 412
The UI Thread and Concurrency Management 415
Custom Service Synchronization Contexts 417
The Thread Pool Synchronizer 418
Thread Affinity 423
Priority Processing 425
Callbacks and Client Safety 429
Callbacks with ConcurrencyMode.Single 429
Callbacks with ConcurrencyMode.Multiple 430
Callbacks with ConcurrencyMode.Reentrant 431
Callbacks and Synchronization Contexts 431
Callbacks and the UI Synchronization Context 432
Callback Custom Synchronization Contexts 435
Asynchronous Calls 439
Requirements for an Asynchronous Mechanism 439

xii | Table of Contents

Download from Library of Wow! eBook <www.wowebook.com>


Proxy-Based Asynchronous Calls 440
Asynchronous Invocation 442
Polling or Waiting for Completion 445
Completion Callbacks 447
One-Way Asynchronous Operations 452
Asynchronous Error Handling 456
Asynchronous Calls and Transactions 457
Synchronous Versus Asynchronous Calls 457

9. Queued Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 461


Disconnected Services and Clients 461
Queued Calls 462
Queued Calls Architecture 463
Queued Contracts 463
Configuration and Setup 464
Transactions 471
Delivery and Playback 471
Service Transaction Configuration 473
Nontransactional Queues 476
Instance Management 477
Per-Call Queued Services 478
Sessionful Queued Services 480
Singleton Service 483
Concurrency Management 484
Throttling 485
Delivery Failures 485
The Dead-Letter Queue 487
Time to Live 487
Configuring the Dead-Letter Queue 488
Processing the Dead-Letter Queue 490
Playback Failures 494
Poison Messages 495
Poison Message Handling in MSMQ 4.0 495
Poison Message Handling in MSMQ 3.0 501
Queued Versus Connected Calls 501
Requiring Queuing 502
The Response Service 504
Designing a Response Service Contract 505
Client-Side Programming 509
Queued Service-Side Programming 512
Response Service-Side Programming 514
Transactions 514
The HTTP Bridge 518

Table of Contents | xiii

Download from Library of Wow! eBook <www.wowebook.com>


Designing the Bridge 518
Transaction Configuration 519
Service-Side Configuration 520
Client-Side Configuration 522

10. Security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 525


Authentication 525
Authorization 526
Transfer Security 527
Transfer Security Modes 527
Transfer Security Mode Configuration 529
Transport Security and Credentials 532
Message Security and Credentials 533
Identity Management 533
Overall Policy 534
Scenario-Driven Approach 534
Intranet Application Scenario 535
Securing the Intranet Bindings 536
Constraining Message Protection 543
Authentication 544
Identities 547
The Security Call Context 548
Impersonation 550
Authorization 558
Identity Management 563
Callbacks 564
Internet Application Scenario 566
Securing the Internet Bindings 566
Message Protection 568
Authentication 572
Using Windows Credentials 574
Using the ASP.NET Providers 575
Identity Management 584
Business-to-Business Application Scenario 585
Securing the Business-to-Business Bindings 585
Authentication 586
Authorization 589
Identity Management 590
Host Security Configuration 591
Anonymous Application Scenario 591
Securing the Anonymous Bindings 591
Authentication 592
Authorization 592

xiv | Table of Contents

Download from Library of Wow! eBook <www.wowebook.com>


Identity Management 592
Callbacks 593
No Security Scenario 593
Unsecuring the Bindings 593
Authentication 594
Authorization 594
Identity Management 594
Callbacks 594
Scenarios Summary 595
Declarative Security Framework 595
The SecurityBehaviorAttribute 596
Host-Side Declarative Security 604
Client-Side Declarative Security 605
Security Auditing 612
Configuring Security Audits 613
Declarative Security Auditing 615

11. The Service Bus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 617


What Is a Relay Service? 618
The Windows Azure AppFabric Service Bus 619
Programming the Service Bus 620
Relay Service Address 620
The Service Bus Registry 623
The Service Bus Explorer 625
The Service Bus Bindings 626
The TCP Relay Binding 626
The WS 2007 Relay Binding 630
The One-Way Relay Binding 631
The Event Relay Binding 632
Cloud as Interceptor 633
Service Bus Buffers 634
Buffers Versus Queues 635
Working with Buffers 636
Sending and Retrieving Messages 642
Buffered Services 643
Response Service 652
Service Bus Authentication 657
Configuring Authentication 658
Shared Secret Authentication 659
No Authentication 663
Metadata over the Service Bus 665
Transfer Security 667
Transport Security 668

Table of Contents | xv

Download from Library of Wow! eBook <www.wowebook.com>


Message Security 669
TCP Relay Binding and Transfer Security 670
WS Relay Binding and Transfer Security 676
One-Way Relay Binding and Transfer Security 676
Bindings and Transfer Modes 677
Streamlining Transfer Security 678

A. Introduction to Service Orientation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 685

B. Headers and Contexts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 701

C. Discovery . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 723

D. Publish-Subscribe Service . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 775

E. Generic Interceptor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 809

F. WCF Coding Standard . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 825

G. ServiceModelEx Catalog . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 837

Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 855

xvi | Table of Contents

Download from Library of Wow! eBook <www.wowebook.com>


Foreword

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

Download from Library of Wow! eBook <www.wowebook.com>


As people providing a public web service infrastructure, we’re looking to provide
equally capable messaging-centric and REST protocol heads and resource projections
across the infrastructure. Because of concerns about broad reach into browsers and
devices, the prioritization often plays out in a way that the REST protocol heads for the
public protocol surface area win out and get built first—and mostly on top of the HTTP
web programming model provided by WCF. However, there has never been any serious
debate or question in cross-team engineering discussions about the interfaces between
the various subsystems under the waterline not being SOAP-based endpoints built on
WCF. Everyone already went into the room with the assumption that they would be.
Building the backbone systems for a cross-team effort at Microsoft with several hundred
engineers and an investment volume the size of the Windows Azure Platform is at or
beyond the complexity level of many mission-critical Enterprise systems. Running such
a system and upgrading or changing parts of such a system in flight and without down-
time is not only complex, it’s an art form. You need loose coupling between subsystems,
you need a lot of flexibility and extensibility, and you need to have a clear notion of
what that other system is going to accept and return in terms of messages. What I keep
finding is that once you confront a “simpler” communications model with real-world
requirements of the sort we’ve got on the Windows Azure backbone, you almost in-
evitably end up reinventing the wheel at the protocol level and you increasingly make
the life of implementers harder.
WCF is a great technology because it deals with the complexity of flexibly intercon-
necting applications. It’s great because you can build SOAP services, building the
backbone of your systems that can interoperate with other services on other platforms
with similarly capable web services stacks, such as those built by Oracle/Sun, IBM, or
the Apache Foundation. It’s great because it allows you to build the “broad-reach”
HTTP/REST resource projection surface of your system on the same foundation.
The book you have in your hands is rightfully “the book” about the Windows Com-
munication Foundation. Continuously improving our skills at architecting and build-
ing distributed business applications is a passion that Juval and I share.
This book is going to help you learn about the “distributed” part—how to hook stuff
together and how to do so securely, reliably, and in a loosely coupled fashion—all from
Juval Löwy, one of the most prominent distributed systems experts in the world today.

xviii | Foreword

Download from Library of Wow! eBook <www.wowebook.com>


Programming WCF Services shows you in great detail what we here at Microsoft have
built as a foundation for your applications and services, and the book conveys it with
the accuracy, teaching skill, and dedication to architecture that Juval is justly renowned
for around the globe.
I’ll stop now. Turn the page. Start reading.
—Clemens Vasters
Principal Technical Lead,Windows Azure AppFabric Service Bus, Microsoft

Foreword | xix

Download from Library of Wow! eBook <www.wowebook.com>


Download from Library of Wow! eBook <www.wowebook.com>
Preface

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

Download from Library of Wow! eBook <www.wowebook.com>


To me, WCF is the next development platform, which to a large extent subsumes
raw .NET programming. All .NET developers should use WCF, regardless of their
application types, sizes, or industry domains. WCF is a fundamental technology that
provides an easy and clean way to generate services and applications in compliance
with what I regard as sound design principles. WCF was engineered from the ground
up to simplify application development and deployment and to lower the overall cost
of ownership. WCF services allow you to build service-oriented applications, from
standalone desktop applications to web-based applications and services to high-end
Enterprise applications.

How This Book Is Organized


This book covers the topics and skills you need to design and develop service-oriented
WCF-based applications, illustrating how to take advantage of built-in features such
as service hosting, instance management, concurrency management, transactions, dis-
connected queued calls, security, and the Windows Azure AppFabric Service Bus.
While the book shows you how to use these features, it focuses on the “why” and on
the rationale behind particular design decisions. You’ll learn about not only WCF pro-
gramming and the related system issues, but also relevant design options, tips, best
practices, and pitfalls. I approach almost every topic and aspect from a software engi-
neering standpoint, because my objective is to make you not just a WCF expert, but
also a better software engineer. Armed with the insights this text provides, you can
engineer your applications for maintainability, extensibility, reusability, and
productivity.
This third edition has provided me with several opportunities: first, to catch up with
WCF in .NET 4.0 with its new features such as hosting, discovery, and configuration.
Second, I wanted to present the AppFabric Service Bus, which is a fundamentally dis-
ruptive technology because of the sort of applications it allows developers to build.
Third, I have had two more years’ worth of WCF techniques, ideas, and helper classes,
as well as improvement of the ideas I had in the first and second editions. I believe this
new material will make this edition valuable even to readers of the second edition.
This book avoids many implementation details of WCF and largely confines its cov-
erage to the possibilities and practical aspects of using WCF: how to apply the tech-
nology and how to choose among the available design and programming models. It
makes the most of what .NET 4.0 and the service bus has to offer, and in some respects
is an advanced C# book as well.
In addition, the book contains many useful utilities, tools, and helper classes I have
written, collectively known as ServiceModelEx. My tools, helper classes, and attributes
aim at increasing your productivity and the quality of your WCF services. Serv-
iceModelEx is literally a small framework that sits on top of WCF and compensates for
some oversights in its design. ServiceModelEx also simplifies and automates certain
tasks. This book is as much about my tools, ideas, and techniques as it is about native

xxii | Preface

Download from Library of Wow! eBook <www.wowebook.com>


WCF, and my framework also demonstrates how you can extend WCF. Many readers
have told me that aside from the explanations in this book, ServiceModelEx is the most
valuable asset the book offers. I have also kept to my guideline that, in principle, readers
should not have to use all (or any part) of ServiceModelEx. In practice,
ServiceModelEx is your WCF power tools collection. You can also use each helper class,
utility, or framework individually, as there are few, if any, interdependencies.
During the past six years, I have published a number of WCF articles in MSDN Mag-
azine, and I wrote the WCF section of the “Foundations” column for the magazine as
well. I used these articles to seed the chapters in this book, and I am grateful to the
magazine for allowing me to do so. Even if you have read the articles, you should still
read the corresponding chapters here. The chapters are much more comprehensive, are
wider in scope (offering additional angles, techniques, and samples) and up to date,
and often tie their subjects into other chapters.
Each chapter addresses a single topic and discusses it in depth. However, the chapters
often rely on those that precede them, so you should read the book in order.
Here is a brief summary of the chapters and appendixes in this book:
Chapter 1, WCF Essentials
This first chapter starts by explaining what WCF is, then describes essential WCF
concepts and building blocks (such as addresses, contracts, bindings, endpoints,
hosting, and clients) and key concepts such as reliability and transport sessions.
The chapter includes a discussion of the WCF architecture, which is really the
linchpin of all that follows in the subsequent chapters. This chapter assumes that
you understand the basic motivation and benefit of service orientation. If that is
not the case, you should first read Appendix A. Even if you are already familiar
with the basic concepts of WCF, I recommend that you give this chapter at least a
cursory reading, not only to ensure that you have a solid foundation, but also
because some of the helper classes and terms introduced here will be used and
extended throughout the book.
Chapter 2, Service Contracts
Chapter 2 is dedicated to the topic of designing and working with service contracts.
First, it covers some useful techniques for service contract overloading and inher-
itance, as well as some advanced techniques. The chapter also discusses how to
design and factor contracts that cater to reuse, maintainability, and extensibility.
It ends by showing you how to interact programmatically with the metadata of the
exposed contracts at runtime.
Chapter 3, Data Contracts
Chapter 3 deals with how the client and the service can exchange data without ever
actually sharing the data type itself or using the same development technology. In
this chapter, you will see how to deal with some interesting real-life issues, such as
data versioning, and how to pass collections of items.

Preface | xxiii

Download from Library of Wow! eBook <www.wowebook.com>


Exploring the Variety of Random
Documents with Different Content
Cæsar made arrangements for a series of festivals and celebrations,
to commemorate and confirm the re-establishment of a good
understanding between the king and the queen, and the consequent
termination of the war. Such celebrations, he judged, would have
great influence in removing any remaining animosities from the
minds of the people, and restore the dominion of a kind and friendly
feeling throughout the city. The people fell in with these measures,
and cordially co-operated to give them effect; but Pothinus and
Achillas, though they suppressed all outward expressions of
discontent, made incessant efforts in secret to organize a party, and
to form plans for overthrowing the influence of Cæsar, and making
Ptolemy again the sole and exclusive sovereign.
Pothinus represented to all whom he could induce to listen to him
that Cæsar’s real design was to make Cleopatra queen alone, and to
depose Ptolemy, and urged them to combine with him to resist a
policy which would end in bringing Egypt under the dominion of a
woman. He also formed a plan, in connection with Achillas, for
ordering the army back from Pelusium. The army consisted of thirty
thousand men. If that army could be brought to Alexandria and kept
under Pothinus’s orders, Cæsar and his three thousand Roman
soldiers would be, they thought, wholly at their mercy.
There was, however, one danger to be guarded against in ordering
the army to march toward the capital, and that was, that Ptolemy,
while under Cæsar’s influence, might open communications with the
officers, and so obtain command of its movements, and thwart all
the conspirators’ designs. To prevent this, it was arranged between
Pothinus and Achillas that the latter should make his escape from
Alexandria, proceed immediately to the camp at Pelusium, resume
the command of the troops there, and conduct them himself to the
capital; and that in all these operations, and also subsequently on
his arrival, he should obey no orders unless they came to him
through Pothinus himself.
Although sentinels and guards were probably stationed at the gates
and avenues leading from the city, Achillas contrived to effect his
escape and to join the army. He placed himself at the head of the
forces, and commenced his march toward the capital. Pothinus
remained all the time within the city as a spy, pretending to
acquiesce in Cæsar’s decision, and to be on friendly terms with him,
but really plotting for his overthrow, and obtaining all the
information which his position enabled him to command, in order
that he might co-operate with the army and Achillas when they
should arrive.
All these things were done with the utmost secrecy, and so cunning
and adroit were the conspirators in forming and executing their
plots, that Cæsar seems to have had no knowledge of the measures
which his enemies were taking, until he suddenly heard that the
main body of Ptolemy’s army was approaching the city, at least
twenty thousand strong. In the mean time, however, the forces
which he had sent for from Syria had not arrived, and no alternative
was left but to defend the capital and himself as well as he could
with the very small force which he had at his disposal.
He determined, however, first, to try the effect of orders sent out in
Ptolemy’s name to forbid the approach of the army to the city. Two
officers were accordingly intrusted with these orders, and sent out to
communicate them to Achillas. The names of these officers were
Dioscorides and Serapion.
It shows in a very striking point of view to what an incredible
exaltation the authority and consequence of a sovereign king rose in
those ancient days, in the minds of men, that Achillas, at the
moment when these men made their appearance in the camp,
bearing evidently some command from Ptolemy in the city,
considered it more prudent to kill them at once, without hearing
their message, rather than to allow the orders to be delivered and
then take the responsibility of disobeying them. If he could succeed
in marching to Alexandria and in taking possession of the city, and
then in expelling Cæsar and Cleopatra and restoring Ptolemy to the
exclusive possession of the throne, he knew very well that the king
would rejoice in the result, and would overlook all irregularities on
his part in the means by which he had accomplished it, short of
absolute disobedience of a known command. Whatever might be the
commands that these messengers were bringing him, he supposed
that they doubtless originated, not in Ptolemy’s own free will, but
that they were dictated by the authority of Cæsar. Still, they would
be commands coming in Ptolemy’s name; and the universal
experience of officers serving under the military despots of those
ancient days showed that, rather than to take the responsibility of
directly disobeying a royal order once received, it was safer to avoid
receiving it by murdering the messengers.
Achillas therefore directed the officers to be seized and slain. They
were accordingly taken off and speared by the soldiers, and then the
bodies were borne away. The soldiers, however, it was found, had
not done their work effectually. There was no interest for them in
such a cold-blooded assassination, and perhaps something like a
sentiment of compassion restrained their hands. At any rate, though
both the men were desperately wounded, one only died. The other
lived and recovered.
Achillas continued to advance toward the city. Cæsar, finding that
the crisis which was approaching was becoming very serious in its
character, took, himself, the whole command within the capital, and
began to make the best arrangements possible under the
circumstances of the case to defend himself there. His numbers
were altogether too small to defend the whole city against the
overwhelming force which was advancing to assail it. He accordingly
intrenched his troops in the palaces and in the citadel, and in such
other parts of the city as it seemed practicable to defend. He
barricaded all the streets and avenues leading to these points, and
fortified the gates. Nor did he, while thus doing all in his power to
employ the insufficient means of defense already in his hands to the
best advantage, neglect the proper exertions for obtaining succor
from abroad. He sent off galleys to Syria, to Cyprus, to Rhodes, and
to every other point accessible from Alexandria where Roman troops
might be expected to be found, urging the authorities there to
forward re-enforcements to him with the utmost possible dispatch.
During all this time Cleopatra and Ptolemy remained in the palace
with Cæsar, both ostensibly co-operating with him in his councils and
measures for defending the city from Achillas. Cleopatra, of course,
was sincere and in earnest in this co-operation; but Ptolemy’s
adhesion to the common cause was very little to be relied upon.
Although, situated as he was, he was compelled to seem to be on
Cæsar’s side, he must have secretly desired that Achillas should
succeed and Cæsar’s plans be overthrown. Pothinus was more
active, though not less cautious in his hostility to them. He opened a
secret communication with Achillas, sending him information, from
time to time, of what took place within the walls, and of the
arrangements made there for the defense of the city against him,
and gave him also directions how to proceed. He was very wary and
sagacious in all these movements, feigning all the time to be on
Cæsar’s side. He pretended to be very zealously employed in aiding
Cæsar to secure more effectually the various points where attacks
were to be expected, and in maturing and completing the
arrangements for defense.
But, notwithstanding all his cunning, he was detected in his double
dealing, and his career was suddenly brought to a close, before the
great final conflict came on. There was a barber in Cæsar’s
household, who, for some cause or other, began to suspect
Pothinus; and, having little else to do, he employed himself in
watching the eunuch’s movements and reporting them to Cæsar.
Cæsar directed the barber to continue his observations. He did so;
his suspicions were soon confirmed, and at length a letter, which
Pothinus had written to Achillas, was intercepted and brought to
Cæsar. This furnished the necessary proof of what they called his
guilt, and Cæsar ordered him to be beheaded.
This circumstance produced, of course, a great excitement within
the palace, for Pothinus had been for many years the great ruling
minister of state—the king, in fact, in all but in name. His execution
alarmed a great many others, who, though in Cæsar’s power, were
secretly wishing that Achillas might prevail. Among those most
disturbed by these fears was a man named Ganymede. He was the
officer who had charge of Arsinoë, Cleopatra’s sister. The
arrangement which Cæsar had proposed for establishing her in
conjunction with her brother Ptolemy over the island of Cyprus had
not gone into effect; for, immediately after the decision of Cæsar, the
attention of all concerned had been wholly engrossed by the tidings
of the advance of the army, and by the busy preparations which
were required on all hands for the impending contest. Arsinoë,
therefore, with her governor Ganymede, remained in the palace.
Ganymede had joined Pothinus in his plots; and when Pothinus was
beheaded, he concluded that it would be safest for him to fly.
He accordingly resolved to make his escape from the city, taking
Arsinoë with him. It was a very hazardous attempt, but he
succeeded in accomplishing it. Arsinoë was very willing to go, for she
was now beginning to be old enough to feel the impulse of that
insatiable and reckless ambition which seemed to form such an
essential element in the character of every son and daughter in the
whole Ptolemaic line. She was insignificant and powerless where she
was, but at the head of the army she might become immediately a
queen.
It resulted, in the first instance, as she had anticipated. Achillas and
his army received her with acclamations. Under Ganymede’s
influence they decided that, as all the other members of the royal
family were in durance, being held captive by a foreign general, who
had by chance obtained possession of the capital, and were thus
incapacitated for exercising the royal power, the crown devolved
upon Arsinoë; and they accordingly proclaimed her queen.
Every thing was now prepared for a desperate and determined
contest for the crown between Cleopatra, with Cæsar for her
minister and general, on the one side, and Arsinoë, with Ganymede
and Achillas for her chief officers, on the other. The young Ptolemy,
in the mean time, remained Cæsar’s prisoner, confused with the
intricacies in which the quarrel had become involved, and scarcely
knowing now what to wish in respect to the issue of the contest. It
was very difficult to foresee whether it would be best for him that
Cleopatra or that Arsinoë should succeed.
Chapter VII.

The Alexandrine War.

T HE war which ensued as the result of the intrigues and


maneuvers described in the last chapter is known in the history
of Rome and Julius Cæsar as the Alexandrine war. The events which
occurred during the progress of it, and its termination at last in the
triumph of Cæsar and Cleopatra, will form the subject of this
chapter.
Achillas had greatly the advantage over Cæsar at the outset of the
contest, in respect to the strength of the forces under his command.
Cæsar, in fact, had with him only a detachment of three or four
thousand men, a small body of troops which he had hastily put on
board a little squadron of Rhodian galleys for pursuing Pompey
across the Mediterranean. When he set sail from the European
shores with this inconsiderable fleet, it is probable that he had no
expectation even of landing in Egypt at all, and much less of being
involved in great military undertakings there. Achillas, on the other
hand, was at the head of a force of twenty thousand effective men.
His troops were, it is true, of a somewhat miscellaneous character,
but they were all veteran soldiers, inured to the climate of Egypt,
and skilled in all the modes of warfare which were suited to the
character of the country. Some of them were Roman soldiers, men
who had come with the army of Mark Antony from Syria when
Ptolemy Auletes, Cleopatra’s father, was reinstated on the throne,
and had been left in Egypt, in Ptolemy’s service, when Antony
returned to Rome. Some were native Egyptians. There was also in
the army of Achillas a large number of fugitive slaves—refugees who
had made their escape from various points along the shores of the
Mediterranean, at different periods, and had been from time to time
incorporated into the Egyptian army. These fugitives were all men of
the most determined and desperate character.
Achillas had also in his command a force of two thousand horse.
Such a body of cavalry made him, of course, perfect master of all
the open country outside the city walls. At the head of these troops
Achillas gradually advanced to the very gates of Alexandria, invested
the city on every side, and shut Cæsar closely in.
The danger of the situation in which Cæsar was placed was
extreme; but he had been so accustomed to succeed in extricating
himself from the most imminent perils, that neither he himself nor
his army seem to have experienced any concern in respect to the
result. Cæsar personally felt a special pride and pleasure in
encountering the difficulties and dangers which now beset him,
because Cleopatra was with him to witness his demeanor, to admire
his energy and courage, and to reward by her love the efforts and
sacrifices which he was making in espousing her cause. She confided
every thing to him, but she watched all the proceedings with the
most eager interest, elated with hope in respect to the result, and
proud of the champion who had thus volunteered to defend her. In a
word, her heart was full of gratitude, admiration, and love.
The immediate effect, too, of the emotions which she felt so strongly
was greatly to heighten her natural charms. The native force and
energy of her character were softened and subdued. Her voice,
which always possessed a certain inexpressible charm, was endued
with new sweetness through the influence of affection. Her
countenance beamed with fresh animation and beauty, and the
sprightliness and vivacity of her character, which became at later
periods of her life boldness and eccentricity, now being softened and
restrained within proper limits by the respectful regard with which
she looked upon Cæsar, made her an enchanting companion. Cæsar
was, in fact, entirely intoxicated with the fascinations which she
unconsciously displayed.
Under other circumstances than these, a personal attachment so
strong, formed by a military commander while engaged in active
service, might have been expected to interfere in some degree with
the discharge of his duties; but in this case, since it was for
Cleopatra’s sake and in her behalf that the operations which Cæsar
had undertaken were to be prosecuted, his love for her only
stimulated the spirit and energy with which he engaged in them.
The first measure to be adopted was, as Cæsar plainly perceived, to
concentrate and strengthen his position in the city, so that he might
be able to defend himself there against Achillas until he should
receive re-enforcements from abroad. For this purpose he selected a
certain group of palaces and citadels which lay together near the
head of the long pier or causeway which led to the Pharos, and,
withdrawing his troops from all other parts of the city, established
them there. The quarter which he thus occupied contained the great
city arsenals and public granaries. Cæsar brought together all the
arms and munitions of war which he could find in other parts of the
city, and also all the corn and other provisions which were contained
either in the public depôts or in private warehouses, and stored the
whole within his lines. He then inclosed the whole quarter with
strong defenses. The avenues leading to it were barricaded with
walls of stone. Houses in the vicinity which might have afforded
shelter to an enemy were demolished, and the materials used in
constructing walls wherever they were needed, or in strengthening
the barricades. Prodigious military engines, made to throw heavy
stones, and beams of wood, and other ponderous missiles, were set
up within his lines, and openings were made in the walls and other
defenses of the citadel, wherever necessary, to facilitate the action
of these machines.
View of Alexandria.

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.

T HE war by which Cæsar reinstated Cleopatra upon the throne


was not one of very long duration. Cæsar arrived in Egypt in
pursuit of Pompey about the 1st of August; the war was ended and
Cleopatra established in secure possession by the end of January; so
that the conflict, violent as it was while it continued, was very brief,
the peaceful and commercial pursuits of the Alexandrians having
been interrupted by it only for a few months.
Nor did either the war itself, or the derangements consequent upon
it, extend very far into the interior of the country. The city of
Alexandria itself and the neighboring coasts were the chief scenes of
the contest until Mithradates arrived at Pelusium. He, it is true,
marched across the Delta, and the final battle was fought in the
interior of the country. It was, however, after all, but a very small
portion of the Egyptian territory that was directly affected by the
war. The great mass of the people, occupying the rich and fertile
tracts which bordered the various branches of the Nile, and the long
and verdant valley which extended so far into the heart of the
continent, knew nothing of the conflict but by vague and distant
rumors. The pursuits of the agricultural population went on, all the
time, as steadily and prosperously as ever; so that when the conflict
was ended, and Cleopatra entered upon the quiet and peaceful
possession of her power, she found that the resources of her empire
were very little impaired.
She availed herself, accordingly, of the revenues which poured in
very abundantly upon her, to enter upon a career of the greatest
luxury, magnificence, and splendor. The injuries which had been
done to the palaces and other public edifices of Alexandria by the
fire, and by the military operations of the siege, were repaired. The
bridges which had been broken down were rebuilt. The canals which
had been obstructed were opened again. The sea-water was shut off
from the palace cisterns; the rubbish of demolished houses was
removed; the barricades were cleared from the streets; and the
injuries which the palaces had suffered, either from the violence of
military engines or the rough occupation of the Roman soldiery, were
repaired. In a word, the city was speedily restored once more, so far
as was possible, to its former order and beauty. The five hundred
thousand manuscripts of the Alexandrian library, which had been
burned, could not, indeed, be restored; but, in all other respects, the
city soon resumed in appearance all its former splendor. Even in
respect to the library, Cleopatra made an effort to retrieve the loss.
She repaired the ruined buildings, and afterward, in the course of
her life, she brought together, it was said, in a manner hereafter to
be described, one or two hundred thousand rolls of manuscripts, as
the commencement of a new collection. The new library, however,
never acquired the fame and distinction that had pertained to the
old.
The former sovereigns of Egypt, Cleopatra’s ancestors, had
generally, as has already been shown, devoted the immense
revenues which they extorted from the agriculturalists of the valley
of the Nile to purposes of ambition. Cleopatra seemed now disposed
to expend them in luxury and pleasure. They, the Ptolemies, had
employed their resources in erecting vast structures, or founding
magnificent institutions at Alexandria, to add to the glory of the city,
and to widen and extend their own fame. Cleopatra, on the other
hand, as was, perhaps, naturally to be expected of a young,
beautiful, and impulsive woman, suddenly raised to so conspicuous a
position, and to the possession of such unbounded wealth and
power, expended her royal revenues in plans of personal display, and
in scenes of festivity, gayety, and enjoyment. She adorned her
palaces, built magnificent barges for pleasure excursions on the Nile,
and expended enormous sums for dress, for equipages, and for
sumptuous entertainments. In fact, so lavish were her expenditures
for these and similar purposes during the early years of her reign,
that she is considered as having carried the extravagance of sensual
luxury and personal display and splendor beyond the limits that had
ever before or have ever since been attained.
Whatever of simplicity of character, and of gentleness and kindness
of spirit she might have possessed in her earlier years, of course
gradually disappeared under the influences of such a course of life
as she now was leading. She was beautiful and fascinating still, but
she began to grow selfish, heartless, and designing. Her little
brother—he was but eleven years of age, it will be recollected, when
Cæsar arranged the marriage between them—was an object of
jealousy to her. He was now, of course, too young to take any actual
share in the exercise of the royal power, or to interfere at all in his
sister’s plans or pleasures. But then he was growing older. In a few
years he would be fifteen—which was the period of life fixed upon
by Cæsar’s arrangements, and, in fact, by the laws and usages of
the Egyptian kingdom—when he was to come into possession of
power as king, and as the husband of Cleopatra. Cleopatra was
extremely unwilling that the change in her relations to him and to
the government, which this period was to bring, should take place.
Accordingly, just before the time arrived, she caused him to be
poisoned. His death released her, as she had intended, from all
restraints, and thereafter she continued to reign alone. During the
remainder of her life, so far as the enjoyment of wealth and power,
and of all other elements of external prosperity could go, Cleopatra’s
career was one of uninterrupted success. She had no conscientious
scruples to interfere with the most full and unrestrained indulgence
of every propensity of her heart, and the means of indulgence were
before her in the most unlimited profusion. The only bar to her
happiness was the impossibility of satisfying the impulses and
passions of the human soul, when they once break over the bounds
which the laws both of God and of nature ordain for restraining
them.
In the mean time, while Cleopatra was spending the early years of
her reign in all this luxury and splendor, Cæsar was pursuing his
career, as the conqueror of the world, in the most successful
manner. On the death of Pompey, he would naturally have
succeeded at once to the enjoyment of the supreme power; but his
delay in Egypt, and the extent to which it was known that he was
entangled with Cleopatra, encouraged and strengthened his enemies
in various parts of the world. In fact, a revolt which broke out in Asia
Minor, and which it was absolutely necessary that he should proceed
at once to quell, was the immediate cause of his leaving Egypt at
last. Other plans for making head against Cæsar’s power were
formed in Spain, in Africa, and in Italy. His military skill and energy,
however, were so great, and the ascendency which he exercised
over the minds of men by his personal presence was so unbounded,
and so astonishing, moreover, was the celerity with which he moved
from continent to continent, and from kingdom to kingdom, that in a
very short period from the time of his leaving Egypt, he had
conducted most brilliant and successful campaigns in all the three
quarters of the world then known, had put down effectually all
opposition to his power, and then had returned to Rome the
acknowledged master of the world. Cleopatra, who had, of course,
watched his career during all this time with great pride and pleasure,
concluded, at last, to go to Rome and make a visit to him there.
The people of Rome were, however, not prepared to receive her very
cordially. It was an age in which vice of every kind was regarded
with great indulgence, but the moral instincts of mankind were too
strong to be wholly blinded to the true character of so conspicuous
an example of wickedness as this. Arsinoë was at Rome, too, during
this period of Cæsar’s life. He had brought her there, it will be
recollected, on his return from Egypt, as a prisoner, and as a trophy
of his victory. His design was, in fact, to reserve her as a captive to
grace his triumph.
A triumph, according to the usages of the ancient Romans, was a
grand celebration decreed by the senate to great military
commanders of the highest rank, when they returned from distant
campaigns in which they had made great conquests or gained
extraordinary victories. Cæsar concentrated all his triumphs into one.
They were celebrated on his return to Rome for the last time, after
having completed the conquest of the world. The processions of this
triumph occupied four days. In fact, there were four triumphs, one
on each day for the four days. The wars and conquests which these
ovations were intended to celebrate were those of Gaul, of Egypt, of
Asia, and of Africa; and the processions on the several days
consisted of endless trains of prisoners, trophies, arms, banners,
pictures, images, convoys of wagons loaded with plunder, captive
princes and princesses, animals, wild and tame, and every thing else
which the conqueror had been able to bring home with him from his
campaigns, to excite the curiosity or the admiration of the people of
the city, and illustrate the magnitude of his exploits. Of course, the
Roman generals, when engaged in distant foreign wars, were
ambitious of bringing back as many distinguished captives and as
much public plunder as they were able to obtain, in order to add to
the variety and splendor of the triumphal procession by which their
victories were to be honored on their return. It was with this view
that Cæsar brought Arsinoë from Egypt; and he had retained her as
his captive at Rome until his conquests were completed and the time
for his triumph arrived. She, of course, formed a part of the
triumphal train on the Egyptian day. She walked immediately before
the chariot in which Cæsar rode. She was in chains, like any other
captive, though her chains, in honor of her lofty rank, were made of
gold.
Cleopatra’s Sister in the triumphal Procession.

The effect, however, upon the Roman population of seeing the


unhappy princess, overwhelmed as she was with sorrow and
chagrin, as she moved slowly along in the train, among the other
emblems and trophies of violence and plunder, proved to be by no
means favorable to Cæsar. The populace were inclined to pity her,
and to sympathize with her in her sufferings. The sight of her
distress recalled, too, to their minds the dereliction from duty of
which Cæsar had been guilty of in his yielding to the enticements of
Cleopatra, and remaining so long in Egypt to the neglect of his
proper duties as a Roman minister of state. In a word, the tide of
admiration for Cæsar’s military exploits which had been setting so
strongly in his favor, seemed inclined to turn, and the city was filled
with murmurs against him even in the midst of his triumphs.
In fact, the pride and vainglory which led Cæsar to make his
triumphs more splendid and imposing than any former conqueror
had ever enjoyed, caused him to overact his part so as to produce
effects the reverse of his intentions. The case of Arsinoë was one
example of this. Instead of impressing the people with a sense of
the greatness of his exploits in Egypt, in deposing one queen and
bringing her captive to Rome, in order that he might place another
upon the throne in her stead, it only reproduced anew the censures
and criminations which he had deserved by his actions there, but
which, had it not been for the pitiable spectacle of Arsinoë in the
train, might have been forgotten.
There were other examples of a similar character. There were the
feasts, for instance. From the plunder which Cæsar had obtained in
his various campaigns, he expended the most enormous sums in
making feasts and spectacles for the populace at the time of his
triumph. A large portion of the populace was pleased, it is true, with
the boundless indulgences thus offered to them; but the better part
of the Roman people were indignant at the waste and extravagance
which were every where displayed. For many days the whole city of
Rome presented to the view nothing but one wide-spread scene of
riot and debauchery. The people, instead of being pleased with this
abundance, said that Cæsar must have practiced the most extreme
and lawless extortion to have obtained the vast amount of money
necessary to enable him to supply such unbounded and reckless
waste.
There was another way, too, by which Cæsar turned public opinion
strongly against himself, by the very means which he adopted for
creating a sentiment in his favor. The Romans, among the other
barbarous amusements which were practiced in the city, were
specially fond of combats. These combats were of various kinds.
They were fought sometimes between ferocious beasts of the same
or of different species, as dogs against each other, or against bulls,
lions, or tigers. Any animals, in fact, were employed for this purpose,
that could be teased or goaded into anger and ferocity in a fight.
Sometimes men were employed in these combats—captive soldiers,
that had been taken in war, and brought to Rome to fight in the
amphitheaters there as gladiators. These men were compelled to
contend sometimes with wild beasts, and sometimes with one
another. Cæsar, knowing how highly the Roman assemblies enjoyed
such scenes, determined to afford them the indulgence on a most
magnificent scale, supposing, of course, that the greater and the
more dreadful the fight, the higher would be the pleasure which the
spectators would enjoy in witnessing it. Accordingly, in making
preparations for the festivities attending his triumph, he caused a
large artificial lake to be formed at a convenient place in the vicinity
of Rome, where it could be surrounded by the populace of the city,
and there he made arrangements for a naval battle. A great number
of galleys were introduced into the lake. They were of the usual size
employed in war. These galleys were manned with numerous
soldiers. Tyrian captives were put upon one side, and Egyptian upon
the other; and when all was ready, the two squadrons were ordered
to approach and fight a real naval battle for the amusement of the
enormous throngs of spectators that were assembled around. As the
nations from which the combatants in this conflict were respectively
taken were hostile to each other, and as the men fought, of course,
for their lives, the engagement was attended with the usual horrors
of a desperate naval encounter. Hundreds were slain. The dead
bodies of the combatants fell from the galleys into the lake, and the
waters of it were dyed with their blood.
There were land combats, too, on the same grand scale. In one of
them five hundred foot soldiers, twenty elephants, and a troop of
thirty horse were engaged on each side. This combat, therefore, was
an action greater, in respect to the number of the combatants, than
the famous battle of Lexington, which marked the commencement of
the American war; and in respect to the slaughter which took place,
it was very probably ten times greater. The horror of these scenes
proved to be too much even for the populace, fierce and merciless
as it was, which they were intended to amuse. Cæsar, in his
eagerness to outdo all former exhibitions and shows, went beyond
the limits within which the seeing of men butchered in bloody
combats and dying in agony and despair would serve for a pleasure
and a pastime. The people were shocked; and condemnations of
Cæsar’s cruelty were added to the other suppressed reproaches and
criminations which every where arose.
Cleopatra, during her visit to Rome, lived openly with Cæsar at his
residence, and this excited very general displeasure. In fact, while
the people pitied Arsinoë, Cleopatra, notwithstanding her beauty and
her thousand personal accomplishments and charms, was an object
of general displeasure, so far as public attention was turned toward
her at all. The public mind was, however, much engrossed by the
great political movements made by Cæsar and the ends toward
which he seemed to be aiming. Men accused him of designing to be
made a king. Parties were formed for and against him; and though
men did not dare openly to utter their sentiments, their passions
became the more violent in proportion to the external force by which
they were suppressed. Mark Antony was at Rome at this time. He
warmly espoused Cæsar’s cause, and encouraged his design of
making himself king. He once, in fact, offered to place a royal
diadem upon Cæsar’s head at some public celebration; but the
marks of public disapprobation which the act elicited caused him to
desist.
At length, however, the time arrived when Cæsar determined to
cause himself to be proclaimed king. He took advantage of a certain
remarkable conjuncture of public affairs, which can not here be
particularly described, but which seemed to him specially to favor his
designs, and arrangements were made for having him invested with
the regal power by the senate. The murmurs and the discontent of
the people at the indications that the time for the realization of their
fears was drawing nigh, became more and more audible, and at
length a conspiracy was formed to put an end to the danger by
destroying the ambitious aspirant’s life. Two stern and determined
men, Brutus and Cassius, were the leaders of this conspiracy. They
matured their plans, organized their band of associates, provided
themselves secretly with arms, and when the senate convened, on
the day in which the decisive vote was to have been passed, Cæsar
himself presiding, they came up boldly around him in his presidential
chair, and murdered him with their daggers.
Antony, from whom the plans of the conspirators had been kept
profoundly secret, stood by, looking on stupefied and confounded
while the deed was done, but utterly unable to render his friend any
protection.
Cleopatra immediately fled from the city and returned to Egypt.
Arsinoë had gone away before. Cæsar, either taking pity on her
misfortunes, or impelled, perhaps, by the force of public sentiment,
which seemed inclined to take part with her against him, set her at
liberty immediately after the ceremonies of his triumph were over.
He would not, however, allow her to return into Egypt, for fear,
probably, that she might in some way or other be the means of
disturbing the government of Cleopatra. She proceeded, accordingly,
into Syria, no longer as a captive, but still as an exile from her native
land. We shall hereafter learn what became of her there.
Calpurnia mourned the death of her husband with sincere and
unaffected grief. She bore the wrongs which she suffered as a wife
with a very patient and unrepining spirit, and loved her husband
with the most devoted attachment to the end. Nothing can be more
affecting than the proofs of her tender and anxious regard on the
night immediately preceding the assassination. There were certain
slight and obscure indications of danger which her watchful devotion
to her husband led her to observe, though they eluded the notice of
all Cæsar’s other friends, and they filled her with apprehension and
anxiety; and when at length the bloody body was brought home to
her from the senate-house, she was overwhelmed with grief and
despair.
She had no children. She accordingly looked upon Mark Antony as
her nearest friend and protector, and in the confusion and terror
which prevailed the next day in the city, she hastily packed together
the money and other valuables contained in the house, and all her
husband’s books and papers, and sent them to Antony for safe
keeping.
Chapter IX.

The Battle of Philippi.

W HEN the tidings of the assassination of Cæsar were first


announced to the people of Rome, all ranks and classes of men
were struck with amazement and consternation. No one knew what
to say or do. A very large and influential portion of the community
had been Cæsar’s friends. It was equally certain that there was a
very powerful interest opposed to him. No one could foresee which
of these two parties would now carry the day, and, of course, for a
time, all was uncertainty and indecision.
Mark Antony came forward at once, and assumed the position of
Cæsar’s representative and the leader of the party on that side. A
will was found among Cæsar’s effects, and when the will was
opened it appeared that large sums of money were left to the
Roman people, and other large amounts to a nephew of the
deceased, named Octavius, who will be more particularly spoken of
hereafter. Antony was named in the will as the executor of it. This
and other circumstances seemed to authorize him to come forward
as the head and the leader of the Cæsar party. Brutus and Cassius,
who remained openly in the city after their desperate deed had been
performed, were the acknowledged leaders of the other party; while
the mass of the people were at first so astounded at the magnitude
and suddenness of the revolution which the open and public
assassination of a Roman emperor by a Roman senate denoted, that
they knew not what to say or do. In fact, the killing of Julius Cæsar,
considering the exalted position which he occupied, the rank and
station of the men who perpetrated the deed, and the very
extraordinary publicity of the scene in which the act was performed,
was, doubtless, the most conspicuous and most appalling case of
assassination that has ever occurred. The whole population of Rome
seemed for some days to be amazed and stupefied by the tidings. At
length, however, parties began to be more distinctly formed. The
lines of demarkation between them were gradually drawn, and men
began to arrange themselves more and more unequivocally on the
opposite sides.
For a short time the supremacy of Antony over the Cæsar party was
readily acquiesced in and allowed. At length, however, and before his
arrangements were finally matured, he found that he had two
formidable competitors upon his own side. These were Octavius and
Lepidus.
Octavius, who was the nephew of Cæsar, already alluded to, was a
very accomplished and elegant young man, now about nineteen
years of age. He was the son of Julius Cæsar’s niece.[6] He had
always been a great favorite with his uncle. Every possible attention
had been paid to his education, and he had been advanced by
Cæsar, already, to positions of high importance in public life. Cæsar,
in fact, adopted him as his son, and made him his heir. At the time
of Cæsar’s death he was at Apollonia, a city of Illyricum, north of
Greece. The troops under his command there offered to march at
once with him, if he wished it, to Rome, and avenge his uncle’s
death. Octavius, after some hesitation, concluded that it would be
most prudent for him to proceed thither first himself, alone, as a
private person, and demand his rights as his uncle’s heir, according
to the provisions of the will. He accordingly did so. He found, on his
arrival, that the will, the property, the books and parchments, and
the substantial power of the government, were all in Antony’s hands.
Antony, instead of putting Octavius into possession of his property
and rights, found various pretexts for evasion and delay. Octavius
was too young yet, he said, to assume such weighty responsibilities.
He was himself also too much pressed with the urgency of public
affairs to attend to the business of the will. With these and similar
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!

ebookname.com

You might also like