Для полноты картины и полезности материала добавлю VB-код для работы с HTTP.
Процедура посылки готового XML-RPC запроса:
Private Sub callXMLRPC(url as String, request As String, ByRef xml As MSXML2.DOMDocument)
Dim http As New MSXML2.XMLHTTP
Call http.Open("POST", url, False)
Call http.send(request)
If http.Status <> 200 Then
Set http = Nothing
Call Err.Raise(1, , "Ошибка запроса на сервер XML-RPC.")
End If
Set xml = http.responseXML
Set http = Nothing
End Sub
Тестовый код, запрашивающий список в виде набора значений, где значение (n * 2) означает ключ, а (n * 2 + 1) - значение.
Private Sub loadSomeData(customerId as Long, ByRef items As Collection)
Dim url as String
Dim request As String
Dim xml As MSXML2.DOMDocument
Dim nodes As MSXML2.IXMLDOMNodeList
On Error Resume Next
url = "http://rpc-server/xml-rpc.php"
request = "<?xml version=""1.0""?>" + _
"<methodCall>" + _
"<methodName>csr.client.getSomeData</methodName>" + _
"<params>" + _
"<param>" + _
"<value><i4>" + CStr(customerId) + "</i4></value>" + _
"</param>" + _
"</params>" + _
"</methodCall>"
Set items = new Collection
Call callXMLRPC(request, xml)
If Err > 0 Then
Exit Sub
End If
Set nodes = xml.selectNodes("/methodResponse/params/param/value/array/data/value/string/text()")
If nodes.length() > 0 Then
Dim i As Long
Dim key As String
Dim value As String
For i = 0 To nodes.length - 1 Step 2
key = nodes(i).nodeValue
value = nodes(i + 1).nodeValue
Сall items.Add(value, key)
Next
End If
Set nodes = Nothing
Set xml = Nothing
End Sub
Вот такой XML ответ:
<?xml version="1.0" encoding="windows-1251"?>
<methodResponse>
<params>
<param>
<value>
<array>
<data>
<value>
<string>CUSTNR</string>
</value>
<value>
<string>.......</string>
</value>
<value>
<string>CONTRACTDATE</string>
</value>
<value>
<string>......</string>
</value>
<value>
<string>COUNTRY</string>
</value>
<value>
<string>Российская Федерация</string>
</value>
<value>
<string>FULLNAME</string>
</value>
<value>
<string>Открытое акционерное общество "............."</string>
</value>
<value>
<string>MANDATE_FOR_AKT</string>
</value>
<value>
<string/>
</value>
</data>
</array>
</value>
</param>
</params>
</methodResponse>