/*
 * 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 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 TestNsfw {
    public static Log _logger = LogFactory.getLog(TestNsfw.class);

    public static void main(String[] args) throws IOException, InstantiationException, IllegalAccessException {
        String url = "http://smrz.zjtax.gov.cn:8082/taxService/service/taxNsfwCommonApp!doService";
        String charset = "GBK";
        HashMap<String, String> params = new HashMap<String, String>();
        params.put("domain.ywId", "nsfw.saveeva");
        params.put("domain.ywId", "nsfw.savebiz");
        params.put("domain.ywId", "nsfw.jhxtGetYyxxZw");
        params.put("domain.ywId", "nsfw.saveticket");
        params.put("domain.ParmJson", "{\"uid\":\"\",\"bid\":\"nsfw.savebiz\",\"ID\":\"1\",\"sid\":\"\",\"kz\":\"\",\"ver\":\"\",\"govhallid\":\"133050001\",\"bizid\":\"1\",\"Ticket\":null,\"Idcard\":null,\"Evatime\":null,\"Createtime\":null,\"Calltime\":null,\"Acccode\":null,\"Counterid\":null,\"Evaid\":null,\"Finishtime\":null,\"State\":null,\"Accname\":null,\"Bizname\":\"\u6d4b\u8bd5\u6570\u636e\u554a\",\"yxbz\":\"Y\"}");
        params.put("domain.ParmJson", "{\"uid\":\"ea16224e51\",\"bid\":\"nsfw.saveticket\",\"ID\":\"22333\",\"sid\":\"\",\"kz\":\"\",\"ver\":\"1.0\",evaid:\"1\",govhallid:\"133110001\",govhallname:\"sss\",bizid:\"02\",Ticket:\"1079\",Idcard:\"0\",Evatime:\"null\",Createtime:\"2018-04-24 18:03:00\",Calltime:\"2018-04-24 18:10:00\",Acccode:\"1021\",Counterid:\"3\",Evaid:\"1\",Evatime:\"2018-04-24 18:10:00\",Finishtime:null,State:\"2\"}");
        String str = TestNsfw.doPost(url, params, charset, true);
        System.out.println(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=gbk"));
            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();
    }
}
