Link to home
Start Free TrialLog in
Avatar of gismanager
gismanager

asked on

How to Parse http.ResponseText returned from Web service

I have written a web service with a number of different functions.  One of thes functions returns an ArrayOfString.  I am in process of writing code that access this web service.  The only part I am having trouble with is how to access (parse out) the array elements from the response text or how to assign the ResponseText to an Array.  I am attaching snipet from my web service (The function in question) and a snipet from my vba client that calls the service and receives the ResponseText.  I also attached a text file of the ResponseText.


'################################################################
    '# This Funtion returns string array of road segment that 
    '# matchs Street Name, Type and Location City Zip and with range
    '################################################################

    <WebMethod(Description:="Returns true or false if it finds matching street segment", EnableSession:=False)> _
    Public Function GetArray_StreetSegment(ByVal strHnum As String, ByVal strPreDir As String, ByVal strName As String, ByVal strType As String, ByVal strcity As String, ByVal strzip As String) As String()
        Dim RetVal(10) As String
        Dim sqlCommand As String
 
        Dim strSQLcommand As String

        '-- Build the SQL command'

        strSQLcommand = "Select OBJECTID, L_F_ADD,L_T_ADD, R_F_ADD, R_T_ADD, predir, stname, sttype, locationcity, zip  from " & MyTable & " Where (("

        If strPreDir = "" Then
            strSQLcommand = strSQLcommand & "(predir = '' or predir is null)"
        Else
            strSQLcommand = strSQLcommand & "predir ='" & strPreDir & "'"
        End If
        strSQLcommand = strSQLcommand & " And StName ='" & strName & "'"

        If strType = "" Then
            strSQLcommand = strSQLcommand & " And (stType ='' or stType is null)"
        Else
            strSQLcommand = strSQLcommand & " And sttype ='" & strType & "'"
        End If
        strSQLcommand = strSQLcommand & " And LocationCity ='" & strcity & "'"
        strSQLcommand = strSQLcommand & " And Zip ='" & strzip & "') "
        strSQLcommand = strSQLcommand & " And (((L_F_ADD >=" & strHnum & " AND L_T_ADD <=" & strHnum & ")" & _
            " Or (L_F_ADD <=" & strHnum & " AND L_T_ADD >=" & strHnum & ")) Or " & _
            " ((R_F_ADD >= " & strHnum & " and R_T_ADD <= " & strHnum & ") Or  " & _
            " (R_F_ADD <= " & strHnum & "  and R_T_ADD >= " & strHnum & "))))"


        sqlCommand = strSQLcommand

        ' The data referenced is accessed through a MultiVersioned View (ESRI SDE terminology)

        Dim VersionCommand1 As New SqlCommand("sde.set_current_version", connection)
        VersionCommand1.CommandType = CommandType.StoredProcedure
        VersionCommand1.Parameters.Add("@version_name", NVarChar, 25)
        VersionCommand1.Parameters("@version_name").Value = MyVersion
        connection.Open()
        VersionCommand1.ExecuteNonQuery()

        Dim adapter As SqlDataAdapter = New SqlDataAdapter(sqlCommand, connection)
        Dim custDS As DataSet = New DataSet()

        adapter.MissingSchemaAction = MissingSchemaAction.AddWithKey
        adapter.Fill(custDS, MyTable)
        '-- Should only be one record that matches if any so only look at 0
        If custDS.Tables(0).Rows.Count > 0 Then
            RetVal(0) = custDS.Tables(0).Rows(0).Item(0).ToString
            RetVal(1) = custDS.Tables(0).Rows(0).Item(1).ToString
            RetVal(2) = custDS.Tables(0).Rows(0).Item(2).ToString
            RetVal(3) = custDS.Tables(0).Rows(0).Item(3).ToString
            RetVal(4) = custDS.Tables(0).Rows(0).Item(4).ToString
            RetVal(5) = custDS.Tables(0).Rows(0).Item(5).ToString
            RetVal(6) = custDS.Tables(0).Rows(0).Item(6).ToString
            RetVal(7) = custDS.Tables(0).Rows(0).Item(7).ToString
            RetVal(8) = custDS.Tables(0).Rows(0).Item(8).ToString
            RetVal(9) = custDS.Tables(0).Rows(0).Item(9).ToString
        Else
            RetVal(0) = "False"
        End If

        Return RetVal

    End Function

Open in new window

Webservice-Responsel.txt
Avatar of CSecurity
CSecurity
Flag of Iran, Islamic Republic of image

ASKER CERTIFIED SOLUTION
Avatar of gismanager
gismanager

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Why VBScript? Could you do it in JavaScript, there is a lot of Javascript XML parsers out there. Try Googling, VBScript XML Parser, you'll find some samples, but you need to modify them to fit your needs. Like:
http://forum.videohelp.com/topic304523.html
http://forums.devx.com/archive/index.php/t-3442.html
http://www.visualbasicscript.com/m57661.aspx

and...
Avatar of gismanager
gismanager

ASKER

Must be VB for applications because it is being called within the ArcGIS application.