excel - SOAP through VBA -
i attempting pull info following site pulls: http://gis.calhouncounty.org/parcelviewer/index.html. if type in ppin 66078 , click property taxes, bring data. attempting recreate soap request in vba, unsuccessfully. calls service, data in response blank. got frustrated recreated full header set, no avail. maybe there cookie issue, cookies on computer don't seem expire quickly. here's have in extract:
url = "http://gis.calhouncounty.org/wscalhounparcel2/inquiry.asmx?wsdl" method = "gettaxbill" parcel = range("a" & currentrow).value soaprequest = soaprequest & "<?xml version=""1.0"" encoding=""utf-8""?><soap:envelope xmlns:soap=""http://schemas.xmlsoap.org/soap/envelope/"" xmlns:xsd=""http://www.w3.org/2001/xmlschema"" xmlns:xsi=""http://www.w3.org/2001/xmlschema-instance""> " soaprequest = soaprequest & "<soap:body>" soaprequest = soaprequest & "<tns:" & method & " xmlns:tns=""http://gis.calhouncounty.org"">" soaprequest = soaprequest & "<tns:ppin>" & parcel & "</tns:ppin>" soaprequest = soaprequest & "</tns:" & method & ">" soaprequest = soaprequest & "</soap:body>" soaprequest = soaprequest & "</soap:envelope>" set objhttp = createobject("msxml2.xmlhttp") objhttp.open "post", url, false objhttp.setrequestheader "host", "gis.calhouncounty.org" objhttp.setrequestheader "connection", "keep-alive" objhttp.setrequestheader "content-length", soaprequestlen objhttp.setrequestheader "origin", "http://gis.calhouncounty.org" objhttp.setrequestheader "x-requested-with", "shockwaveflash/17.0.0.169" objhttp.setrequestheader "soapaction", "http://gis.calhouncounty.org/" & method objhttp.setrequestheader "user-agent", "mozilla/5.0 (windows nt 6.1; wow64) applewebkit/537.36 (khtml, gecko) chrome/42.0.2311.90 safari/537.36" objhttp.setrequestheader "content-type", "text/xml; charset=utf-8" objhttp.setrequestheader "accept", "*/*" objhttp.setrequestheader "referer", "http://gis.calhouncounty.org/parcelviewer" objhttp.setrequestheader "accept-encoding", "gzip, deflate" objhttp.setrequestheader "accept-language", "en-us,en;q=0.8" objhttp.setrequestheader "cookie", "aspsessionidaabarsab=diijlagcfjkdfkbcdnmmleib; aspsessionidaaacqsba=bkajpfcdcajlbakffbacbmgc; aspsessionidcccbrtba=dkjpbapdnlifbojgcpedmahg; __utma=262294995.1570768928.1429018531.1429018531.1430173329.2; __utmc=262294995; __utmz=262294995.1430173329.2.2.utmcsr=google|utmccn=(organic)|utmcmd=organic|utmctr=(not%20provided); aspsessionidaqtratab=ohcbmbmcnalfkocoddmiahia; _ga=ga1.2.90452212.1429018592; __utmt=1; __utma=167846455.90452212.1429018592.1430173349.1430248358.4; __utmb=167846455.1.10.1430248358; __utmc=167846455; __utmz=167846455.1430173349.3.3.utmcsr=google|utmccn=(organic)|utmcmd=organic|utmctr=(not%20provided)" objhttp.send soaprequest any incredibly appreciated! -andy
you not error checking. adapt following error checking code. err.number, err.description, err.source, file.status, file.statustext, file.getallresponseheaders.
the url has 100% correct. unlike browser there no code fix urls.
the purpose of program error details.
how correct url type url in browser, navigate, , correct url in address bar. other way use properties of link etc url.
also microsoft.xmlhttp maps microsoft.xmlhttp.1.0. hkey_classes_root\msxml2.xmlhttp maps msxml2.xmlhttp.3.0. try later one
try way using xmlhttp. edit url's etc. if seems work comment out if / end if dump info if seeming work. it's vbscript vbscript works in vb6.
on error resume next set file = wscript.createobject("microsoft.xmlhttp") file.open "get", "http://www.microsoft.com/en-au/default.aspx", false 'this ie 8 headers file.setrequestheader "user-agent", "mozilla/4.0 (compatible; msie 8.0; windows nt 6.0; trident/4.0; slcc1; .net clr 2.0.50727; media center pc 5.0; .net clr 1.1.4322; .net clr 3.5.30729; .net clr 3.0.30618; .net4.0c; .net4.0e; bcd2000; bcd2000)" file.send if err.number <> 0 line ="" line = line & vbcrlf & "" line = line & vbcrlf & "error getting file" line = line & vbcrlf & "==================" line = line & vbcrlf & "" line = line & vbcrlf & "error " & err.number & "(0x" & hex(err.number) & ") " & err.description line = line & vbcrlf & "source " & err.source line = line & vbcrlf & "" line = line & vbcrlf & "http error " & file.status & " " & file.statustext line = line & vbcrlf & file.getallresponseheaders wscript.echo line err.clear wscript.quit end if on error goto 0 set bs = createobject("adodb.stream") bs.type = 1 bs.open bs.write file.responsebody bs.savetofile "c:\users\test.txt", 2 also see if these other objects work.
c:\users>reg query hkcr /f xmlhttp hkey_classes_root\microsoft.xmlhttp hkey_classes_root\microsoft.xmlhttp.1.0 hkey_classes_root\msxml2.serverxmlhttp hkey_classes_root\msxml2.serverxmlhttp.3.0 hkey_classes_root\msxml2.serverxmlhttp.4.0 hkey_classes_root\msxml2.serverxmlhttp.5.0 hkey_classes_root\msxml2.serverxmlhttp.6.0 hkey_classes_root\msxml2.xmlhttp hkey_classes_root\msxml2.xmlhttp.3.0 hkey_classes_root\msxml2.xmlhttp.4.0 hkey_classes_root\msxml2.xmlhttp.5.0 hkey_classes_root\msxml2.xmlhttp.6.0 end of search: 12 match(es) found. also aware there limit on how many times can call particular xmlhttp object before lockout occurs. if happens, , when debugging code, change different xmlhttp object
i running code.
--------------------------- windows script host --------------------------- error 0(0x0) source http error 200 ok date: tue, 28 apr 2015 21:56:46 gmt server: microsoft-iis/7.5 cache-control: private, max-age=0 content-type: text/xml; charset=utf-8 x-aspnet-version: 2.0.50727 x-powered-by: asp.net access-control-allow-origin: * keep-alive: timeout=5, max=100 connection: keep-alive --------------------------- ok --------------------------- then msgbox out responsebody , have data sending cat rather what's in spreadsheet.
Comments
Post a Comment