/*
 * Decompiled with CFR 0.152.
 */
package gt3.esb.ejb.adapter.client;

import gt3.esb.ejb.adapter.client.IEsbXmlMessageReceiver;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;
import javax.naming.InitialContext;

public class Ejb3TestClient {
    private static final int MAX_OUTPUT_LINE_LENGTH = 100;
    private boolean logging = true;

    public Ejb3TestClient() {
        this.initialize();
    }

    public void initialize() {
        long startTime = 0L;
        if (this.logging) {
            this.log("Initializing bean access.");
            startTime = System.currentTimeMillis();
        }
        try {
            InitialContext context = this.getInitialContext();
            IEsbXmlMessageReceiver service = (IEsbXmlMessageReceiver)context.lookup("gt3.esb.ejb.AipEJBAdapterXml");
            String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><service xmlns=\"http://www.chinatax.gov.cn/spec/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\t<head>\t\t<tran_id>SWZJ.GSGL.SB.CXZRRDJXXWBXT</tran_id>\t\t<channel_id>GDDS.ZJNB.GSHD</channel_id>\t\t<tran_seq>eea4ff11269045068f421dd3d654804e</tran_seq>\t\t<tran_date>20120416</tran_date>\t\t<tran_time>083231475</tran_time>\t\t<expand>\t\t\t<name>identityType</name>\t\t\t<value>49308fd2f75d462594648203c1ae5e93</value>\t\t</expand>\t\t<expand>\t\t\t<name>sjry</name>\t\t\t<value>24406060733</value>\t\t</expand>\t\t<expand>\t\t\t<name>sjjg</name>\t\t\t<value>24406820018</value>\t\t</expand>\t</head>\t<body><![CDATA[<?xml version=\"1.0\" encoding=\"UTF-8\"?><taxML xsi:type=\"zrrxxcxrequest\" xmlbh=\"String\" bbh=\"String\" xmlmc=\"String\" xsi:schemaLocation=\"http://www.chinatax.gov.cn/dataspec/ TaxMLBw_GSGL_SB_001_Request_v1.0.xsd\" xmlns=\"http://www.chinatax.gov.cn/dataspec/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\t<djxh>20124400001005357570</djxh>\t<zjzlDm></zjzlDm>\t<zjhm></zjhm>\t<xm></xm>\t<nsrsbh></nsrsbh></taxML>]]></body></service>";
            String response = service.receiveMessageXML(xml);
            if (this.logging) {
                long endTime = System.currentTimeMillis();
                this.log("Succeeded initializing bean access through Home interface.");
                this.log("Execution time: " + (endTime - startTime) + " ms.");
                System.out.println(response);
            }
        }
        catch (Exception e) {
            if (this.logging) {
                this.log("Failed initializing bean access.");
            }
            e.printStackTrace();
        }
    }

    private InitialContext getInitialContext() throws Exception {
        String url = "t3://150.12.56.135:8001";
        Properties properties = null;
        try {
            properties = new Properties();
            properties.put("java.naming.factory.initial", "weblogic.jndi.WLInitialContextFactory");
            properties.put("java.naming.provider.url", url);
            return new InitialContext(properties);
        }
        catch (Exception e) {
            this.log("Unable to connect to WebLogic server at " + url);
            this.log("Please make sure that the server is running.");
            throw e;
        }
    }

    public String filetostr(String fName) throws IOException {
        File f_XmlSource = new File(fName);
        byte[] b_XmlSource = new byte[new Long(f_XmlSource.length()).intValue()];
        FileInputStream fis_XmlSource = new FileInputStream(f_XmlSource);
        fis_XmlSource.read(b_XmlSource);
        System.out.println(new String(b_XmlSource));
        System.out.println();
        return new String(b_XmlSource);
    }

    private void log(String message) {
        if (message == null) {
            System.out.println("-- null");
            return;
        }
        if (message.length() > 100) {
            System.out.println("-- " + message.substring(0, 100) + " ...");
        } else {
            System.out.println("-- " + message);
        }
    }

    public static void main(String[] args) {
        Ejb3TestClient client = new Ejb3TestClient();
    }
}
