Esempio n. 1
0
        public static T RequestMessage <T>(XmlMappingObject messageObject) where T : XmlMappingObject, new()
        {
            string             str         = messageObject.ToInnerXmlString("body");
            string             commandCode = CommandDefinition.GetCommandByRequestObjectType(messageObject.GetType()).CommandCode;
            MessageRequestInfo info2       = new MessageRequestInfo();

            MessageRequestInfo.MessageHead head = new MessageRequestInfo.MessageHead();
            head.Transcode = commandCode;
            head.Partnerid = PartnerId;
            head.Version   = Version;
            head.DateTime  = DateTime.Now.ToString("yyyyMMddHHmmss");
            info2.Head     = head;
            info2.Body     = str;
            MessageRequestInfo info = info2;
            string             text = info.ToXmlString("msg").Replace("&gt;", ">").Replace("&lt;", "<");

            if (!string.IsNullOrEmpty(_xmlDir))
            {
                TryAppendText(messageObject, text, 0, 3);
            }
            string requestString = string.Format("transcode={0}&msg={1}&key={2}&partnerid={3}", new object[] { info.Head.Transcode, text, MessageHelper.GetMd5Body(commandCode + text + Key), PartnerId });
            string xMl           = GetXMl(PostManager.Post(ServiceUrl, requestString, Encoding.UTF8, 0, null, "text/xml"));
            T      local         = XmlAnalyzeHelper.AnalyseResponse <T>(xMl, "body");

            if (!string.IsNullOrEmpty(_xmlDir))
            {
                TryAppendText(local, xMl, 0, 3);
            }
            return(local);
        }
Esempio n. 2
0
        public static string GetRequestMessageXml(XmlMappingObject messageObject)
        {
            string             str   = messageObject.ToInnerXmlString("body");
            MessageRequestInfo info2 = new MessageRequestInfo();

            MessageRequestInfo.MessageHead head = new MessageRequestInfo.MessageHead();
            head.Transcode = CommandDefinition.GetCommandByRequestObjectType(messageObject.GetType()).CommandCode;
            head.Partnerid = PartnerId;
            head.Version   = Version;
            head.DateTime  = DateTime.Now.ToString("yyyyMMddHHmmss");
            info2.Head     = head;
            info2.Body     = str;
            MessageRequestInfo info = info2;
            string             str2 = info.ToXmlString("msg").Replace("&gt;", ">").Replace("&lt;", "<");

            return(string.Format("transcode={0}&msg={1}&key={2}&partnerid={3}", new object[] { info.Head.Transcode, str2, MessageHelper.GetMd5Body(info.Head.Transcode + str2 + Key), PartnerId }));
        }