Visual Basic.NET
  Home arrow Visual Basic.NET arrow Page 4 - Calling a Web Service using VB6 with SOAP ...
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Dedicated Servers 
Moblin 
JMSL Numerical Library 
Windows Web Hosting
 
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? 
VISUAL BASIC.NET

Calling a Web Service using VB6 with SOAP 3.0
By: Jayaram Krishnaswamy
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 50
    2006-04-12

    Table of Contents:
  • Calling a Web Service using VB6 with SOAP 3.0
  • The web services used in the tutorial
  • Example 2: Calling a ColdFusion web service
  • Example 3: SOAP client calling the Enc/Denc web 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


    Calling a Web Service using VB6 with SOAP 3.0 - Example 3: SOAP client calling the Enc/Denc web service


    (Page 4 of 4 )

    The second web service considered is a service that has two defined methods. The service takes a string and returns its encoded value as the first method (Enc()) and the second method (denc()) takes a given value and returns its de-encoded value. Please review this tutorial regarding this service. The web service code is created using VB.NET and summarized in the following code listing:

    Imports System.Web.Services
    <System.Web.Services.WebService(Namespace := "http://tempuri.org/
    Hencode/Service1")> _ Public Class Service1 Inherits System.Web.Services.WebService #Region " Web Services Designer Generated Code " Public Sub New() MyBase.New() 'This call is required by the Web Services Designer. InitializeComponent() 'Add your own initialization code after the InitializeComponent()
    call End Sub 'Required by the Web Services Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Web Services Designer 'It can be modified using the Web Services Designer. 'Do not modify it using the code editor. <System.Diagnostics.DebuggerStepThrough()> Private Sub
    InitializeComponent() components = New System.ComponentModel.Container() End Sub Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) 'CODEGEN: This procedure is required by the Web Services Designer 'Do not modify it using the code editor. If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub #End Region Public Function enc (ByVal StrEncode As String) Dim encodedStr As String encodedStr = _ Convert.ToBase64String(System.Text.ASCIIEncoding. _ ASCII.GetBytes(StrEncode)) Return (encodedStr) End Function <WebMethod()> _ Public Function denc (ByVal StrDecode As String) Dim decodedStrg As String decodedStrg = System.Text.ASCIIEncoding.ASCII. _ GetString(Convert.FromBase64String(StrDecode)) Return decodedStrg End Function End Class

    Create a project and a command button to the default form. To the click event of the button add the code shown here. The client once declared can be used for all the methods the service provides.

    Private Sub Command1_Click()
    Dim clnt As New SoapClient30
    Dim strsvc As String
    'the client is initialized
    clnt.MSSoapInit "http://localhost/Hencode/Service1.asmx?wsdl"
    'the client calls the enc method of the service
    strsvc = clnt.Enc ("Mysorian")
    'the result returned from the web service is sent to message box
    MsgBox (strsvc)
    Dim orig As String
    'the client is called now with denc method of the web service
    'the denc takes the string produced by the first call to enc
    'the idea is to reproduce the original string
    orig = clnt.denc(strsvc)
    MsgBox (orig)
    End Sub

    If you run the above code, you will first get an encoded value, and in the second message your original is recovered as shown.

    Summary

    SOAP 3.0 will be used by those who cannot afford, or do not want to implement, the .NET framework as the programming backbone. It is also quite useful to those developers who want to use their VB 6 skills. The method does not have the excellent support of the built-in web service discovery tool in VS 2003, but necessary information may be obtained from the web reference (WSDL).  It is possible to use either of the CreateObject() or NEW instantiation schemes.


    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 in one form or another is here to stay. A number of easy to understand...
       · The article is good to begin with. Is SOAP a generic solution for communicating...
       · What kind of difficulty did you experience. Lots of time it is to do with the data...
       · It is possible to call a web service method using VB6 with SOAP 3.0.It is ok if...
       · Could you be little more specific? I am not sure what exactly you are trying to...
       · Hi, I am facing problem to "Calling Web Services in VB6"If any one already...
       · Could be more specific as to what kind of a problem?
       · code that can call web service
       · Your answer is very brief and I cannot fathom the exact problem you are having.The...
       · Does the client server need the MS SOAP Toolkit installing before you can use SOAP...
       · I have followed exaactly the same from the tutorial but it prompt an error. The...
       · Well, now i roughly know what caused this to happen. It only happen when i am using...
       · Hi,is it possible to pass some credential information like user name and...
       · Hi Jay,Im getting the follwoing error when trying to use VB 6.0 to access a...
       · If you receive this error message try the suggestion below:Connector:Connection...
       · how to call a web service created using vb.net.how to use the vb6 application to...
     

    VISUAL BASIC.NET ARTICLES

    - Create a Sudoku Puzzle Generator using VB.NET
    - Entity Creation and Messaging in a VB.NET Te...
    - Movement and Player Statistics in a VB.NET T...
    - Creating and Drawing a Game Map in VB.NET (F...
    - Working with Classes and Properties for Game...
    - Working with Loops, Arrays, and Collections ...
    - Learning Loops in VB.NET for Game Development
    - Learning VB.NET: Working with Variables, Con...
    - The Basics of VB.NET Through Text Game Devel...
    - Learning VB.NET Through Text Game Development
    - Types of Operators in Visual Basic
    - Operators
    - Understanding Custom Events using Visual Bas...
    - Polymorphism using Abstract Classes in Visua...
    - Shadowing using Shadows in Visual Basic.NET ...





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