Home arrow HTML arrow Page 2 - Wanna Chat with a Web Service?

Wanna Chat with a Web Service?

If you are creating a web service and you feel that you would like to communicate with your client, Ahm will discuss how with help from Eliza. Interested? Read this article to find out more.

Author Info:
By: Ahm Asaduzzaman
Rating: 5 stars5 stars5 stars5 stars5 stars / 17
April 26, 2003
  1. · Wanna Chat with a Web Service?
  2. · The Article
  3. · Conclusion

print this article

Wanna Chat with a Web Service? - The Article
(Page 2 of 3 )

RPC-Style Web Services

Remote Procedure Call (RPC)-Style Web services are synchronous because the clients invoke the Web Service by sending parameters and waits for the method to return values before continuing. RPC-style Web Services are tightly coupled because the sending parameters and return values are as described in WSDL (Web Service Description Language) file, an XML format for describing Web Services. In RPC-style Web Services, the calling parameters and the return values are wrapped inside the SOAP Body.

The difference with SOAP and XML-RPC is that it uses standard, general-purpose transports; such as HTTP; together with a text-based method call description in XML. RPC made over Web-based protocols and are no different from those made over other protocols, such as IIOP, DCOM, or JRMP. However, HTTP (and SMTP) has general right of access through most firewalls, which makes it easier to integrate applications across organizational boundaries and it is payload agnostic.

Example RPC-Style Web Service

To explain this part of the article, I have chosen a Web service from Xmethods, called “Eliza-chat with a Web Service”.  Let’s try to implement a client in Visual Basic 6.0 to consume the service. The codes should be written in a way, so, if anyone has elementary knowledge in VB, can re-write a few lines of codes to consume other RPC-Style Web services.

Now little about Eliza, “she” is a mock Rogerian psychotherapist. It prompts you user input, and uses a special transformation algorithm to change user input into a follow-up question. Which makes certain kinds of natural language conversation between man and computer. It was introduces in 1966 in ACM 9 by Joseph Weizenbaum. If you are interested in computational linguistics, MIT press is a good starting point.

At first, look into the RPC profile for this service (Pic. 1), that’s all information you need to write the client.

Pic. Eliza 1.

The vital part of VB code for SOAP envelops to construct request string with input parameters and output string with output parameters is as follows.  The detail coding/description you can find in the support file with this article.

Option Explicit
Dim bFlag As Boolean
Private Sub DisplayData(ByVal response As String)
    Dim doc As MSXML2.DOMDocument
    Set doc = New MSXML2.DOMDocument
    'MsgBox response
    If doc.loadXML(response) Then
        lblCurrentTemp.Caption = doc.selectSingleNode("//Eliza").text
        MsgBox "Failed to load the response text: " & vbCrLf & response
    End If
    bFlag = True
End Sub
Private Sub txtZip_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
    Dim soap As SOAPSender
    Set soap = New SOAPSender
    bFlag = False
    Screen.MousePointer = vbHourglass
    soap.BeginBodyPart "chat", "http://www.net-aholic.de/cgi-bin/eliza/chat.wsdl"
    soap.BeginElement "Say", ""
    soap.WriteText txtZip.text
    soap.SoapAction = "http://www.net-aholic.de/cgi-bin/eliza/chat.wsdl"
    soap.ServiceUrl = "http://www.net-aholic.de/cgi-bin/eliza/chat.wsdl"
    ' to analyze request envelop, uncomment following line
    'MsgBox soap.GetRequestString
    'MsgBox soap.GetResponseString
    DisplayData soap.GetResponseString
    Screen.MousePointer = vbDefault
txtZip.text = ""
End If
End Sub

Pic. Eliza 2.

Document-Style Web Services

It is beyond dispute that the ability to invoke a cross-platform RPC using XML is extremely useful and compelling for using Web Services, if it constrained only to RPC mechanism, the reach of the technology will be limited. Developers have a choice of using either RPC or document-style messaging. Here is a good article by McCarthy on document-style Web Services. Document-style Web Services are loosely coupled and asynchronous. The client sends the parameter to the Web Service as XML document, instead of discrete set of parameter values to the Web Service. The input XML document can also be described in WSDL.

Unlike RPC-style Web Service, Document-style Web Service does not follow call/response semantics.  The Web Service receives entire document, processes it and may or may not return a response message. The SOAP Body of a document style carries one or more XML documents, within its body. The protocol places no constraint on how that document needs to be structured, which is totally handled at the application level.

Here is an example: if you send an email to: google@capeclear.com and in the subject line type your query string, you will get the query response from the Google Web service over the email. Same way we can get the different language translation services.  Document-Style Web Services has begun to emerge as an important but very different approach. Document-Style Web Services prove to be the best solution for wide range of usage scenarios in B2B. The Xmethods site is hosting a demo Web service that is built using document style.

blog comments powered by Disqus

- Does HTML5 Need a Main Element?
- Revisiting the HTML5 vs. Native Debate
- HTML5: Not for Phone Apps?
- HTML5 or Native?
- Job Hunting? Freelancer.com Lists This Quart...
- HTML5 in the News
- Report: HTML5 Mobile Performance Lags
- The Top HTML5 Audio Players
- Top HTML5 Video Tutorials
- HTML5: Reasons to Learn and Use It
- More of the Top Tutorials for HTML5 Forms
- MobileAppWizard Releases HTML5 App Builder
- HTML5 Boilerplate: Working with jQuery and M...
- HTML5 Boilerplate Introduction
- New API Platform for HTML5

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 

Developer Shed Affiliates


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