4

I am a Computer Science student, and I am studying the web this academic year. I already have a knowledge on HTML, CSS, Javascript, PHP and a bit of XML. I will need to make a mini project which will includes all of these technologies, including web services in it. Could you give me a description of why and how web services work. Why we use that, and what could not be done without it.

It would be good if you could give me an example, where we use web services. That'd give me some ideas to think about my project title.

I'm going to use SOAP and WSDL, using PHP.

  • Some links: http://stackoverflow.com/questions/204653/when-should-a-web-service-not-be-used, http://stackoverflow.com/questions/226108/what-is-a-web-service-in-plain-english, http://stackoverflow.com/questions/4693301/web-service-vs-aspx-pages-pros-and-cons – John Saunders Aug 25 '12 at 20:37
  • You can check sample projects from here.This gives you a better understanding on the working. http://www.codeproject.com/Articles/41844/Webservice-Client-and-Server-demo-in-PHP – Sajith Aug 25 '12 at 10:25

1 Answers1

3

Why we use web services

The power of web services are that they provide features programmers can add to their own applications, regardless of the programming language used.

Example

For example, you may have a website in which you would like users to to be able to punch in their location and your website returns the weather along with a display of their location on Google maps. Google maps, and various weather sites, provide web services so web developers can use such features. If your site is coded in Java, PHP, or python, it will not matter.

Another example is if you have a business website and you would like your site to display stock tickers daily. Various companies will provide stock ticker web services so that you can do that. Some are free and some are not.

SOAP vs RESTful Web services

Eventually you will need to discuss the difference between RESTful web services and SOAP, and that is a monumental discussion in itself. But a simple example of a restful web service for adding two numbers is below.

REST

http://www.SimpleMathSite.com/Add/5/6/

the site will return some thing like

<?XML  version="1.0" encoding="utf-8"?>
<answer>
11
</answer>

You can use this in your javascript or PHP code. Looking at the URL you can see your calling the 'Add' function and passing it the values 5 and 6. This is how web services allow objects written in different languages to communicate with each other.

SOAP

SOAP is far more complicated but it's advantage is the WSDL file which describes all of the remote functions you can call. Because of this some compilers let you import a web service and create objects that you can place in your code without needing to see any of the complicated XML going on behind the scenes. If the above example had a WSDL file some compilers would let you import the web service so you could use it in your code like this.

int Answer = SimpleMath.Add(5,6); // No need to parse the XML yourself.

Check out this weather web service for a great example of how to use SOAP. It provides sample HTTP GET and POST requests you can use if you want to make your own SOAP client from scratch.

http://www.webservicex.com/globalweather.asmx?op=GetWeather

What if there were no web services?

Without web services web sites could not update their content with data that comes from other web sites, like air line information, hotel vacancies, or whether or not your facebook friends like the same song on Pandora.

Usman Mutawakil
  • 4,993
  • 9
  • 43
  • 80