Delphi-Kylix
  Home arrow Delphi-Kylix arrow Page 4 - Building a Web Service from Scratch with D...
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
DELPHI-KYLIX

Building a Web Service from Scratch with Delphi
By: Leidago
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 4
    2006-11-06

    Table of Contents:
  • Building a Web Service from Scratch with Delphi
  • Writing the Methods
  • Adding state
  • Testing the service

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Building a Web Service from Scratch with Delphi - Testing the service


    (Page 4 of 4 )

    Now, to use the service we need to create a client, but before we do this make sure that the service is running. We need to create the client in the same way that we created the other client in the previous article. Go to File|New|Other and select the Web services tab. Then select WSDL importer, and enter the location of the WSDL file that you saved previously. The wizard should now create a unit for you. Save this unit in a new folder.

    Then start a new application and save it in the same folder. On the form drop an edit, a button and an httprio component (rename it htt). Now, you might ask why we are using the  HTTPRIO component since its main purpose is to connect a client to a web service that is located on a server on some other part of the planet? It's very simple: the HTTPRIO component regards the (local) web server (in my case IIS) as remote. So let's set the parameters for the HTTPRIO component:

    WSDLLocation : IMyWebServer.xml

    Port : IMyWebServerPort

    Service: IMyWebServerservice

    Obviously your details might be different depending on what name you gave your WSDL file earlier. Now double click on the button and add the following code:

    procedure TForm1.Button1Click(Sender: TObject);

    begin

    (htt as IMyWebServer).SetTxt(edit1.Text);

    showmessage('The text entered is: '+(htt as
    IMyWebServer).GetTxt);

    end;

    All that happens in this code is that the settxt function is called with the text available in the edit1 box and then gettxt is called to show the text.

    That's all there is to it when creating web services. Delphi makes it all very easy for us by doing all the donkey work so we can easily work with a web service with two lines of code!

    Conclusion

    I'm well aware that the example service I created here is very simple. This is entirely intentional. This code can easily be modified and made more useful. It is a good starting point for someone who is just starting to learn web services. A good next step would be to perhaps introduce a database to the service and display random quotes. Visit the xmethods.com website for some inspiration. In the meantime have fun using and learning web services.


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

       · Web services are a exiting new technology, this article will explain how you can...
     

    DELPHI-KYLIX ARTICLES

    - 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...
    - Using the Client Dataset in Two-Tiered Clien...






    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
    Stay green...Green IT