public NMessage ReciveMessage(NMessageHeader messageHeader) { NMessage message = null; if (mUserConfiguration == null) { return(message); } //Authorize(username, password, lastmsg,type) type=XML Hashtable parameters = new Hashtable(); parameters.Add("username", mUserConfiguration.Username); parameters.Add("password", mUserConfiguration.Password); parameters.Add("messageid", messageHeader.MsgID); parameters.Add("type", "XML"); parameters.Add("format", "amr"); try { List <NMessageBody> messageBodysList = new List <NMessageBody>(); WebRequest requestGetMessage = WebRequest.Create(mUserConfiguration.Url + BulildWebRequestQuery("XMLGetMessage", parameters)); HttpWebResponse responseGetMessage = (HttpWebResponse)requestGetMessage.GetResponse(); Stream dataStream = responseGetMessage.GetResponseStream(); //String DATA = new StreamReader(dataStream).ReadToEnd(); XmlSerializer des = new XmlSerializer(typeof(NMessageBody)); NMessageBody messageBody = (NMessageBody)des.Deserialize(new System.Xml.XmlTextReader(dataStream)); dataStream.Close(); message = new NMessage(messageHeader, messageBody); } catch (Exception ex) { #if (DEBUG) throw; #endif } return(message); }
public NMessage(NMessageHeader header, NMessageBody body) { this.Header = header; this.Body = body; }
public NMessage ReciveMessage(NMessageHeader messageHeader) { NMessage message = null; if (mUserConfiguration == null) return message; //Authorize(username, password, lastmsg,type) type=XML Hashtable parameters = new Hashtable(); parameters.Add("username", mUserConfiguration.Username); parameters.Add("password", mUserConfiguration.Password); parameters.Add("messageid", messageHeader.MsgID); parameters.Add("type", "XML"); parameters.Add("format", "amr"); try { List<NMessageBody> messageBodysList = new List<NMessageBody>(); WebRequest requestGetMessage = WebRequest.Create(mUserConfiguration.Url + BulildWebRequestQuery("XMLGetMessage", parameters)); HttpWebResponse responseGetMessage = (HttpWebResponse)requestGetMessage.GetResponse(); Stream dataStream = responseGetMessage.GetResponseStream(); //String DATA = new StreamReader(dataStream).ReadToEnd(); XmlSerializer des = new XmlSerializer(typeof(NMessageBody)); NMessageBody messageBody = (NMessageBody)des.Deserialize(new System.Xml.XmlTextReader(dataStream)); dataStream.Close(); message = new NMessage(messageHeader, messageBody); } catch (Exception ex) { #if(DEBUG) throw; #endif } return message; }