Skip to main content
Kofax

Call a Web Service from a SBL Validation Script

9568

QAID # 9568 Published

Question / Problem:

Is there a way to call a Web Service from a Validation Script?

Answer / Solution:

While a Web Service cannot be accessed directly via SBL or Ascent Capture, it is possible to do this by creating a COM object that wraps the Web Service, and instantiating this object via the CreateObject method in SBL.

As an example, we can start with a Visual Basic 2005 Class Library project, naming it:

KofaxSupportSamplesWebServiceValidation.

Ensure that the Root Namespace matches the project name, and on the Compile page of the My Project properties, enable the Register for COM Interop option.

Next, add a static Web Reference to:

http://www.webservicex.net/uszip.asmx?WSDL.

Then create a COM object named WrapperClass and add the following code:

Public Function GetZIPInfo(ByVal ZipCode As String) As String
    Dim sResult As String = ""
    Dim o As New net.webservicex.www.USZip

Try
sResult = _
           o.GetInfoByZIP(ZipCode).SelectNodes("descendant::CITY").Item(0).InnerText
    Catch ex As Exception

        MsgBox(ex.Message, MsgBoxStyle.Exclamation, _
           "Kofax Support Web Service Sample (GetZIPInfo)")

End Try
    Return sResult
                End Function

After building the project, go to a Document Class and create a Document Validation Script.

Add the following code to the bottom of the default script:

Sub Main
   Dim o As Object
   Set o = CreateObject("KofaxSupportSamplesWebServiceValidation.WrapperClass")
   MsgBox o.GetZIPInfo("92806")

End Sub 

Compile and run the script to see the first city returned for the Zip Code via the Web Service.

Applies to:

Product Version
CAPTURE 10.0
  10.1
  10.2
  11.0
  • Was this article helpful?