/// <summary> /// Constructor /// </summary> /// <param name="proxyType">Interface type that has to be proxied</param> /// <param name="hessianProxyFactory">HessianProxyFactory - Instance</param> /// <param name="uri">Server-Proxy uri</param> public CHessianProxyStandardImpl(Type proxyType,CHessianProxyFactory hessianProxyFactory, Uri uri) : base(typeof(IHessianProxyStandard)) { this.m_proxyType = proxyType; this.m_methodCaller = new CHessianMethodCaller(hessianProxyFactory,uri); this.m_methods = proxyType.GetMethods(); }
public CHessianProxyStandardImpl(Type proxyType, CHessianProxyFactory hessianProxyFactory, Uri uri, string username, string password, WebProxy webproxy) : base(typeof(IHessianProxyStandard)) { this.m_proxyType = proxyType; this.m_methodCaller = new CHessianMethodCaller(hessianProxyFactory, uri, username, password, webproxy); this.m_methods = proxyType.GetMethods(); }
/// <summary> /// This reflective method for invoking methods. Overriden from RealProxy. /// Handles the object invocation. This method wrapps an instance call to the hessian /// requests, sends it to the hessian service and translates the reply of this call to the C# - data type /// <see cref="System.Runtime.Remoting.Proxies.RealProxy"/> /// </summary> /// <param name="msg"></param> /// <returns></returns> public override IMessage Invoke(IMessage msg) { // Convert to a MethodCallMessage IMethodCallMessage methodMessage = new MethodCallMessageWrapper((IMethodCallMessage)msg); MethodInfo methodInfo = this.GetMethodInfoForMethodBase(methodMessage); Type[] argumentTypes = CHessianMethodCaller.GetArgTypes(methodMessage.Args); object objReturnValue = null; if (methodInfo != null) { if (methodInfo.Name.Equals("Equals") && argumentTypes != null && argumentTypes.Length == 1 && argumentTypes[0].IsAssignableFrom((typeof(Object)))) { Object value = methodMessage.Args[0]; if (value == null) { objReturnValue = false; } else if (value.GetType().Equals(typeof(CHessianProxy)) || value.GetType().IsAssignableFrom(typeof(CHessianProxy))) { objReturnValue = this.m_methodCaller.URI.Equals(((CHessianProxy)value).URI); } else { objReturnValue = false; } } else if (methodInfo.Name.Equals("GetHashCode") && argumentTypes.Length == 0) { objReturnValue = this.m_methodCaller.URI.GetHashCode(); } else if (methodInfo.Name.Equals("GetHessianURL")) { objReturnValue = this.m_methodCaller.URI.ToString(); } else if (methodInfo.Name.Equals("ToString") && argumentTypes.Length == 0) { objReturnValue = "[HessianProxy " + this.m_methodCaller.URI + "]"; } else if (methodInfo.Name.Equals("GetType") && argumentTypes.Length == 0) { objReturnValue = this.m_proxyType; } else { objReturnValue = this.m_methodCaller.DoHessianMethodCall(methodMessage.Args, methodInfo); } } else { if (methodMessage.MethodName.Equals("GetType") && (methodMessage.ArgCount == 0)) { objReturnValue = this.m_proxyType; } } // Create the return message (ReturnMessage) return(new ReturnMessage(objReturnValue, methodMessage.Args, methodMessage.ArgCount, methodMessage.LogicalCallContext, methodMessage)); }
/// <summary> /// Gets method info instance, according to the given method base /// </summary> /// <param name="methodMessage">Method message, that describes the method call</param> /// <returns>MethodInfo - Instance</returns> private MethodInfo GetMethodInfoForMethodBase(IMethodCallMessage methodMessage) { if (IsMethodNameUnique(methodMessage.MethodName)) { return(this.m_proxyType.GetMethod(methodMessage.MethodName)); } else { return(this.m_proxyType.GetMethod(methodMessage.MethodName, CHessianMethodCaller.GetArgTypes(methodMessage.Args))); } }
public void DoHessianMethodCallTest() { CHessianProxyFactory hessianProxyFactory = null; // TODO: Initialize to an appropriate value Uri uri = null; // TODO: Initialize to an appropriate value CHessianMethodCaller target = new CHessianMethodCaller(hessianProxyFactory, uri); // TODO: Initialize to an appropriate value object[] arrMethodArgs = null; // TODO: Initialize to an appropriate value MethodInfo methodInfo = null; // TODO: Initialize to an appropriate value object expected = null; // TODO: Initialize to an appropriate value object actual; actual = target.DoHessianMethodCall(arrMethodArgs, methodInfo); Assert.AreEqual(expected, actual); Assert.Inconclusive("Verify the correctness of this test method."); }
public static void TestHessainCompact() { CHessianProxyFactory factory = new CHessianProxyFactory(); //String url = "http://192.168.0.1:9090/resin-doc/protocols/tutorial/hessian-add/hessian/hessianDotNetTest"; String url = "http://192.168.1.11:9090/resin-doc/protocols/csharphessian/hessian/hessianDotNetTest"; CHessianMethodCaller methodCaller = new CHessianMethodCaller(factory, new Uri(url)); try { MethodInfo mInfo_1 = typeof(IHessianTest).GetMethod("testConcatString"); object result = methodCaller.DoHessianMethodCall(new object[]{"Hallo ","Welt"},mInfo_1 ); Console.WriteLine("Return value of method \"testConcatString\":" ); Console.WriteLine(result); MethodInfo mInfo_2 = typeof(IHessianTest).GetMethod("testHashMap"); string [] keys = new string[]{"Bauarbeiter","Jo!"}; string [] values = new string[]{"Koennen wir das schaffen?","Wir schaffen das!"}; Hashtable hashResult = (Hashtable)methodCaller.DoHessianMethodCall(new object[]{keys,values},mInfo_2 ); IDictionaryEnumerator dict = hashResult.GetEnumerator(); Console.WriteLine("Return value of method \"testHashMap\":" ); while (dict.MoveNext()) { Console.WriteLine(dict.Key.ToString() +" " + dict.Value.ToString() ); } ParamObject pobject = (ParamObject)Activator.CreateInstance(typeof(ParamObject)); pobject.setStringVar("Bauarbeiter, koennen wir das schaffen?"); Hashtable hashTab = new Hashtable(); hashTab.Add("Jo", " Wir schaffen das!"); MethodInfo mInfo_3 = typeof(IHessianTest).GetMethod("testParamObject"); ParamObject pObjResult = (ParamObject)methodCaller.DoHessianMethodCall(new object[]{pobject},mInfo_3 ); Console.WriteLine("Return value of method \"testParamObject\":" ); Console.WriteLine(pObjResult.getStringVar()); Console.WriteLine(pObjResult.getHashVar()["Message"].ToString()); } catch(Exception ex) { Console.WriteLine(ex.Message); } Console.ReadLine(); }
/// <summary> /// Constructor /// </summary> /// <param name="proxyType">Interface type that has to be proxied</param> /// <param name="hessianProxyFactory">HessianProxyFactory - Instance</param> /// <param name="uri">Server-Proxy uri</param> public CHessianProxyStandardImpl(Type proxyType, CHessianProxyFactory hessianProxyFactory, Uri uri) : base(typeof(IHessianProxyStandard)) { this.m_proxyType = proxyType; this.m_methodCaller = new CHessianMethodCaller(hessianProxyFactory, uri); this.m_methods = proxyType.GetMethods(); }
internal CHessianProxy(CHessianProxyFactory hessianProxyFactory, Uri uri, string username, string password, WebProxy webproxy) { this.m_methodCaller = new CHessianMethodCaller(hessianProxyFactory, uri, username, password, webproxy); }
/// <summary> /// Constructor /// </summary> /// <param name="hessianProxyFactory">HessianProxyFactory - Instance</param> /// <param name="uri">Server-Proxy uri</param> internal CHessianProxy(CHessianProxyFactory hessianProxyFactory, Uri uri) { this.m_methodCaller = new CHessianMethodCaller(hessianProxyFactory, uri); }
/// <summary> /// Constructor /// </summary> /// <param name="hessianProxyFactory">HessianProxyFactory - Instance</param> /// <param name="uri">Server-Proxy uri</param> internal CHessianProxy(CHessianProxyFactory hessianProxyFactory, Uri uri) { this.m_methodCaller = new CHessianMethodCaller(hessianProxyFactory,uri); }