Home arrow Delphi-Kylix arrow Page 2 - Web Services Made Easy With Delphi
DELPHI-KYLIX

Web Services Made Easy With Delphi


Web services are being used more and more on the Internet, thanks to (among other advantages) their cross-platform compatibility. In this article, the first of three parts, we will cover what a web service is and how it works, and look at some examples of XML and SOAP messages.

Author Info:
By: Leidago
Rating: 3 stars3 stars3 stars3 stars3 stars / 19
October 23, 2006
TABLE OF CONTENTS:
  1. · Web Services Made Easy With Delphi
  2. · Why use XML (eXtensible Markup Language)?
  3. · Why SOAP (Simple Object Access Protocol)?
  4. · Web Service Description Language (WSDL)

print this article
SEARCH DEVARTICLES

TOOLS YOU CAN USE

advertisement
Web Services Made Easy With Delphi - Why use XML (eXtensible Markup Language)?
(Page 2 of 4 )

XML is an extensible mark-up language that enables you to identify and organize your information in a more accurate and flexible way. It is called extensible because it does not have a fixed format, as does HTML, which is an SML or Single Markup Language. 

For example if you want text to appear bold in HTML you place the text between the "<b></b>" tags. Every browser knows what to do when they encounter these tags. If however, you change these tags to "<bold></bold>" then browsers would not know what to do with them, since they are only programmed to recognize the "<b></b>" as meaning bold. 

In contrast to this, XML does not have any predefined tags; rather, it allows you to create your own tag sets to both display and format text. All you have to do is add a (XSL) stylesheet to enable the browser to format your text. This language can therefore be read and understood on any computer platform, and it is precisely because of this flexibility that web services uses XML to format its messages. The most visible use of XML is in RSS documents, which are used to make news content available on the Internet. Below is an example of an RSS document:

XML code:

<?xml version="1.0" encoding="iso-8859-1"?>
<?xml-stylesheet type="text/xsl" href="generic.xsl"?>
<!-- Copy and paste the url into your newsreader application" -->
<!-- generator="Movable Type/2.64" -->
<rss version="0.91">
  <channel>
     <item>
      <title>RSS Syndication </title>
      <link>http://www.examplesite.com</link>
      <description> The UK newspaper that does not have an RSS
feed??</description>
    </item>   

    <item>
      <title>Education in Crisis??</title>
  <link>http://www.examplesite.com</link>
  <description>The problem of classroom shortage in UK Schools</description>
</item>
    <item>
      <title>RSS XML Reader</title>
  <link>http://www.examplesite.com</link>
  <description>A new program that reads xml files. </description>
</item>
      </channel>
</rss>

The line "<?xml-stylesheet type="text/xsl" href="generic.xsl"?>" specifies the name of the style sheet that is used to format the information. In this case the file is called "generic.xsl." Below is the style sheet code that enables the XML code to be formatted:

<?xml version="1.0" ?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" encoding="iso-8859-1" omit-xml-
declaration="yes" indent="yes"/>
<xsl:template match="*">
<table border="1" width="600" align="center">
<tr><td valign="top" align="center" class="title"
bgcolor="silver" >
<a>
<xsl:attribute name="href">
<xsl:value-of select="*[local-name()='channel']/*[local-name()
='link']"/>
</xsl:attribute>
<xsl:attribute name="target">
<xsl:text>top</xsl:text>
</xsl:attribute>
<xsl:value-of select="*[local-name()='channel']/*[local-name()
='title']" disable-output-escaping="yes"/>
</a>
<xsl:text disable-output-escaping="yes">&amp;nbsp;</xsl:text>
<xsl:value-of select="*[local-name()='channel']/*[local-name()
='lastBuildDate']"/>
</td></tr><tr><td valign="top" bgcolor="ghostwhite"
class="headlines" >
<ul>
<xsl:for-each select="//*[local-name()='item']">
<li>
<a>
<xsl:attribute name="href">
<xsl:value-of select="*[local-name()='link']"/>
</xsl:attribute>
<xsl:attribute name="target">
<xsl:text>top</xsl:text>
</xsl:attribute>
<xsl:value-of select="*[local-name()='title']" disable-output-
escaping="yes"/>
</a>
<xsl:text disable-output-escaping="yes">&amp;nbsp;</xsl:text>
<xsl:value-of select="*[local-name()='description']" disable-
output-escaping="yes"/>
</li>
</xsl:for-each>
</ul>
</td></tr>
</table>
</xsl:template>
<xsl:template match="/">
<xsl:apply-templates/>
</xsl:template>
</xsl:stylesheet> 

I will not be explaining how style sheets are created because that is an entire subject in its own right. But here is what you get when you combine the two:

To summarize:

  • XML gives you the ability to 'package' your information in anyway you like, i.e. you can create your own tag sets and still have the same advantages offered by HTML, like text formatting.
  • XML is platform independent.
  • XML is language independent, i.e. you can create a xml document in any language  


blog comments powered by Disqus
DELPHI-KYLIX ARTICLES

- Loading an XML Document into the DOM
- Delphi Wrapper Classes and XML
- Delphi and the DOM
- Delphi and XML
- Internet Access: Client Service
- Finishing the Client for an Internet Access ...
- The Client for an Internet Access Control Ap...
- User Management for an Internet Access Contr...
- Important Procedures for an Internet Access ...
- Server Code for an Internet Access Control A...
- Constructing the Interface for an Internet A...
- Building a Server Application for an Interne...
- Building an Internet Access Control Applicat...
- Client Dataset: Working with Data Packets an...
- Using the Client Dataset in an N-Tiered Appl...

Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 



© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 11 - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials