Exemplo n.º 1
0
        public static T RequestMessage <T>(XmlMappingObject messageObject) where T : XmlMappingObject, new()
        {
            var str         = messageObject.ToInnerXmlString("body");
            var commandCode = CommandDefinition.GetCommandByRequestObjectType(messageObject.GetType()).CommandCode;
            var info2       = new MessageRequestInfo();
            var 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;
            var info = info2;
            var text = info.ToXmlString("msg").Replace("&gt;", ">").Replace("&lt;", "<");

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

            if (!string.IsNullOrEmpty(_xmlDir))
            {
                TryAppendText(local, xMl, 0, 3);
            }
            return(local);
        }
Exemplo 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 }));
        }
Exemplo n.º 3
0
        public static string RequestMessage(XmlMappingObject messageObject)
        {
            var str   = messageObject.ToInnerXmlString("body");
            var info2 = new MessageRequestInfo();
            var 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;
            var info          = info2;
            var str2          = info.ToXmlString("msg").Replace("&gt;", ">").Replace("&lt;", "<");
            var requestString = string.Format("transcode={0}&msg={1}&key={2}&partnerid={3}", info.Head.Transcode, str2,
                                              MessageHelper.GetMd5Body(info.Head.Transcode + str2 + Key), PartnerId);

            return(GetXMl(PostManager.Post(ServiceUrl, requestString, Encoding.UTF8, 0, null, "text/xml")));
        }