VB projects - SOAP test
Description: sending test SOAP request to web service and displaying response
Minimum requirements: VB6
Download: source code
Screenshot:

Project: EXE
Controls: CommandButton cmdRequest, TextBox txtResponseHeaders (MultiLine = -1 'True, ScrollBars = 2 'Vertical), TextBox txtResponse (MultiLine = -1 'True, ScrollBars = 2 'Vertical)
Additional references: Microsoft XML, v3.0 (msxml3.dll)
Code:
Option Explicit
Private Sub cmdRequest_Click()
Dim o As New XMLHTTP
Dim s As String
On Error GoTo err_handler
s = s & "<?xml version=""1.0"" encoding=""UTF-8""?>" & vbCrLf
s = s & "<SOAP-ENV:Envelope" & vbCrLf
s = s & "SOAP-ENV:encodingStyle=""http://schemas.xmlsoap.org/soap/encoding/""" & vbCrLf
s = s & "xmlns:SOAP-ENC=""http://schemas.xmlsoap.org/soap/encoding/""" & vbCrLf
s = s & "xmlns:SOAP-ENV=""http://schemas.xmlsoap.org/soap/envelope/""" & vbCrLf
s = s & "xmlns:ns0=""capeconnect:GlobalWeather:GlobalWeather""" & vbCrLf
s = s & "xmlns:xsd=""http://www.w3.org/2001/XMLSchema""" & vbCrLf
s = s & "xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"">" & vbCrLf
s = s & "<SOAP-ENV:Body>" & vbCrLf
s = s & "<ns0:getWeatherReport>" & vbCrLf
s = s & "<code xsi:type=""xsd:string"">CYVR</code>" & vbCrLf
s = s & "</ns0:getWeatherReport>" & vbCrLf
s = s & "</SOAP-ENV:Body>" & vbCrLf
s = s & "</SOAP-ENV:Envelope>" & vbCrLf
o.open "POST", "http://live.capescience.com:80/ccx/GlobalWeather", False
o.setRequestHeader "Content-Type", "text/xml"
o.setRequestHeader "Connection", "close"
o.setRequestHeader "SOAPAction", ""
o.send s
txtResponseHeaders = o.getAllResponseHeaders
txtResponse = o.responseText
err_handler:
If Err.Number <> 0 Then MsgBox "Error " & Err.Number & ": " & Err.Description
End Sub
|