Excel vba and XMLHTTP with ADFS - not returning xml -


i have excel macro has been in use years posts database using xmlhttp call. code digitally signed.

recently site being posted has enabled adfs. instead of getting xml contents of adfs authentication form. there no prompt credentials in since authentication occurred. open url web browser goes through expected existing credentials used , page loaded.

i tried setting trusted setting url , allowed external content didn't matter.

have missed something?

the html looks like...

<html><head><title>working...</title></head><body><form method="post" name="hiddenform" action="https://isvcci.jttest.com:444/"><input type="hidden" name="wa" value="wsignin1.0" /> ... <noscript><p>script disabled. click submit continue.</p><input type="submit" value="submit" /></noscript></form><script language="javascript">window.settimeout('document.forms[0].submit()', 0);</script></body></html> 

this vba:

sub postxml(strtype string, straddress string, objxml msxml2.domdocument60)     dim objhttp msxml2.xmlhttp60, objxmlresponse msxml2.domdocument60, objnode msxml2.ixmldomnode     dim strtext string     set objhttp = new msxml2.xmlhttp60      objhttp.open "post", straddress, false     objhttp.setrequestheader "content-type", "text/xml; charset=utf-8"      objhttp.send objxml     set objxmlresponse = objhttp.responsexml     rem responsexml empty responsetext has adfs page <------     set objnode = objxmlresponse.selectsinglenode("root/errormessage")     if objnode nothing         msgbox "error: unable retrieve expected response server." + vbcrlf + "the opportunity may not have been updated."     else     ... code success goes here     end if end sub 

thanks assistance!

xmlhttp wouldn't work on adfs used internetexplorer control instead. it's hassle resulting xml though using page sets form value simpler. resulting xml gets returned formatted see in web browser. use simple regex remove dashes outside of tags.

i'm not experienced vba , excel there might better ways code works.

sub postxml(strtype string, straddress string, objxml msxml2.domdocument60)     dim objhttp msxml2.xmlhttp60, objxmlresponse msxml2.domdocument60, objnode msxml2.ixmldomnode     dim objdoc mshtml.htmldocument     dim strtext string, strheaders string, strpostdata string     dim mybrowser internetexplorer     dim postdata() byte     dim expr vbscript_regexp_55.regexp     dim colmatch vbscript_regexp_55.matchcollection     dim vbsmatch vbscript_regexp_55.match     dim smatchstring string      ' xmlhttp doesn't work adfs browser used      set mybrowser = new internetexplorer     strheaders = "content-type: text/xml; charset=utf-8" & vbcrlf     postdata = strconv(objxml.xml, vbfromunicode)     mybrowser.visible = false     mybrowser.navigate straddress, 0, "", postdata, strheaders     while mybrowser.busy or mybrowser.readystate <> 4     loop     set objdoc = mybrowser.document     strtext = objdoc.body.innertext     set expr = new vbscript_regexp_55.regexp     expr.pattern = "(?:\s|&nbsp;|^)(-)(?=\s|\r|\n|$)"     expr.ignorecase = true     expr.multiline = true     expr.global = true     strtext = expr.replace(strtext, "")      set objxmlresponse = new msxml2.domdocument60     set objnode = nothing     if objxmlresponse.loadxml(strtext)        set objnode = objxmlresponse.selectsinglenode("root/errormessage")     'else        'msgbox "invalid xml " & objxmlresponse.parseerror.errorcode & "," & objxmlresponse.parseerror.reason     end if     mybrowser.quit     set mybrowser = nothing      rem msgbox "response =" & vbcrlf & objxmlresponse.xml      if objnode nothing         msgbox "error: unable retrieve expected response server."     else         strtext = objnode.text         if strtext > ""             msgbox strtext, vbokonly, "error"         else             ' worked, read xml here         end if     end if end sub 

Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -