Book Image

Learning NServiceBus - Second Edition

By : David Boike
Book Image

Learning NServiceBus - Second Edition

By: David Boike

Overview of this book

Table of Contents (18 chapters)
Learning NServiceBus Second Edition
Credits
Foreword
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Exposing web services


Shocking as it may sound, not every computer on the planet runs Windows and the .NET Framework. Sometimes, we may even need to exchange data with our cross-platform brethren. When there is only an occasional need to swap data with another platform, NServiceBus allows us to expose a command handler as a Windows Communication Foundation (WCF) web service with very little effort on our part.

In order to expose a web service, we will need the following:

  • A command message, implementing ICommand or defined using unobtrusive mode conventions. This will serve as the input to the web service.

  • An enum that will serve as the return value for the web service.

  • A handler class that processes the command and then performs Bus.Return<ResponseEnumType>(ResponseEnumType returnCode) to return the response.

Once we have these in place, we can create a web service very easily, at least as far as the NServiceBus code is concerned:

public class MyWebSvc : WcfService<MyCmd, MyResponse...