public class TestSGIPSubmit
extends Thread {
SGIPSubmit sgipSubmit = null;
private static BodySubmit bodySubmit = null;
private int cmdID = SGIP_Command.ID_SGIP_SUBMIT; public void run() {
Socket so;
java.io.OutputStream out;
java.io.InputStream input;
so = null;
out = null;
input = null;
bodySubmit.setSpNumber("9365");
bodySubmit.setChargeNumber("13393514835");
bodySubmit.setUserCount(1);
bodySubmit.setAgentFlag(0);
bodySubmit.setCorpId("");
bodySubmit.setExpireTime("2007121415");
bodySubmit.setFeeType(1);
bodySubmit.setFeeValue("000000");
bodySubmit.setGivenVale("000000");
bodySubmit.setMessageCoding(0);
bodySubmit.setMessageContent("fdsfsdfsfsdfsdfds");
bodySubmit.setUserNumber("13998787845"); SGIP_Command sgip_command = new SGIP_Command();
try {
so = new Socket("127.0.0.1", 8802);
out = new DataOutputStream(so.getOutputStream());
input = new DataInputStream(so.getInputStream());
sgipSubmit = new SGIPSubmit(bodySubmit, 0xb4e9536bL, cmdID);
if (sgipSubmit.write(out) == 0) {
System.out.println("bindTest.write ok !!!");
} SGIP_Command respSubmit = sgip_command.read(input);
SGIPSubmitResp submitResp = (SGIPSubmitResp) respSubmit;
if (submitResp.readbody() == 0) {
System.out.println("BindResp result" +
submitResp.getBodysubmitResp().getResult());
System.out.println("command:" + submitResp.getMsgHead().getCommandId());
System.out.println("seq1:" + submitResp.getMsgHead().getSeq_1());
System.out.println("seq2:" + submitResp.getMsgHead().getSeq_2());
} }
catch (Exception e) {
System.out.println(e.toString());
} } public TestSGIPSubmit() {
super();
} public static void main(String[] args) {
TestSGIPSubmit testsgipsubmit = new TestSGIPSubmit();
BodySubmit bodySubmit = new BodySubmit(); testsgipsubmit.start(); }
}编译时提示:Hit uncaught exception java.lang.NullPointerException
调试的话就是:Exception in thread "Thread-0" java.lang.NullPointerException
at com.zhuoyue.smsp.sgip12.process.TestSGIPSubmit.run(TestSGIPSubmit.java:34)
extends Thread {
SGIPSubmit sgipSubmit = null;
private static BodySubmit bodySubmit = null;
private int cmdID = SGIP_Command.ID_SGIP_SUBMIT; public void run() {
Socket so;
java.io.OutputStream out;
java.io.InputStream input;
so = null;
out = null;
input = null;
bodySubmit.setSpNumber("9365");
bodySubmit.setChargeNumber("13393514835");
bodySubmit.setUserCount(1);
bodySubmit.setAgentFlag(0);
bodySubmit.setCorpId("");
bodySubmit.setExpireTime("2007121415");
bodySubmit.setFeeType(1);
bodySubmit.setFeeValue("000000");
bodySubmit.setGivenVale("000000");
bodySubmit.setMessageCoding(0);
bodySubmit.setMessageContent("fdsfsdfsfsdfsdfds");
bodySubmit.setUserNumber("13998787845"); SGIP_Command sgip_command = new SGIP_Command();
try {
so = new Socket("127.0.0.1", 8802);
out = new DataOutputStream(so.getOutputStream());
input = new DataInputStream(so.getInputStream());
sgipSubmit = new SGIPSubmit(bodySubmit, 0xb4e9536bL, cmdID);
if (sgipSubmit.write(out) == 0) {
System.out.println("bindTest.write ok !!!");
} SGIP_Command respSubmit = sgip_command.read(input);
SGIPSubmitResp submitResp = (SGIPSubmitResp) respSubmit;
if (submitResp.readbody() == 0) {
System.out.println("BindResp result" +
submitResp.getBodysubmitResp().getResult());
System.out.println("command:" + submitResp.getMsgHead().getCommandId());
System.out.println("seq1:" + submitResp.getMsgHead().getSeq_1());
System.out.println("seq2:" + submitResp.getMsgHead().getSeq_2());
} }
catch (Exception e) {
System.out.println(e.toString());
} } public TestSGIPSubmit() {
super();
} public static void main(String[] args) {
TestSGIPSubmit testsgipsubmit = new TestSGIPSubmit();
BodySubmit bodySubmit = new BodySubmit(); testsgipsubmit.start(); }
}编译时提示:Hit uncaught exception java.lang.NullPointerException
调试的话就是:Exception in thread "Thread-0" java.lang.NullPointerException
at com.zhuoyue.smsp.sgip12.process.TestSGIPSubmit.run(TestSGIPSubmit.java:34)
public static void main(String[] args) {
TestSGIPSubmit testsgipsubmit = new TestSGIPSubmit();
bodySubmit = new BodySubmit(); testsgipsubmit.start(); }
则会好用了