/*
 * Decompiled with CFR 0.152.
 * 
 * Could not load the following classes:
 *  org.apache.commons.httpclient.Header
 *  org.apache.commons.httpclient.HttpClient
 *  org.apache.commons.httpclient.HttpMethod
 *  org.apache.commons.httpclient.methods.PostMethod
 *  org.apache.commons.logging.Log
 *  org.apache.commons.logging.LogFactory
 */
package com.hst.taxService.service.imp;

import com.hst.common.util.HstJsonUtil;
import com.hst.taxService.domain.szrs.SzrsGzjsGridlbDomain;
import com.hst.taxService.domain.szrs.SzrsGzjsRequestDomain;
import com.hst.taxService.service.imp.TestPost;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.httpclient.Header;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpMethod;
import org.apache.commons.httpclient.methods.PostMethod;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class TestSzrs {
    public static Log _logger = LogFactory.getLog(TestSzrs.class);

    public static void main(String[] args) throws IOException {
        String url = "http://80.20.16.200:9999/taxService/service/taxSzrsCommon!doService";
        String charset = "GBK";
        HashMap<String, String> params = new HashMap<String, String>();
        params.put("domain.ywId", "SZRS.PubImport");
        String json = TestSzrs.gzjs();
        params.put("domain.parmJson", json);
        String str = TestPost.doPost(url, params, charset, true);
        System.out.println(str);
    }

    public static String gzjs() {
        String str = "";
        SzrsGzjsRequestDomain dom = new SzrsGzjsRequestDomain();
        dom.setUid("3455667ed");
        dom.setBid("SZRS.PubImport");
        dom.setSid("");
        dom.setVer("1.0");
        dom.setKz("0.00");
        dom.setSwryDm("13301911302");
        SzrsGzjsGridlbDomain vo = new SzrsGzjsGridlbDomain();
        vo.setSjtbrwXh("");
        vo.setSzrsRwlbDm("01");
        vo.setYwxh("");
        vo.setSzrsYwid("");
        dom.getDataList().add(vo);
        str = HstJsonUtil.beanCtreatJson(dom);
        return str;
    }

    public static String doPost(String url, Map<String, String> params, String charset, boolean pretty) {
        StringBuffer response;
        block10: {
            response = new StringBuffer();
            HttpClient client = new HttpClient();
            PostMethod post = new PostMethod(url);
            post.setRequestHeader(new Header("Content-type", "application/x-www-form-urlencoded;charset=utf-8"));
            post.setRequestHeader(new Header("User-Agent", "Mozilla/5.0 /Windows; U; Windows NT 4.1; de; rv:1.9.1.5) Gecko/20091102 Firefox/3.0"));
            if (params != null) {
                for (Map.Entry<String, String> entry : params.entrySet()) {
                    post.setParameter(entry.getKey(), entry.getValue());
                }
            }
            try {
                try {
                    client.executeMethod((HttpMethod)post);
                    if (post.getStatusCode() == 200) {
                        String line;
                        BufferedReader reader = new BufferedReader(new InputStreamReader(post.getResponseBodyAsStream(), charset));
                        while ((line = reader.readLine()) != null) {
                            if (pretty) {
                                response.append(line).append(System.getProperty("line.separator"));
                                continue;
                            }
                            response.append(line);
                        }
                        reader.close();
                    }
                }
                catch (IOException e) {
                    _logger.error((Object)("\u6267\u884cHTTP Post\u8bf7\u6c42" + url + "\u65f6\uff0c\u53d1\u751f\u5f02\u5e38\uff01"), (Throwable)e);
                    post.releaseConnection();
                    break block10;
                }
            }
            catch (Throwable throwable) {
                post.releaseConnection();
                throw throwable;
            }
            post.releaseConnection();
        }
        return response.toString();
    }
}
