Developer Forum [ All Topics | New Topic ]

Thread: SOAP XML in VBA

Hi,

I am trying to get the ticket through login with VBA excel. HOwever I always get a bad connect. You can see it in the msgbox. I picked up the code on this Forum.

Am I missing something here???

Thanks

Francois

CODE>
Sub GetRapLogin()

    Dim sURL As String
    Dim sEnv As String
    Dim strUser, strPWD As String
    Dim xmlHttp As New MSXML2.ServerXMLHTTP
    Dim xmlDoc As New DOMDocument
    Dim strLength As Integer
   
    sURL = "https://technet.rapaport.com/HTTP/Authenticate.aspx"
   
    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 & " <Login xmlns=""http://technet.rapaport.com/""> "
    sEnv = sEnv & " <Username>myusername</Username> "
    sEnv = sEnv & " <Password>mypasswd</Password>"
    sEnv = sEnv & " </Login> "
    sEnv = sEnv & " </soap:Body>"
    sEnv = sEnv & "</soap:Envelope>"
        
    strLength = Len(sEnv)
   
    MsgBox sEnv
   
   
     
    With xmlHttp
      .Open "POST", sURL, False
        .setRequestHeader "Host", "technet.rapaport.com"
        .setRequestHeader "Content-Type", "text/xml; charset=utf-8"
        .setRequestHeader "Content-length", strLength
        .setRequestHeader "SOAPAction", "http://technet.rapaport.com/Login"
   
        .send sEnv
        xmlDoc.LoadXML .responseText
             
        MsgBox .responseText
    End With
     xmlDoc.Save ThisWorkbook.Path & "\WebQueryResult.xml"
  


End Sub


>> add a comment
Francois
07/22/2013 10:22


0 Replies: