Executing a SOAP Request from Access 2007

I am currently working on a system in Microsoft Access 2007, and I need to make a SOAP request to an external web server to get some data. I'm new to SOAP and Visual Basic, and I'm having trouble figuring out what I need to do to make this SOAP request.

Of some of the posts on Google, it looks like previous versions of Access might need the Microsoft SOAP Toolkit to make a SOAP request. However, as far as I can tell, the SOAP Toolkit has been deprecated a few years ago, so I'm sure that is not what I want. Do I need to load an external library to call SOAP? If so, which one? If not, what VB syntax is used to invoke SOAP from an Access 2007 file?

+3
source share
2 answers

I don't know if there is a better way than doing this through VBA, using a low-level Http POST to send the SOAP message to the server. You will have to process the XML-SOAP message in any way you choose. Here is an example function for doing Http POST in VBA.

Function doHttpPost(request As String) As String

    Dim response As String
    Dim http As WinHttp.WinHttpRequest
    Set http = New WinHttp.WinHttpRequest

    On Error GoTo doPostError

    http.setTimeouts 30000, 30000, 30000, 300000

    http.Open "POST", "http://someserver.com/soapListener", False
    http.setRequestHeader "name", "value" 'set any headers you want'

    http.send request

    If http.Status <> 200 Then
        MsgBox "An error has occurred with your request. " & vbCrLf & "The error message is: " & http.responseText & vbCrLf & http.Status & " " & http.statusText
        Exit Function
    End If

    doHttpPost = http.responseText
    Exit Function

doPostError:
    'process error messages here'

End Function
+2
source

You should use your favorite .NET language to create a COM component that Access can invoke. This component must use standard .NET mechanisms (Add Service Link) to make calls to the web service.

In no case should you use the SOAP Toolkit, which is very outdated.

+1
source

Source: https://habr.com/ru/post/1765887/


All Articles