Georgio
HttpRequest - What am I doing wrong!?!?! Help September 25, 2008 11:55PM |
bPageRet is boolean // Run a request on a secure server bPageRet = HTTPRequest("[zoasis.com];,... "IsFirstTime=true"+CR+"AccountNumber=XXXXX"+CR+"MainZip=90025"+CR+... "selectclinicbutton.x=38"+CR+"selectclinicbutton.y=3"+CR+"submit") // If an error occurs IF bPageRet = False THEN // evaluate the error SWITCH ErrorInfo(errCode) // Invalid certificate name CASE HTTPErrorInvalidCertificateName : //automatically ignore cert. HTTP.IgnoreError = HTTPIgnoreInvalidCertificateName // Re-run the request HTTPRequest("[zoasis.com];,... "IsFirstTime=true"+CR+"AccountNumber=XXXXX"+CR+"MainZip=90025"+CR+... "selectclinicbutton.x=38"+CR+"selectclinicbutton.y=3"+CR+"submit") EDT_Edit1 = HTTPGetResult() // Invalid or expired cert. CASE HTTPErrorExpiredCertificate : HTTP.IgnoreError = HTTPIgnoreExpiredCertificate // Re-run the request HTTPRequest("[zoasis.com];,... "IsFirstTime=true"+CR+"AccountNumber=XXXXX"+CR+"MainZip=90025"+CR+... "selectclinicbutton.x=38"+CR+"selectclinicbutton.y=3"+CR+"submit") END END
Piet van Zanten
Re: HttpRequest - What am I doing wrong!?!?! Help September 26, 2008 08:41AM |
PROCEDURE UrlEncode(_S) sRes is string //Possible : 32 45-46 48-57 65-90 95 97-122 bOk is boolean N is int C is int FOR C = 1 TO Length(_S) N = Asc(_S[[C]]) bOk = True SWITCH True CASE (N>=45) AND (N<=46) CASE (N>=48) AND (N<=57) CASE (N>=65) AND (N<=90) CASE (N=95) CASE (N>=97) AND (N<=122) OTHER CASE bOk = False END IF bOk THEN sRes += _S[[C]] ELSE IF (N=32) THEN sRes += "+" ELSE sRes += "%"+NumToString(N,"02X") END END END RESULT sResThe function filters out spaces and encodes unsafe ascii characters.
Alexandre Leclerc
Re: HttpRequest - What am I doing wrong!?!?! Help September 26, 2008 03:25PM |
Alexandre Leclerc
Re: HttpRequest - What am I doing wrong!?!?! Help September 26, 2008 03:37PM |
bPageRet = HTTPRequest("[zoasis.com] "AccountNumber=XXXXX"+CR+"MainZip=90025"+CR+"submit")
Georgio
Re: HttpRequest - What am I doing wrong!?!?! Help September 26, 2008 05:20PM |
Alexandre Leclerc
Re: HttpRequest - What am I doing wrong!?!?! Help September 26, 2008 05:58PM |
Georgio
Re: HttpRequest - What am I doing wrong!?!?! Help September 26, 2008 07:47PM |
Sohan
Re: HttpRequest - What am I doing wrong!?!?! Help September 27, 2008 05:20AM |
Georgio
Re: HttpRequest - What am I doing wrong!?!?! Help September 27, 2008 10:31PM |
Georgio
Re: HttpRequest - What am I doing wrong!?!?! Help September 28, 2008 01:58AM |
Sohan
Re: HttpRequest - What am I doing wrong!?!?! Help September 28, 2008 02:10AM |
Sohan
Re: HttpRequest - What am I doing wrong!?!?! Help September 28, 2008 05:45AM |
POST / HTTP/1.1 Content-Length: 60 Content-Type: application/x-www-form-urlencoded Accept: */* Host: localhost User-Agent: Connection: close IsFirstTime=true AccountNumber=XXXXX MainZip=90025 submit(Ignore the "localhost", it is because I am using tcptrace). As you can see, the word "submit" is simply copied into the body of the posted data (below the empty line). I would be surprised if this is correct. The documentation to HTTPRequest states that all input fields should be on a seperate line, and appended with "submit". I wonder if this is correct, since the word "submit" does not seem to be interpreted by Windev.
POST /control/selectclinic HTTP/1.1 Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/msword, application/x-silverlight, */* Referer: [zoasis.com] Accept-Language: nl Content-Type: application/x-www-form-urlencoded Accept-Encoding: gzip, deflate User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727) Host: zoasis.com Content-Length: 98 Connection: Keep-Alive Cache-Control: no-cache Cookie: JSESSIONID=LppZ1sDqzwyCGHP0JJ2f898db8295Y6nL4g1xPmqyx13q7ftFQJy!1632793846 IsFirstTime=false&AccountNumber=xxxxx&MainZip=90025&selectclinicbutton.x=37&selectclinicbutton.y=3First thing to notice is that the posted data is on a single line and does not contain the word "submit" (surprise surprise). Next thing is the cookie. Your browser has picked up a cookie somewhere and sends it along with every request. Your HTTPRequest() is failing because you did not supply it. Don't let the HTML page that comes along with it confuse you. It says: "Missing required field(s): Hospital Account Number, Hospital Zip Code" etc, but that's BS. It means that the cookie is missing. The browser received the cookie on first entry of the site/page. Keep in mind that if you approach the site through a browser, the POST request is the second request, not the first one. The first request is a simple GET of the main url, in this case "[zoasis.com];. This is where the cookie is set. You will have to focus on the header received, not the (html) result. The first header received is:
HTTP/1.1 200 OK Server: Sun-ONE-Web-Server/6.1 Date: Sun, 28 Sep 2008 01:32:09 GMT Content-Type: text/html; charset=UTF8 Set-Cookie: JSESSIONID=LppZ1sDqzwyCGHP0JJ2f898db8295Y6nL4g1xPmqyx13q7ftFQJy!1632793846; path=/ Transfer-encoding: chunkedThere is the cookie. As soon as you receive it, you must supply it with every request that you send. Next you can issue the POST request. Use the third parameter of HTTPRequest to send the cookie along with the request. Don't forget to append a CR to every 'additional HTTP header' that you send. When I do this I get the following response:
HTTP/1.1 200 OK Server: Sun-ONE-Web-Server/6.1 Date: Sun, 28 Sep 2008 01:41:52 GMT Content-Type: text/html; charset=UTF8 Set-Cookie: clinicId=null; expires=Thursday, 01-Jan-1970 01:00:00 GMT Set-Cookie: clinicZip=null; expires=Thursday, 01-Jan-1970 01:00:00 GMT Transfer-encoding: chunkedThe resulting HTML is the same as I see in my browser, so the request has succeeded. This is as far as I can go with it, since I do not have a valid account-id.
Georgio
Re: HttpRequest - What am I doing wrong!?!?! Help September 28, 2008 06:33PM |
Georgio
Re: HttpRequest - What am I doing wrong!?!?! Help September 28, 2008 06:41PM |
Roger Dunk
Re: HttpRequest - What am I doing wrong!?!?! Help September 29, 2008 01:54AM |
KenKnight
Re: HttpRequest - What am I doing wrong!?!?! Help September 29, 2008 03:33AM |
Georgio
Re: HttpRequest - What am I doing wrong!?!?! Help September 29, 2008 05:33PM |