hi
There is a secure site:
https://farm3.sat.gob.gt/saqbe-arancel-publico/aduana/arancel/consulta/consulta.jsf
After the landing page is retrieved, just provide 01 in Posición arancelaria text field and click on buscar. I am able to retrive this page via httpunit api. but after that CLASIFICACIÓN ARANCELARIA page... on clicking of 0101.10.90, i m not able to retrieve that page via
Java code.
Please help me asap.
I have tried the following way to retrieve data:
1) Setting parameters into WebRequest:
//Retrieving webForm from the response of landed page secured site:
WebForm webForm = response.getFormWithID("formar");
//Then retrieve the request from the webForm and setting all relevant parameters associated with particular hsCodes:
WebRequest req = webForm.getRequest();
req.setParameter("formar_SUBMIT","1");
req.setParameter("jsf_sequence","3");
req.setParameter("formar:_link_hidden_","");
req.setParameter("pCodigo","01019000");
req.setParameter("formar:_idcl","formar:tree:0:0:1:parter2");
WebResponse resp = webForm.submit();
But we have redirected again to the same landing page from which we want to retrieve subsequent page for a HsCode.
We have also tested it after setting the following properties :
ClientProperties props = webConversation.getClientProperties();
props.setUserAgent("Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7");
props.setAcceptCookies(true);
props.setAutoRedirect(false);
props.setAutoRefresh(false);
But still we are not able to achieve desired response.
2) Retrieving data via WebLink:
//Retrieve link from response for a particular hsCode
WebLink link = response.getLinkWith("0101.10.10");
//Get the webrequest for a particular link.
WebRequest req = link.getRequest();
//Now webConversation API must return the response.
WebResponse resp = webConversation.getResponse(req);
But the response don't contain the subsequent page associated with particular HsCode.
3)Setting Request headers with Session fields and other parameters:
At first We Retrieve HeaderFields from rquest and response in java code and comparing these fields to HttpAnalyzer header fields.
Now setting the parameters which are alike or don't exist in request.
req.setHeaderField("ORA_WX_SESSION", "10.1.0.34:47873-2#3");
req.setHeaderField("Keep-Alive","300");
req.setHeaderField("Connection","keep-alive");
req.setHeaderField("JSESSIONID", "0a01002230d7760c3064f5d54d71b35e84bd606926fc.e3aOaNuPbhiQe3uMc3mPbNaRbO0");
But still the same response has been retrieved.
4)Using HttpsURLConnection:
We have opened a Url connection and then retrieving response
HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
connection.setDoInput(true);
connection.setDoOutput(true);
String response = showText(con.getInputStream());
Via this way we are able to retrieve response for the landing page, but for subsequent pages its still a challenge to retrieve data.
We have also tried with setting some other options with HttpsURLConnection like as the example in following link:
http://www.java-samples.com/java/POST-toHTTPS-url-free-java-sample-program.htm
System.setProperty("java.protocol.handler.pkgs","com.sun.net.ssl.internal.www.protocol");
java.security.Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
SSLSocketFactory factory = (SSLSocketFactory) SSLSocketFactory.getDefault();
connection.setSSLSocketFactory(factory);
connection.setFollowRedirects(true);
5)Using HttpClient:
HttpClient client = new HttpClient();
HttpMethod method = new PostMethod("https://farm3.sat.gob.gt/saqbe-arancel-publico/aduana/arancel/consulta/consulta.jsf");
client.executeMethod(method);
byte[] body = method.getResponseBody();
InputStream is = new ByteArrayInputStream(body);
String resp = showText(is);
method.releaseConnection();
6) Using SSL implementation:
As per the Url describes
http://httpunit.sourceforge.net/doc/sslfaq.html
We have downloaded the JSSE package from the Sun URL and placed the key jar files into JVM ext directory, and updated java.security file
and then we have used all the options described above, but still the same story has been repeated.
7)Using HttpAnalyzer:
We have also used HttpAnalyzer and some other tools also to analyze the web content but HttpAnalyzer is not able to trace data when Url connection has been done via eclipse for a secured site.
So still its remaining a challenge for retrieval of tariff data for GT.