Figure 1 The ROPE Object Model

Figure 1 The ROPE Object Model

Figure 2 SalesTaxRates.USStateRates

  GetStateTaxRates() As String
GetTaxRateForState
        (ByVal StateAbbrev As String)
        As Single
GetStateTaxAmt
        (ByVal StateAbbrev As String,
        ByVal TaxableTotal As Currency)
        As Currency

Figure 4 SOAP Toolkit Supported Data Types

XML Datatype
Variant Type
string
VT_BSTR
boolean
VT_BOOL
byte
VT_I1
short
VT_I2
integer
VT_I4
unsigned-byte
VT_UI1
unsigned-short
VT_UI2
unsigned-integer
VT_UI4
float
VT_R4
double
VT_R8

Figure 5 USStateRates.xml

  <?xml version='1.0' ?>
<serviceDescription name='SalesTaxRates' 
    xmlns='urn:schemas-xmlsoap-org:servicedesc/2000-1-17' 
    xmlns:dt='https://www.w3.org/1999/XMLSchema' 
    xmlns:USStateRates='USStateRates' 
>
<import namespace='USStateRates' location='#USStateRates'/>

    <soap xmlns='urn:schemas-xmlsoap-org:soap-sdl-2000-01-25'>
        <interface name='USStateRates'>
            <requestResponse name='GetStateTaxRates'>
                <request ref='USStateRates:GetStateTaxRates'/>
                <response ref='USStateRates:GetStateTaxRatesResponse'/>
            </requestResponse>
            <requestResponse name='GetTaxRateForState'>
                <request ref='USStateRates:GetTaxRateForState'/>
                <response ref='USStateRates:GetTaxRateForStateResponse'/>
            </requestResponse>
            <requestResponse name='GetStateTaxAmt'>
                <request ref='USStateRates:GetStateTaxAmt'/>
                <response ref='USStateRates:GetStateTaxAmtResponse'/>
            </requestResponse>
        </interface>
        <service>
            <addresses>
               <location url='https://hacek/soaplisten/USStateRates.asp'/>
            </addresses>
            <implements name='USStateRates'/>
        </service>
    </soap>


    <USStateRates:schema id='USStateRates' targetNamespace='USStateRates' 
            xmlns='https://www.w3.org/1999/XMLSchema'>
        <element name='GetStateTaxRates'>
        </element>
        <element name='GetStateTaxRatesResponse'>
            <type>
                <element name='return' type='dt:string'/>
            </type>
        </element>
        <element name='GetTaxRateForState'>
            <type>
                <element name='StateAbbrev' type='dt:string'/>
            </type>
        </element>
        <element name='GetTaxRateForStateResponse'>
            <type>
                <element name='return' type='dt:single'/>
            </type>
        </element>
        <element name='GetStateTaxAmt'>
            <type>
                <element name='StateAbbrev' type='dt:string'/>
                <element name='TaxableTotal' type='dt:string'/>
            </type>
        </element>
        <element name='GetStateTaxAmtResponse'>
            <type>
                <element name='return' type='dt:string'/>
            </type>
        </element>
    </USStateRates:schema>

</serviceDescription>

Figure 6 USStateRates.asp

  <%@ Language=VBScript %>

<%

Option Explicit

Response.Expires = 0
Const SOAP_SDLURI = "https://hacek/soaplisten/USStateRates.xml"

%>
<!--#include file="listener.asp"-->
<%

Public Function GetStateTaxRates()

     Dim objGetStateTaxRates
 
     Set objGetStateTaxRates = _ 
         Server.CreateObject("SalesTaxRates.USStateRates")
     GetStateTaxRates = objGetStateTaxRates.GetStateTaxRates()
     Set objGetStateTaxRates = NOTHING
End Function

Public Function GetTaxRateForState(ByVal StateAbbrev)

     Dim objGetTaxRateForState

     Set objGetTaxRateForState = _ 
         Server.CreateObject("SalesTaxRates.USStateRates")
     GetTaxRateForState = _
         objGetTaxRateForState.GetTaxRateForState(StateAbbrev)
     Set objGetTaxRateForState = NOTHING
End Function

Public Function GetStateTaxAmt(ByVal StateAbbrev, ByVal TaxableTotal)

     Dim objGetStateTaxAmt

     Set objGetStateTaxAmt = _
         Server.CreateObject("SalesTaxRates.USStateRates")
     GetStateTaxAmt = objGetStateTaxAmt.GetStateTaxAmt(StateAbbrev, _
         TaxableTotal)
     Set objGetStateTaxAmt = NOTHING

End Function

%>

Figure 7 index.htm

  <HTML>

<HEAD>
<TITLE>US State Tax Rates Web Service Sample</TITLE>
</HEAD>

<BODY>
<H3>US State Tax Rates Web Service Sample</H3>
<P>Retrieve an ADO 2.5 Recordset containing US state tax rates:</P>
<FORM action="GetStateTaxRates.asp" id=FORM1 method=post name=FORM1>
  <INPUT type=submit id=submit1 name=Submit1 value="Get All">
</FORM>
<HR>
<P>Retrieve the state tax rate for a particular US state:</P>
<FORM action="GetTaxRateForState.asp" id=FORM2 method=post name=FORM2>
  <INPUT type=text id=state1 name=state1 value="WA">
  <INPUT type=submit id=submit2 name=submit2 value=Submit>
</FORM>
<HR>
<P>Compute the taxable amount for a particular US state and taxable total:</P>
<FORM action="GetStateTaxAmt.asp" id=FORM3 method=post name=FORM3>
  <INPUT type=text id=state2 name=state2 value="WA">
  <INPUT type=text id=amount name=amount value="$10.00">
  <INPUT type=submit id=submit2 name=submit2 value=Submit>
</FORM>
</BODY>

</HTML>

Figure 8 GetTaxRateForState.asp

  <%@ Language=VBScript %>
<% Option Explicit %>
<!--#include file="ROPEConstants.inc"-->
<%
Dim oProxy
Dim hResult
Dim sState
Dim sParam

Const URI_SDL = "https://hacek/SOAPListen/USStateRates.xml"

sState = Request.Form("state1")

Response.Write "<HTML><HEAD><TITLE>Get Sales Tax Rate for State" _
               "</TITLE></HEAD><BODY>"

Set oProxy = Server.CreateObject("ROPE.Proxy")

'-- Load the service description file for the Web service
'-- hResult = oProxy.LoadServicesDescription(icURI, URI_SDL)

If hResult >< False Then
'-- If loaded successfully, call the method (method name is case 
'-- sensitive; must match SDL)
   
   sParam = oProxy.GetTaxRateForState(CStr(sState))
   Response.Write "Sales tax in " & sState & " is " & sParam & "%"

Else
'-- If not loaded successfully, probably missing file or improperly 
'-- written

   Response.Write "Failed to load service description."

End If

Set oProxy = Nothing

Response.Write "</BODY></HTML>"
%>

Figure 9 GetStateTaxRates.asp

  <%@ Language=VBScript %>
<% Option Explicit %>
<!--#include file="ROPEConstants.inc"-->
<%
Dim oProxy
Dim oStream
Dim oADORS
Dim hResult
Dim sReturn

Const URI_SDL = "https://hacek/SOAPListen/USStateRates.xml"
Const adClipString = 2

Response.Write "<HTML><HEAD><TITLE>Get State Sales Tax Rates" _
               "</TITLE></HEAD><BODY>"

Set oProxy = Server.CreateObject("ROPE.Proxy")
hResult = oProxy.LoadServicesDescription(icURI, URI_SDL)

If hResult >< False Then
'-- If loaded successfully, call the method (method name is case 
'-- sensitive; must match SDL)

   sReturn = oProxy.GetStateTaxRates()
	
   If Len(sReturn) > 0 Then
   '-- Place the returned string in an ADO Stream object and then open an 
   '-- ADO Recordset from it 

      Set oStream = Server.CreateObject("ADODB.Stream")

      With oStream
         .Open 
         .WriteText sReturn
         .SetEOS
         .Position = 0
      End With
      
      Set oADORS = Server.CreateObject("ADODB.Recordset")
      oADORS.Open oStream
      Set oStream = Nothing

      '-- Dump recordset into an HTML table
      Response.Write "<TABLE border='1'><TR><TD>"
      Response.Write oADORS.GetString(adClipString, oADORS.RecordCount, _
                     "</TD><TD>", "</TD></TR><TR><TD>", "(null)")
      Response.Write "</TD></TR></TABLE>"

      Set oADORS = Nothing

   Else
      Response.Write "Failed to retrieve data."
   End If

Else
'-- If not loaded successfully, probably missing file or improperly 
'-- written

   Response.Write "Failed to load service description."

End If

Set oProxy = Nothing

Response.Write "</BODY></HTML>"
%>

Figure 10 GetStateTaxAmt.asp

  <%@ Language=VBScript %>
<% Option Explicit %>
<!--#include file="ROPEConstants.inc"-->
<%
Dim oSOAP
Dim oInfo
Dim oMethod
Dim hResult
Dim sState
Dim sTaxable
Dim sParam

Const URI_SDL = "https://hacek/SOAPListen/USStateRates.xml"
Const METHOD = "GetStateTaxAmt"

sState = Request.Form("state2")
sTaxable = Request.Form("amount")

Response.Write "<HTML><HEAD><TITLE>Get State Tax Amount" _
               "</TITLE></HEAD><BODY>"

Set oSOAP = Server.CreateObject("ROPE.SOAPPackager")
hResult = oSOAP.LoadServicesDescription(icURI, URI_SDL)

If hResult >< False Then
'-- If loaded successfully, call the method (method name is case 
'-- sensitive; must match SDL)

   Set oInfo = Server.CreateObject("ROPE.ServiceDescriptors")
   Set oMethod = Server.CreateObject("ROPE.SDMethodInfo")
   Set oInfo = oSOAP.GetServiceDescriptors(icMETHODINFO)
   Set oMethod = oInfo.Item(METHOD)

   With oSOAP
   
      '-- Construct SOAP request payload
      .SetPayloadData icREQUEST, "", CStr(METHOD), oMethod.InputStructure
      .SetParameter icREQUEST, "StateAbbrev", CStr(sState)
      .SetParameter icREQUEST, "TaxableTotal", CStr(sTaxable)

      '-- Send SOAP request message to the Web service
      .SendRequestToURI URI_SDL, 30

      '-- Obtain SOAP response payload from the Web service response 
      '-- message
      .GetPayload(icRESPONSE)

   End With
   
   sParam = oSOAP.GetParameter(icRESPONSE, "return")
   Response.Write "Sales tax in " & sState & " for " & sTaxable _
       & " is $" & sParam

   Set oMethod = Nothing
   Set oInfo = Nothing

Else
'-- If not loaded successfully, probably missing file or improperly 
'-- written

   Response.Write "Failed to load service description."

End If

Set oSOAP = Nothing

Response.Write "</BODY></HTML>"
%>

Figure 11 Requesting a State Sales Tax Rate

Figure 11 Requesting a State Sales Tax Rate