vba, мыло webservice неполный ответ - PullRequest
0 голосов
/ 06 октября 2018

Я пытаюсь получить большие данные о фондовом рынке по запросу конверта мыла 1.1, структура веб-сервиса объяснена в этой ссылке: http://service.tsetmc.com/WebService/TsePublicV2.asmx?op=BestLimitsAllIns

это мой код:

sub downloaddata()    
Dim Url As String
Url = "http://service.tsetmc.com/WebService/TsePublicV2.asmx"
Dim fldr As String
fldr = "C:\Users\daily\"
'init variable values
Dim Response As String
'Build the HTTP Request object
Dim ObjHttp As New MSXML2.XmlHttp
'build soap envelope for fetching header
Dim sEnv As String
sEnv = "<?xml version=" & """" & "1.0" & """" & " encoding=" & """" & "utf-8" & """" & "?>"
sEnv = sEnv & "<soap:Envelope xmlns:xsi=" & """" & "http://www.w3.org/2001/XMLSchema-instance" & """" & " xmlns:xsd=" & """" & "http://www.w3.org/2001/XMLSchema" & """" & " xmlns:soap=" & """" & "http://schemas.xmlsoap.org/soap/envelope/" & """" & ">"
sEnv = sEnv & "<soap:Body>"
sEnv = sEnv & "<BestLimitsAllIns xmlns=" & """" & "http://tsetmc.com/" & """" & ">"
sEnv = sEnv & "<UserName>" & """" & "username" & """" & "</UserName>"
sEnv = sEnv & "<Password>" & """" & "password" & """" & "</Password>"
sEnv = sEnv & "<Flow>" & "0" & " </Flow>"
sEnv = sEnv & "</BestLimitsAllIns>"
sEnv = sEnv & "</soap:Body>"
sEnv = sEnv & "</soap:Envelope>" 
'wrap the http request in a with statement
With ObjHttp
    .Open "post", Url, False
    .setRequestHeader "Host", "service.tsetmc.com"
    .setRequestHeader "Content-Type", "text/xml; charset=utf-8"
    .setRequestHeader "Content-Length", Len(sEnv)
    .setRequestHeader "SOAPAction", "http://tsetmc.com/BestLimitsAllIns"
    .send sEnv
    Response = ObjHttp.responseText
    Debug.Print "111111111111111111111111"
    Debug.Print .getAllResponseHeaders
    Debug.Print .responseText
    Debug.Print .Status
    Debug.Print .statusText
End With
Dim XDoc As MSXML2.DOMDocument
Dim xEmpDetails As MSXML2.IXMLDOMNode
Dim xParent As MSXML2.IXMLDOMNode
Dim xChild As MSXML2.IXMLDOMNode
Dim Col, Row As Integer
Set XDoc = New MSXML2.DOMDocument
XDoc.async = False
XDoc.validateOnParse = False
If Not XDoc.LoadXML(Response) Then  'strXML is the string with XML'
    Err.Raise XDoc.parseError.ErrorCode, , XDoc.parseError.reason
End If
XDoc.LoadXML (Response)
Set xEmpDetails = XDoc.DocumentElement
Set xParent = xEmpDetails.FirstChild
Row = 2
Col = 1
For Each xParent In xEmpDetails.ChildNodes
    For Each xChild In xParent.ChildNodes
        ThisWorkbook.Worksheets("a").Cells(Row, Col).Value = xChild.Text
        Col = Col + 1
    Next xChild
    Row = Row + 1
    Col = 1
Next xParent
End Sub

ответ должен быть таким:

HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
    <BestLimitsAllInsResponse xmlns="http://tsetmc.com/
    <BestLimitsAllInsResult>
        <xsd:schema>schema(real content will be replaced) 
        </xsd:schema>xml(real content will be replaced
        </BestLimitsAllInsResult>
    </BestLimitsAllInsResponse>
</soap:Body>
</soap:Envelope>

, но реальный ответ, который я дал, является лишь частью выборки, а основные данные не показали:

Cache-Control: private, max-age=0
Content-Length: 301
Content-Type: text/xml; charset=utf-8
Server: Microsoft-IIS/7.5
X-Powered-By: ASP.NET
Date: Sat, 06 Oct 2018 05:23:47 GMT
Connection: keep-alive
<?xml version="1.0" encoding="utf-8"?><soap:Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body
<BestLimitsAllInsResponse xmlns="http://tsetmc.com/" /></soap:Body>
</soap:Envelope>
200 
OK

ответнеполный, основные данные в 4 строке выше отсутствуют.Я не знаю, почему я не могу отладить проблему.пожалуйста, проверьте это и помогите мне.спасибо

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...