|
7#
楼主 |
发表于 2008-2-1 11:36:15
|
只看该作者
代码如下:
Action()
{
char buf[4096];
int sendLen=0;
char strHeader[]="5A01000000000000";
int headerLen=0;
headerLen = strlen(strHeader);
lr_start_transaction("Trans_7061");
lrs_create_socket("socket0", "TCP", "LocalHost=0", "RemoteHost=128.32.100.112:8666", LrsLastArg);
sprintf(buf, "%s", lr_eval_string(
"5A01000000000000"
"<?xml version=\"1.0\" ?>\n"
"<Root>\n"
"<Head>\n"
"<Version>01</Version>\n"
"<TxCode>7061</TxCode>\n"
"<FuncCode>000</FuncCode>\n"
"<Channel>0005</Channel>\n"
"<SubCenterId>{tstSubCenterID}</SubCenterId>\n"
"<NodeId>{tstNodeID}</NodeId>\n"
"<TellerId>{tstTellerID}</TellerId>\n"
"<TxSeqId>{tstTxSeqID}</TxSeqId>\n"
"<UserId>{tstUserID}</UserId>\n"
"<TxDate>20080118</TxDate>\n"
"<TxTime>140158</TxTime>\n"
"</Head>\n"
"<Body>\n"
"<UnitTellerId>{tstUnitTellerID}</UnitTellerId>\n"
"<BusiType>1</BusiType>\n"
"<SecAcct></SecAcct>\n"
"<SecPwdChkFlag>0</SecPwdChkFlag>"
"<SecAcctPwd>5H1gToMGKs8jVj548/0=</SecAcctPwd>\n"
"<SavAcctId>0000000100000006</SavAcctId>\n"
"<TxAmount>0020</TxAmount>\n"
"<CurCode>CNY</CurCode>\n"
"<DepId>{tstDepID}</DepId>\n"
"<SavAcctType>1</SavAcctType>\n"
"</Body>\n"
"</Root>\n")
);
sendLen=strlen(buf);
lr_log_message("len=%d", sendLen);
sprintf(strHeader+8, "%08X", sendLen);
lr_log_message("strHeader=%s",strHeader);
memcpy(buf, strHeader, headerLen);
lr_log_message("%s",buf);
lrs_set_send_buffer("socket0",buf,strlen(buf));
lrs_send("socket0", "buf0", LrsLastArg);
lr_log_message("%d",strlen(buf));
//lrs_receive("socket0", "buf1", LrsLastArg);
lrs_receive_ex("socket0", "buf1", "BinaryStringTerminator=\\x00", LrsLastArg);
lrs_save_searched_string("socket0",NULL,"strResult","LB/BIN=<RespCode>","RB/BIN=</RespCode>",1,0,-1);
if ( strncmp(lr_eval_string("{strResult}"),"E",1) == 0 ) {
lr_end_transaction("Trans_7061", LR_FAIL);
//lr_log_message("strResult=[%s]",lr_eval_string("{strResult}"));
lrs_save_searched_string("socket0",NULL,"strResult","LB/BIN=<RespMsg>","RB/BIN=</RespMsg>",1,0,-1);
} else {
lr_end_transaction("Trans_7061", LR_PASS);
}
lrs_close_socket("socket0");
return 0;
} |
|