protected virtual void SendRequest(WebRequest req, Request.ICOMS reqicoms) { Stream strm = null; XmlTextWriter wtr = null; // Create a new unique key on the input stream string strKey = m_siteId.ToString() + DateTime.Now.ToString("yyyyMMddHHmmssffffff"); reqicoms.KEY = strKey; try { // TODO: Trace request??? strm = req.GetRequestStream(); wtr = new XmlTextWriter(strm, this.RequestEncoding); wtr.WriteRaw(ObjectSerializer.Serialize(reqicoms)); } // try catch (WebException excWeb) { Debug.WriteLine(excWeb); throw new CmUnavailableException(excWeb); } // catch( WebException excWeb ) catch (Exception exc) { Debug.WriteLine(exc); throw new CmProxyException(exc); } // catch( Exception exc ) finally { if (null != wtr) { wtr.Close(); } if (null != strm) { strm.Close(); } } // finally } // SendRequest()
public Response.ICOMS CmMethod(Request.ICOMS reqicoms) { // Set routing information from constructor of this proxy reqicoms.ENVIRONMENT = m_strEnvironment; reqicoms.USERID = m_strUsername; reqicoms.PASSWORD = m_strPassword; WebRequest req = GetWebRequest(new Uri(Url)); SendRequest(req, reqicoms); WebResponse rsp = GetWebResponse(req); Response.ICOMS rspicoms = ReceiveResponse(rsp); rsp.Close(); // Parse the standard errors string strErrorText = null; int intErrorCode = 0; FindError(rspicoms.Item, out intErrorCode, out strErrorText); if (0 != intErrorCode) { throw new CmErrorException(intErrorCode, kstrErrorMessageDefault, new CmProxyException(strErrorText)); } // If the output key was not returned intact, then we are getting // a crisscrossed message. if (rspicoms.KEY != reqicoms.KEY) { throw new CmKeyMismatchException(); } return(rspicoms); } // CmMethod()