protected Dictionary <string, object> makeMessage( string pfxFilePath, string pfxPassword, string cerFilePath, string signType, string charset, Dictionary <string, object> msgData) { //报文结构体初始化 CryptUtils_Csharp.MessageWorker.trafficMessage msgRequestSource = new CryptUtils_Csharp.MessageWorker.trafficMessage(); //发送类实体化 CryptUtils_Csharp.MessageWorker worker = new CryptUtils_Csharp.MessageWorker(); worker.PFXFile = pfxFilePath; //商户pfx证书路径 worker.PFXPassword = pfxPassword; //商户pfx证书密码 worker.CerFile = cerFilePath; //杉德cer证书路径 msgRequestSource.charset = charset; //商户号 msgRequestSource.signType = signType; //交易代码 msgRequestSource.extend = ""; //扩展域 //报文体json JavaScriptSerializer jsonSer = new JavaScriptSerializer(); msgRequestSource.data = jsonSer.Serialize(msgData); CryptUtils_Csharp.MessageWorker.trafficMessage msgRequest = worker.SignMessageBeforePost(msgRequestSource); //string signedMessage = worker.UrlEncodeMessage(msgRequest); Dictionary <string, object> signedMessageDic = new Dictionary <string, object>(); signedMessageDic["charset"] = msgRequest.charset; signedMessageDic["signType"] = msgRequest.signType; signedMessageDic["data"] = msgData;// msgRequest.data; signedMessageDic["sign"] = System.Web.HttpUtility.UrlEncode(msgRequest.sign); signedMessageDic["extend"] = msgRequest.extend; string signedMessage = jsonSer.Serialize(signedMessageDic); log.Debug("服务器返回为:" + signedMessage); return(signedMessageDic); // return System.Web.HttpUtility.UrlEncode(signedMessage); }
protected CryptUtils_Csharp.MessageWorker.trafficMessage SendMessageSample( string pfxFilePath, string pfxPassword, string cerFilePath, string ServerUrl, string signType, string charset, Dictionary <string, object> msgData) { //报文结构体初始化 CryptUtils_Csharp.MessageWorker.trafficMessage msgRequestSource = new CryptUtils_Csharp.MessageWorker.trafficMessage(); //发送类实体化 CryptUtils_Csharp.MessageWorker worker = new CryptUtils_Csharp.MessageWorker(); worker.PFXFile = pfxFilePath; //商户pfx证书路径 worker.PFXPassword = pfxPassword; //商户pfx证书密码 worker.CerFile = cerFilePath; //杉德cer证书路径 msgRequestSource.charset = charset; //商户号 msgRequestSource.signType = signType; //交易代码 msgRequestSource.extend = ""; //扩展域 //报文体json JavaScriptSerializer jsonSer = new JavaScriptSerializer(); msgRequestSource.data = jsonSer.Serialize(msgData); log.Debug("待发送报文为:" + msgRequestSource.data); CryptUtils_Csharp.MessageWorker.trafficMessage respMessage = worker.postMessage(ServerUrl, msgRequestSource); log.Debug("服务器返回为:" + respMessage.data); return(respMessage); }