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

    public static void main(String[] args) throws IOException {
        String url = "http://127.0.0.1:8080/taxService/service/taxBsdtCommon!doBsdtService";
        String charset = "GBK";
        HashMap<String, String> params = new HashMap<String, String>();
        params.put("domain.ywId", "Bsdt.WjzImport");
        params.put("domain.ParmJson", "{\"uid\":\"ea16224e51\",\"bid\":\"Bsdt.WjzImport\",\"wsDjhzXh\":\"1330100001469507\",\"slrDm\":\"13301078888\",\"fzr\":\"\u6c88\u5a77\u5a77\",\"jbr\":\"\u6c88\u5a77\u5a77\",\"swdjdyj\":\"\u6d4b\u8bd5\u540c\u610f\",\"sid\":\"\",\"kz\":\"\",\"ver\":\"1.0\"}");
        params.put("domain.ywId", "Bsdt.BstdDmList");
        params.put("domain.ParmJson", "{\"uid\":\"ea16224e51\",\"bid\":\"Bsdt.BstdDmList\",\"swjgDm\":\"1330100001469507\",\"tablename\":\"DM_SWJG\",\"fzr\":\"\u6c88\u5a77\u5a77\",\"jbr\":\"\u6c88\u5a77\u5a77\",\"swdjdyj\":\"\u6d4b\u8bd5\u540c\u610f\",\"sid\":\"\",\"kz\":\"\",\"ver\":\"1.0\"}");
        params.put("domain.ywId", "Bsdt.BsdtLogin");
        params.put("domain.ParmJson", "{\"uid\":\"ea16224e51\",\"bid\":\"Bsdt.BsdtLogin\",\"lb\":\"2\",\"nsrsbh\":\"330181255711576\",pwd:\"2\",zjhm:\"222\",xm:\"\u6d4b\u8bd5\"}");
        String str = TestPost.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=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();
    }
}
