/// <summary> /// This method wrapps an instance call to the burlap /// requests, sends it to the burlap service and translates the reply of this call to the C# - data type /// </summary> /// <param name="methodInfo">The method to call</param> /// <param name="arrMethodArgs">The arguments to the method call</param> /// <returns>Invocation result</returns> public object DoBurlapMethodCall(object[] arrMethodArgs, MethodInfo methodInfo) { Type[] argumentTypes = GetArgTypes(arrMethodArgs); Stream sInStream = null; Stream sOutStream = null; try { WebRequest webRequest = this.OpenConnection(m_uriBurlapServiceUri); webRequest.ContentType = "text/xml"; webRequest.Method = "POST"; MemoryStream memoryStream = new MemoryStream(2048); CBurlapOutput cBurlapOutput = this.GetBurlapOutput(memoryStream); string strMethodName = methodInfo.Name; if (m_CBurlapProxyFactory.IsOverloadEnabled) { if (arrMethodArgs != null) { strMethodName = strMethodName + "__" + arrMethodArgs.Length; } else { strMethodName = strMethodName + "__0"; } } cBurlapOutput.Call(strMethodName, arrMethodArgs); try { webRequest.ContentLength = memoryStream.ToArray().Length; sOutStream = webRequest.GetRequestStream(); memoryStream.WriteTo(sOutStream); } catch (Exception e) { throw new CBurlapException("Exception by sending request to the service with URI:\n" + this.URI.ToString() + "\n" + e.Message); } sOutStream.Flush(); sOutStream.Close(); HttpWebResponse webResponse = (HttpWebResponse)webRequest.GetResponse(); if (webResponse.StatusCode != HttpStatusCode.OK) { System.Text.StringBuilder sb = new System.Text.StringBuilder(); int chTemp; sInStream = webResponse.GetResponseStream(); if (sInStream != null) { while ((chTemp = sInStream.ReadByte()) >= 0) { sb.Append((char)chTemp); } sInStream.Close(); } throw new CBurlapException(sb.ToString()); } sInStream = webResponse.GetResponseStream(); System.IO.BufferedStream bStream = new BufferedStream(sInStream, 2048); AbstractBurlapInput burlapInput = this.GetBurlapInput(bStream); return(burlapInput.ReadReply(methodInfo.ReturnType)); } catch (Exception e) { if (e.GetType().Equals(typeof(CBurlapException))) { throw e; } else { throw new CBurlapException("Exception by proxy call\n" + e.ToString() + e.Message); } } finally { if (sInStream != null) { sInStream.Close(); } if (sOutStream != null) { sOutStream.Close(); } } }
/// <summary> /// Instantiation of the hessian output (not cached) /// </summary> /// <param name="stream">Strean for HessianOutput - Instantiation</param> /// <returns>New HessianOutput - Instance</returns> private CBurlapOutput GetBurlapOutput(Stream stream) { CBurlapOutput cBurlapOut = new CBurlapOutput(stream); return(cBurlapOut); }