Book Image

ServiceStack 4 Cookbook

Book Image

ServiceStack 4 Cookbook

Overview of this book

Table of Contents (18 chapters)
ServiceStack 4 Cookbook
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Making a basic proxy for existing web services


From time to time, it might be useful to build a proxy for a web service that already exists. Maybe this is because you have an internal service that wasn't designed for consumer use. You'd love to expose it, but you'd need to change it first, and for some reason you cannot. The proxy technique can come in handy here—build a new service that connects to the old service and proxies requests to the old service. In this recipe, we'll build an example of doing just that using the Twitter API as an example of a service you'd like to wrap.

Let's imagine that we wanted users of our group messaging app to search for keywords so that they could find pictures that they could post as messages to their friends. We could leverage an existing provider, such as Flickr, and proxy the service through our application.

How to do It…

First we'll use JsonServiceClient to access Flickr. We can create a FlickrSearch class to help with that, as follows:

[Route("/services...