Quick References
      ADO
      ASP
      CSS2
      HTML
      JavaScript
      Jet SQL
      VBScript
      WML
      WMLScript
      WSH
      XHTML
      XML DOM
      XSLT

Features
      Knowledge Base
      Tutorials

Partners
     ZVON.ORG
     XML
     Planet Source Code
     VisualBuilder
     Web Design
     Your HTML Source
     XML/XSLT Forums
     ASPAlliance
     Scripts
     
     Programmers Heaven
     Tek-Tips Forums
     Developer Fusion
     Code Project



Creating a Web Service using ActiveX Components



SOAP Client

For our SOAP Client we will create the following

  1. ActiveX Server Component
  2. ASP application to input a number and display the result.

ActiveX Server Component

  1. Create a new ActiveX dll Project
  2. Change the name of your project to SoapClient
  3. Change the name of your class to CreateSoap
  4. Add references to SOAP Type Library.

*For this example I use the SOAP Type Library v3.0.

The SOAP Client will accept the method call "CalcFactorial" or "CalcSquareRoot" and a user defined number from our ASP application "math.asp" Using the SOAP Serializer we will build a SOAP Envelope and send it to the SOAP Server via an http connector. The two possible outcomes from our SOAP Server are :

1. The answer via SOAP Message
2. A SOAP Fault alerting us of an error.

Code for CreateSoap.cls

' This is the Location of the asp listener page. In my case: localhost/SOAP/.

Const END_POINT_URL = "http://localhost/SOAP/SOAPListener.asp"

Public Function GenerateSOAP(ByVal MethodCall As String, ByVal num As Long) _
          As String
    Dim SOAPReader As MSSOAPLib30.SOAPReader30
    Dim SOAPSerializer As MSSOAPLib30.SOAPSerializer30
    Dim SOAPConnector As MSSOAPLib30.SOAPConnector30

    Set SOAPConnector = New MSSOAPLib30.HttpConnector30
    SOAPConnector.Property("EndPointURL") = END_POINT_URL
    SOAPConnector.Connect

    ' Set Method Call

    SOAPConnector.Property("SoapAction") = MethodCall
    SOAPConnector.BeginMessage

    Set SOAPSerializer = New MSSOAPLib30.SOAPSerializer30
    SOAPSerializer.Init SOAPConnector.InputStream

    ' Create/Send SOAP Message with Parameter "Number"

    SOAPSerializer.StartEnvelope
      SOAPSerializer.StartBody
        SOAPSerializer.StartElement MethodCall, "uri:Math", , "Functions"
          SOAPSerializer.StartElement "Number", "uri:Math", , "Functions"
            SOAPSerializer.WriteString num
          SOAPSerializer.EndElement
        SOAPSerializer.EndElement
      SOAPSerializer.EndBody
    SOAPSerializer.EndEnvelope

    SOAPConnector.EndMessage

    Set SOAPReader = New MSSOAPLib30.SOAPReader30

    ' Load SOAP Server response into reader

    SOAPReader.Load SOAPConnector.OutputStream

    ' Check for SOAP Fault. In most cases we would do something with a fault (log, etc.)
    ' For simplicity simply return to caller.

    If Not SOAPReader.Fault Is Nothing Then
        GenerateSOAP = SOAPReader.FaultString.Text
    Else
        GenerateSOAP = SOAPReader.RpcResult.Text
    End If
End Function

 
  1 2 3 4 5 6
 
   
Copyright 1999-2005 by Infinite Software Solutions, Inc. All rights reserved.
Trademark Information
knoxville photographer
knoxville wedding photographer