WebServicesPro News Archives About Us Feedback

Recent Articles

Social Networking Browser Flock Gets Facelift
If you're using social networking/web 2.0 technologies to generate traffic and you aren't using the Flock web browser in your efforts, you're missing out in a big...

Track Your Friends Web Activities with Friendfeed
Friendfeed is a cool new service by ex-Gmail and "don't be evil" inventor Paul Buchheit. Friendfeed (which partly looks Google-like, too) tries to solve the problem of keeping track of your friends activities on the...

From SOAP To REST Web Services
I received a question in my email from reader, Rob Rawlins: A client of mine wants me to change the SOAP web service I publish into a REST service, and I dont even know where to begin. After googling around for...

Google Services Give You More Storage, If You Pay...
Google has finally unveiled a system under which you can pay them for more storage in Gmail, Picasa Web Albums, and eventually, a bunch of other Google...

SaaS Vs. OSS? Users Choose SaaS
Tim O'Reilly has an interesting post on why the GPLv3 took a pragmatic approach when it came to the "SaaS loophole" (i.e. SaaS apps aren't redistributed; no redistribution means SaaS vendors can use...

FreshBooks Opens API, Lets In Some Fresh Air
The Enterprise Web 2.0 revolution has been a godsend to small and midsized companies. Inexpensive, web-based tools and services mean the little guys now...

Speed Up Web Services With The SoapDocument...
I've done a lot of web services during the last couple of years and I simply love Service Oriented Architecture using SOAP. The power of using services as a means to create large connected systems are enormous but...


11.08.07


Keep Web Services Simple

By Mads Kristensen

The easy way for .NET developers to create an API over HTTP is to use SOAP web services.

It's natively supported by .NET and has rich support for more complex data types such as the DataSet. The problem with SOAP is that it isn't well supported by other platforms and to consume a .NET SOAP web service in PHP is a nightmare.

If you want to build an API for your web application over HTTP, then consider a simpler approach that is much faster, supports both GET and POST, can easily be RESTful, and works on all platforms. XML-RPC is a good way of doing such a service, but we can do it even simpler and define our own contract easily.

The class

I've build a very small class, RpcService, that let's you pass plain text both ways over HTTP. The text will probably be XML for a more structured contract, but that's up to you. The class has a static Send method and a static Receive method.

The Send method passes the plain text or XML to the request stream and returns the reply as a string. You can then parse the XML your self if needed. The Receive method listens for requests with text in the request stream and returns it as a string. Now you have both ends of the API - the client and the server.

Try a Better Way Today. Try WebEx PCNow


Example

Let's say you want to build a stock quote service that returns the quote of a given stock based on the a stock symbol. You then start by adding an HttpHandler to your website called stock.ashx. That file will function as your web service end point. In the handler's ProcessRequest method you then call the Receive method to get the text from the request stream. It contains the stock symbol and now you need to respond with the current stock quote. You simply just write the quote using Response.Write in order to return it. It could look like this:



Now you have the service ready on the server. The only thing missing is a way to consume the service . In order to do that we need to use the Send method of the RpcService class. It could look like this:

Continue reading this article.


About the Author:
Mads Kristensen currently works as a Senior Developer at Traceworks located in Copenhagen, Denmark. Mads graduated from Copenhagen Technical Academy with a multimedia degree in 2003, but has been a professional developer since 2000. His main focus is on ASP.NET but is responsible for Winforms, Windows- and web services in his daily work as well. A true .NET developer with great passion for the simple solution.

http://www.madskristensen.dk/

About WebServicesPro
WebServicesPro delivers news and strategy articles covering the broad scope of what is known as Web Services. Each issue of WebServicesPro is focused on Making Web Services a Reality.

WebServicesPro is brought to you by:

SecurityConfig.com NetworkingFiles.com
NetworkNewz.com WebProASP.com
PerlProNews.com SQLProNews.com
SysAdminNews DevWebPro.com
LinuxProNews.com WirelessProNews.com
CProgrammingTrends.com ITCertificationNews.com


-- WebServicesPro is an iEntry, Inc. publication --
iEntry, Inc. 2549 Richmond Rd. Lexington KY, 4050
2007 iEntry, Inc.  All Rights Reserved  Privacy Policy  Legal

archives | advertising info | news headlines | free newsletters | comments/feedback | submit article


WebServicesPro Home Page About Article Archive News Downloads WebProWorld Forums iEntry Advertise Contact WebProWorld Forum Making Web Services a Reality