Hi, I have a website use redirect: the link is below:
https://eservice2.wsib.on.ca/b2bf7/Authentication?UserId=xxxx&Password=xxxx It suppose to return a NAK like: <?xml version="1.0" encoding="UTF-8" ?> - <wsibf:Response xmlns:wsib="http://www.wsib.on.ca" xmlns:wsibf=" http://www.wsib.on.ca/form" xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://www.wsib.on.ca/form Acknowledgement.xsd"> - <wsibf:NAK> - <wsibf:errors> <wsibf:errorCode>101</wsibf:errorCode> <wsibf:errorMessage>Invalid user id or password.</wsibf:errorMessage> </wsibf:errors> - <wsibf:timestamp> <wsib:date>20122007</wsib:date> <wsib:time>12:11:55</wsib:time> </wsibf:timestamp> </wsibf:NAK> </wsibf:Response> but when I tried it in my code: HttpClient client = new HttpClient(); client.getHostConfiguration().setHost(LOGON_SITE, LOGON_PORT, "https"); String userId ="userid"; String password="password"; String URL = "/b2bf7/Authentication"+"?"+USERID+EQUAL+userId+"&"+PASSWORD+EQUAL+password; PostMethod authpost = new PostMethod(URL); String redirectLocation=""; client.executeMethod(authpost); Header locationHeader = authpost.getResponseHeader("Location"); if (locationHeader != null) { redirectLocation = locationHeader.getValue(); System.out.println("redirectLocation = "+redirectLocation); } else { System.out.println("nothing found"); // The response is invalid and did not provide the new location for // the resource. Report an error or possibly handle the response // like a 404 Not Found error. } authpost.releaseConnection(); authpost = new PostMethod(redirectLocation); client.executeMethod(authpost); System.out.println("Login form post: " + authpost.getResponseBodyAsString()); } catch (HttpException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } authpost.releaseConnection(); it returns nothing, log looks like 2007/12/20 12:13:28:437 EST [DEBUG] HttpClient - Java version: 1.4.2 2007/12/20 12:13:28:437 EST [DEBUG] HttpClient - Java vendor: IBM Corporation 2007/12/20 12:13:28:437 EST [DEBUG] HttpClient - Java class path: C:\ESWworkspace\TestTool;C:\tmp\apache-commons\commons-logging-1.0.4\commons-logging-api.jar;C:\tmp\apache-commons\commons-logging-1.0.4\commons-logging.jar;C:\tmp\apache-commons\commons-codec-1.3\commons-codec-1.3.jar;C:\tmp\commons-httpclient-3.1-rc1\commons-httpclient-3.1-rc1.jar;C:\B2BForm7\lib\activation.jar;C:\B2BForm7\lib\asm.jar;C:\B2BForm7\lib\b2bform7_persist.jar;C:\B2BForm7\lib\cglib-2.1.jar;C:\B2BForm7\lib\com.ibm.mq.jar;C:\B2BForm7\lib\com.ibm.mq.pcf.jar;C:\B2BForm7\lib\commons-collections-2.1.1.jar;C:\B2BForm7\lib\commons-dbcp.jar;C:\B2BForm7\lib\commons-logging-1.1.jar;C:\B2BForm7\lib\commons-pool.jar;C:\B2BForm7\lib\connector.jar;C:\B2BForm7\lib\db2java.zip;C:\B2BForm7\lib\dom4j-1.6.jar;C:\B2BForm7\lib\eaas_1.2.jar;C:\B2BForm7\lib\ehcache-1.1.jar;C:\B2BForm7\lib\eims_framework_v2_3.jar;C:\B2BForm7\lib\hibernate3.jar;C:\B2BForm7\lib\jms.jar;C:\B2BForm7\lib\jta.jar;C:\B2BForm7\lib\log4j-1.2.11.jar;C:\B2BForm7\lib\mail.jar;C:\B2BForm7\lib\presister.jar;C:\B2BForm 7\lib\spring.jar;C:\tmp\ldapjdk41\packages\ldapjdk.jar 2007/12/20 12:13:28:437 EST [DEBUG] HttpClient - Operating system name: Windows XP 2007/12/20 12:13:28:437 EST [DEBUG] HttpClient - Operating system architecture: x86 2007/12/20 12:13:28:437 EST [DEBUG] HttpClient - Operating system version: 5.1 2007/12/20 12:13:28:927 EST [DEBUG] HttpClient - IBMJSSE 1.42: IBM JSSE provider 2007/12/20 12:13:28:927 EST [DEBUG] HttpClient - IBMJCE 1.2: IBMJCE Provider implements the following: HMAC-SHA1, MD2, MD5, MARS, SHA, MD2withRSA, MD5withRSA, SHA1withRSA, RSA, SHA1withDSA, RC2, RC4, Seal)implements the following: Signature algorithms : SHA1withDSA, SHA1withRSA, MD5withRSA, MD2withRSA Cipher algorithms : Blowfish, AES, DES, TripleDES, PBEWithMD2AndDES, PBEWithMD2AndTripleDES, PBEWithMD2AndRC2, PBEWithMD5AndDES, PBEWithMD5AndTripleDES, PBEWithMD5AndRC2, PBEWithSHA1AndDES PBEWithSHA1AndTripleDES, PBEWithSHA1AndRC2 PBEWithSHAAnd40BitRC2, PBEWithSHAAnd128BitRC2 PBEWithSHAAnd40BitRC4, PBEWithSHAAnd128BitRC4 PBEWithSHAAnd2KeyTripleDES, PBEWithSHAAnd3KeyTripleDES Mars, RC2, RC4, RSA, Seal Message authentication code (MAC) : HmacSHA1, HmacMD2, HmacMD5 Key agreement algorithm : DiffieHellman Key (pair) generator : Blowfish, DiffieHellman, DSA, AES, DES, TripleDES, HmacMD5, HmacSHA1, Mars, RC2, RC4, RSA, Seal Message digest : MD2, MD5, SHA-1, SHA-256, SHA-384, SHA-512 Algorithm parameter generator : DiffieHellman, DSA Algorithm parameter : Blowfish, DiffieHellman, AES, DES, TripleDES, DSA, Mars, PBEwithMD5AndDES, RC2 Key factory : DiffieHellman, DSA, RSA Secret key factory : Blowfish, AES, DES, TripleDES, Mars, RC2, RC4, Seal PKCS5Key, PBKDF1 and PBKDF2(PKCS5Derived Key). Certificate : X.509 Secure random : IBMSecureRandom Key store : JCEKS, PKCS12KS (PKCS12), JKS 2007/12/20 12:13:29:088 EST [DEBUG] HttpClient - IBMJGSSProvider 1.42: IBMJGSSProvider supports Kerberos V5 Mechanism 2007/12/20 12:13:29:088 EST [DEBUG] HttpClient - IBMCertPath 1.0: IBMCertPath Provider implements the following: CertificateFactory : X.509 CertPathValidator : PKIX CertStore : Collection, LDAP CertPathBuilder : PKIX 2007/12/20 12:13:29:088 EST [DEBUG] DefaultHttpParams - Set parameter http.useragent = Jakarta Commons-HttpClient/3.1-rc1 2007/12/20 12:13:29:098 EST [DEBUG] DefaultHttpParams - Set parameter http.protocol.version = HTTP/1.1 2007/12/20 12:13:29:098 EST [DEBUG] DefaultHttpParams - Set parameter http.connection-manager.class = class org.apache.commons.httpclient.SimpleHttpConnectionManager 2007/12/20 12:13:29:098 EST [DEBUG] DefaultHttpParams - Set parameter http.protocol.cookie-policy = default 2007/12/20 12:13:29:098 EST [DEBUG] DefaultHttpParams - Set parameter http.protocol.element-charset = US-ASCII 2007/12/20 12:13:29:098 EST [DEBUG] DefaultHttpParams - Set parameter http.protocol.content-charset = ISO-8859-1 2007/12/20 12:13:29:098 EST [DEBUG] DefaultHttpParams - Set parameter http.method.retry-handler = [EMAIL PROTECTED] 2007/12/20 12:13:29:098 EST [DEBUG] DefaultHttpParams - Set parameter http.dateparser.patterns = [EEE, dd MMM yyyy HH:mm:ss zzz, EEEE, dd-MMM-yy HH:mm:ss zzz, EEE MMM d HH:mm:ss yyyy, EEE, dd-MMM-yyyy HH:mm:ss z, EEE, dd-MMM-yyyy HH-mm-ss z, EEE, dd MMM yy HH:mm:ss z, EEE dd-MMM-yyyy HH:mm:ss z, EEE dd MMM yyyy HH:mm:ss z, EEE dd-MMM-yyyy HH-mm-ss z, EEE dd-MMM-yy HH:mm:ss z, EEE dd MMM yy HH:mm:ss z, EEE,dd-MMM-yy HH:mm:ss z, EEE,dd-MMM-yyyy HH:mm:ss z, EEE, dd-MM-yyyy HH:mm:ss z] 2007/12/20 12:13:29:148 EST [DEBUG] HttpConnection - Open connection to eservices2.wsib.on.ca:443 2007/12/20 12:13:31:351 EST [DEBUG] header - >> "POST /b2bf7/Authentication?UserId=userid&Password=password HTTP/1.1[\r][\n]" 2007/12/20 12:13:31:351 EST [DEBUG] HttpMethodBase - Adding Host request header 2007/12/20 12:13:31:371 EST [DEBUG] header - >> "User-Agent: Jakarta Commons-HttpClient/3.1-rc1[\r][\n]" 2007/12/20 12:13:31:371 EST [DEBUG] header - >> "Host: eservices2.wsib.on.ca[\r][\n]" 2007/12/20 12:13:31:371 EST [DEBUG] header - >> "Content-Length: 0[\r][\n]" 2007/12/20 12:13:31:371 EST [DEBUG] header - >> "[\r][\n]" 2007/12/20 12:13:31:371 EST [DEBUG] EntityEnclosingMethod - Request body has not been specified 2007/12/20 12:13:31:511 EST [DEBUG] header - << "HTTP/1.0 301 Moved Permanently[\r][\n]" 2007/12/20 12:13:31:511 EST [DEBUG] header - << "Location: https://eservices2.wsib.on.ca/error-UAT.htm[\r][\n]" 2007/12/20 12:13:31:511 EST [DEBUG] header - << "Content-Length: 0[\r][\n]" 2007/12/20 12:13:31:511 EST [DEBUG] header - << "Connection: close[\r][\n]" 2007/12/20 12:13:31:511 EST [DEBUG] HttpMethodDirector - Redirect required 2007/12/20 12:13:31:521 EST [DEBUG] HttpMethodBase - Should close connection in response to directive: close redirectLocation = https://eservices2.wsib.on.ca/error-UAT.htm 2007/12/20 12:13:31:521 EST [DEBUG] HttpConnection - Releasing connection back to connection manager. 2007/12/20 12:13:31:521 EST [DEBUG] HttpConnection - Open connection to eservices2.wsib.on.ca:443 2007/12/20 12:13:31:521 EST [DEBUG] header - >> "POST /error-UAT.htm HTTP/1.1[\r][\n]" 2007/12/20 12:13:31:521 EST [DEBUG] HttpMethodBase - Adding Host request header 2007/12/20 12:13:31:521 EST [DEBUG] header - >> "User-Agent: Jakarta Commons-HttpClient/3.1-rc1[\r][\n]" 2007/12/20 12:13:31:521 EST [DEBUG] header - >> "Host: eservices2.wsib.on.ca[\r][\n]" 2007/12/20 12:13:31:521 EST [DEBUG] header - >> "Content-Length: 0[\r][\n]" 2007/12/20 12:13:31:521 EST [DEBUG] header - >> "[\r][\n]" 2007/12/20 12:13:31:521 EST [DEBUG] EntityEnclosingMethod - Request body has not been specified 2007/12/20 12:13:31:561 EST [DEBUG] header - << "HTTP/1.0 301 Moved Permanently[\r][\n]" 2007/12/20 12:13:31:571 EST [DEBUG] header - << "Location: https://eservices2.wsib.on.ca/error-UAT.htm[\r][\n]" 2007/12/20 12:13:31:571 EST [DEBUG] header - << "Content-Length: 0[\r][\n]" 2007/12/20 12:13:31:571 EST [DEBUG] header - << "Connection: close[\r][\n]" 2007/12/20 12:13:31:571 EST [DEBUG] HttpMethodDirector - Redirect required 2007/12/20 12:13:31:571 EST [DEBUG] HttpMethodBase - Buffering response body 2007/12/20 12:13:31:571 EST [DEBUG] HttpMethodBase - Should close connection in response to directive: close 2007/12/20 12:13:31:571 EST [DEBUG] HttpConnection - Releasing connection back to connection manager. 2007/12/20 12:13:31:571 EST [DEBUG] HttpMethodBase - Default charset used: ISO-8859-1 Login form post: Thanks. Jacky Liu Specialist, MiddleWare Development Enterprise Integration & Middleware Services Business Technology Services Workplace Safety & Insurance Board of Ontario (WSIB) Tel:(416)344-4732 Email: [EMAIL PROTECTED] ********************************************************************* The information in this e-mail is intended solely for the addressee(s) named, and is confidential. Any other distribution, disclosure or copying is strictly prohibited. If you have received this communication in error, please reply by e-mail to the sender and delete or destroy all copies of this message. Les renseignements contenus dans le pr'esent message 'electronique sont confidentiels et concernent exclusivement le(s) destinataire(s) 'esign'e(s). Il est strictement interdit de distribuer ou de copier ce message. Si vous avez recu ce message par erreur, veuillez r'epondre par courriel `a l'exp'editeur et effacer ou d'etruire toutes les copies du pr'esent message..
