Rusty S. Swayne

tidbits and tangents

Rusty S. Swayne

My name is Russell S. Swayne although I have gone by Rusty all of my life. I own a small web design/development studio named Mindfly (http://www.mindfly.com), have a wonderful wife and very precocious and yet extremely charming daughter.

contact me Feed
 

RemoteAPI class with simple REST web service

When meddling with mashups I have found it helpful to have a simple utility that allows me to play with REST (Represential State Transfer) web services. REST has become very popular as it is really easy to implement and generally straight forward to understand.

Public Class RemoteAPI
    Public Shared Function GetRESTQueryResults(ByVal URI As String) As String
        Dim req As HttpWebRequest = WebRequest.Create(URI)
        Dim resp As HttpWebResponse = Nothing
        Dim results As String = Nothing
        Try
            resp = req.GetResponse
            Using sr As New StreamReader(resp.GetResponseStream())
            results = sr.ReadToEnd().Trim
            End Using
        Catch ex As Exception
            results = String.Format("<error>{0}</error>", ex.Message)
        End Try
        Return results
    End Function
End Class
 

Add comment


(Will show your Gravatar icon)  





Live preview

said...

-July 6. 2008 08:55

 
 

Powered by BlogEngine.NET 1.2.0.0. Original Design by Heather Alvis.
Sign in