Wiki Search

CS 352 Wiki Web Development 3

| edit page | page history | Sign in |

Day 10 Wiki Notes main content

Notes Index

Big Picture: SOA

Enterprise-level IT solutions are moving to a Service Oriented Architecture (SOA).

SOA's connect together loosely coupled software services using standards (XML, SOAP, etc.). Very often, Web Services are used to implement a service-oriented architecture.

Web services provide interoperability between various software applications running on different platforms written in different programming languages by agreeing to a standard protocol.

Web Sevices Protocols

Web Services Web Services exchange data between a server and a client, using XML to format requests and data so that both systems can understand each other.

Originally, XML-RPC, Remote Procedure Call, used Hypertext Transfer Protocol (HTTP) and eXtensible Markup Language (XML) to create a standard way of calling remote web services and receiving a response. See XML-RPC Home Page.

Microsoft, IBM, and W3C developed SOAP, Software Object Access Protocol, as a lightweight protocol intended for exchanging structured information over HTTP. See SOAP tutorial. Like RPC, SOAP uses XML and its related technologies to define an extensible messaging framework. The framework is independent of any particular programming model and other implementation specific semantics.

Recently, interest is rising in using REST, REpresentational State Transfer, for Web services. Rather than a new protocol, it consists of a popular set of patterns and idioms for consistent and intuitive web services built on top of existing Web protocols. See Building Web Services the REST Way.

RESTful Example

Amazon makes available both SOAP and REST interfaces to their web services, and 85% of their usage is of the REST interface. Amazon provides a useful Scratch Pad tool to experiment with its Web Services

PHP and REST

The article PHP Web Services Without SOAP provides a lengthy description for the following example which uses REST in PHP.

As a proof of concept, we could use HTML-Kit to create getResults.php. Paste the following code into this file.


<?php
$url = "http://ecs.amazonaws.com/onca/xml?" .
"Service=AWSECommerceService&Version=2005-03-23" .
"&Operation=ItemSearch" .
"&ContentType=text%2Fxml" .
"&SubscriptionId=0525E2PQ81DD7ZTWTK82" .
"&SearchIndex=Books" .
"&Title=Gone%20with%20the%20Wind" .
"&ResponseGroup=Small";

$results = file_get_contents($url);
print($results );

?>

This would return the xml file as a string. We would need to create the url and extract information from the $results to make it usable.

ASP.NET and REST

We can use REST with ASP.NET pages as well.

protected void Page_Load(object sender, EventArgs e)
{
    string restUrl = "http://ecs.amazonaws.com ... "
    XmlDocument doc = new XmlDocument();
    doc.Load(restUrl);

     Xml1.Document = doc;

     XslTransform trans = new XslTransform();
     trans.Load(Server.MapPath("amazon2.xsl"));
     Xml1.Transform = trans;
}

Asynchronous Web Services

So far in our simple exercises in class, we have been calling web services and waiting on the response.

More realistically, with SOA applications it makes more sense to call services asynchronously

localhost.WebService ws = new localhost.WebService();
 ws.HelloWorldCompleted += new HelloWorldCompletedEventHandler(HelloWorldDone);
 ws.HelloWorldAsync();

protected void HelloWorldDone(object sender, localhost.HelloWorldCompletedEventArgs e)
{
   Label1.Text = e.Result;
}

| Return to top | | Site Management | Find Broken Links | edit | attr | Documentation Index | PmWiki.org |

Page last modified on April 10, 2008, at 11:37 AM