Simple Webservice Echo Test

|

While troubleshooting some PHP Curl issues, I found and used http://respondto.it/ (and later http://requestb.in/) which allows you to create a dummy webservice endpoint which reveals the full request made to it by your code.

An even simpler use case would be a webservice that simply returned data about the request directly to the calling application. I just created such a simple echo webservice on my scooterlabs.com domain.

Plain text example

$ curl http://scooterlabs.com/echo
Array
(
    [method] => GET
    [headers] => Array
        (
            [User-Agent] => curl/7.19.7 (universal-apple-darwin10.0) libcurl/7.19.7 OpenSSL/0.9.8r zlib/1.2.3
            [Host] => scooterlabs.com
            [Accept] => */*
        )

    [request] => Array
        (
            [foo] => bar
        )

    [client_ip] => 68.125.160.82
    [time_utc] => 2012-01-08T21:33:28+0000
    [info] => Echo service from Scooterlabs (http://www.scooterlabs.com)
)

JSON example

$ curl --silent curl http://scooterlabs.com/echo.json?foo=bar | json_xs
{
   "info" : "Echo service from Scooterlabs (http://www.scooterlabs.com)",
   "request" : {
      "foo" : "bar"
   },
   "headers" : {
      "User-Agent" : "curl/7.21.3 (i386-portbld-freebsd7.3) libcurl/7.21.3 OpenSSL/1.0.0e zlib/1.2.3 libidn/1.22",
      "Accept" : "*/*",
      "Host" : "scooterlabs.com"
   },
   "client_ip" : "66.39.158.129",
   "time_utc" : "2012-01-08T22:07:54+0000",
   "method" : "GET"
}

Source

Source code is up on Github: https://github.com/bcantoni/echotest. If anyone has any comments or feedback, let me know here or on Github.

Possibly related posts:

About

This is the personal website of Brian Cantoni. All opinions on this site are my own.

Twitter

Delicious Links

This weblog is licensed under a Creative Commons License.

Tweetfave

Coming soon - a new way to get the most out of your Twitter Favorites: Tweetfave.com

Mobile Websites

Visit cantoni.mobi for a helpful list of mobile sites.

Advertising

Archives

For older entries, please refer to the Archives.