public void RunRequestTest() { var str = "4d740025636f6d2e78786c2e6a6f622e636f72652e7270632e636f6465632e5270635265717565737453000d736572766572416464726573735300153137322e31382e32332e3133323a3138312f6a6f625300106372656174654d696c6c697354696d654c00000167a64d4b6d53000b616363657373546f6b656e5300206364616666383133616266303266666530366265303436396233663365663433530009636c6173734e616d65530020636f6d2e78786c2e6a6f622e636f72652e62697a2e4578656375746f7242697a53000a6d6574686f644e616d6553000372756e53000e706172616d657465725479706573567400105b6a6176612e6c616e672e436c6173736c000000014d74000f6a6176612e6c616e672e436c6173735300046e616d65530027636f6d2e78786c2e6a6f622e636f72652e62697a2e6d6f64656c2e54726967676572506172616d7a7a53000a706172616d6574657273567400075b6f626a6563746c000000014d740027636f6d2e78786c2e6a6f622e636f72652e62697a2e6d6f64656c2e54726967676572506172616d5300056a6f624964490000000453000f6578656375746f7248616e646c65725300104d6573736167655363686564756c657253000e6578656375746f72506172616d735300005300156578656375746f72426c6f636b537472617465677953000d444953434152445f4c415445525300056c6f674964490000012653000a6c6f674461746554696d4c00000167a64d4b6d530008676c7565547970655300044245414e53000a676c7565536f7572636553000053000e676c756555706461746574696d654c00000167a18329f853000e62726f616463617374496e646578490000000053000e62726f616463617374546f74616c49000000017a7a7a"; CHessianInput input = GetHessianInput(str); var request = (RpcRequest)input.ReadObject(); Assert.Equal("172.18.23.132:181/job", request.serverAddress); Assert.Equal("cdaff813abf02ffe06be0469b3f3ef43", request.accessToken); Assert.Equal("com.xxl.job.core.biz.ExecutorBiz", request.className); Assert.Equal(1544683342701, request.createMillisTime); Assert.Equal("run", request.methodName); Assert.Null(request.requestId); Assert.Null(request.version); Assert.Equal("com.xxl.job.core.biz.model.TriggerParam", (request.parameterTypes[0] as Class).name); var parameter1 = request.parameters[0] as TriggerParam; Assert.Equal(294, parameter1.logId); Assert.Equal(0, parameter1.broadcastIndex); Assert.Equal(1, parameter1.broadcastTotal); Assert.Equal("BEAN", parameter1.glueType); Assert.Equal("", parameter1.glueSource); Assert.Equal(1544602987000, parameter1.glueUpdatetime); Assert.Equal("MessageScheduler", parameter1.executorHandler); Assert.Equal(4, parameter1.jobId); Assert.Equal("", parameter1.executorParams); Assert.Equal("DISCARD_LATER", parameter1.executorBlockStrategy); Assert.Equal(1544683342701, parameter1.logDateTim); }
/// <summary> /// The Request will be processed here. /// The main function in this class /// </summary> public void ProcessRequest() { //Get references to sockets input & output streams m_stream = new NetworkStream(m_socket, FileAccess.ReadWrite, true); MemoryStream memoryStream = new MemoryStream(); //Reads the Header of HTTP Message try { ReadHeaders(); } catch (NotSupportedException e) { SendError(500, "Close"); m_socket.Close(); m_stream.Close(); return; } AbstractHessianInput inHessian = new CHessianInput(m_stream); AbstractHessianOutput tempOutHessian = new CHessianOutput(memoryStream); /// Proxy object CHessianSkeleton objectSkeleton = null; try { objectSkeleton = new CHessianSkeleton(m_apiType, m_Service); objectSkeleton.invoke(inHessian, tempOutHessian); WriteResponse(memoryStream.ToArray()); } catch (Exception e) { SendError(500, "Close"); } finally { m_socket.Close(); m_stream.Close(); } }
/// <summary> /// Execute a request. /// </summary> public void ProcessRequest(HttpContext ctx) { try { context = ctx; Stream inStream = ctx.Request.InputStream; MemoryStream outStream = new MemoryStream(); ctx.Response.BufferOutput = true; ctx.Response.ContentType = "text/xml"; AbstractHessianInput inHessian = new CHessianInput(inStream); AbstractHessianOutput outHessian = new CHessianOutput(outStream); if (m_objectSkeleton == null) { //Vieleicht das Interface als API übergeben??? m_objectSkeleton = new CHessianSkeleton(this.GetType(), this); } m_objectSkeleton.invoke(inHessian, outHessian); byte [] arrData = outStream.ToArray(); int intLength = arrData.Length; //Set length ctx.Response.AppendHeader("Content-Length", intLength.ToString()); //Write stream ctx.Response.OutputStream.Write(arrData, 0, intLength); return; } catch (Exception ex) { ctx.Response.StatusCode = 500; // "Internal server error" ctx.Response.StatusDescription = ex.Message; } }
public void KillRequestTest() { var str = "4d740025636f6d2e78786c2e6a6f622e636f72652e7270632e636f6465632e5270635265717565737453000d736572766572416464726573735300173137322e31382e32332e3133323a33323930302f6a6f625300106372656174654d696c6c697354696d654c00000167c51f4dc853000b616363657373546f6b656e5300206364616666383133616266303266666530366265303436396233663365663433530009636c6173734e616d65530020636f6d2e78786c2e6a6f622e636f72652e62697a2e4578656375746f7242697a53000a6d6574686f644e616d655300046b696c6c53000e706172616d657465725479706573567400105b6a6176612e6c616e672e436c6173736c000000014d74000f6a6176612e6c616e672e436c6173735300046e616d65530003696e747a7a53000a706172616d6574657273567400075b6f626a6563746c0000000149000000047a7a"; CHessianInput input = GetHessianInput(str); var request = (RpcRequest)input.ReadObject(); Assert.Equal("com.xxl.job.core.biz.ExecutorBiz", request.className); Assert.Equal("kill", request.methodName); Assert.Equal(4, (int)request.parameters[0]); }
public void LogRequestTest() { var str = "4d740025636f6d2e78786c2e6a6f622e636f72652e7270632e636f6465632e5270635265717565737453000d736572766572416464726573735300133137322e31382e32332e3133323a32383838325300106372656174654d696c6c697354696d654c00000167bad4d8cd53000b616363657373546f6b656e5300206364616666383133616266303266666530366265303436396233663365663433530009636c6173734e616d65530020636f6d2e78786c2e6a6f622e636f72652e62697a2e4578656375746f7242697a53000a6d6574686f644e616d655300036c6f6753000e706172616d657465725479706573567400105b6a6176612e6c616e672e436c6173736c000000034d74000f6a6176612e6c616e672e436c6173735300046e616d655300046c6f6e677a4d74000f6a6176612e6c616e672e436c6173735300046e616d65530003696e747a52000000037a53000a706172616d6574657273567400075b6f626a6563746c000000034c00000167ba8bbfa0490000059549000000017a7a"; CHessianInput input = GetHessianInput(str); var request = (RpcRequest)input.ReadObject(); Assert.Equal("com.xxl.job.core.biz.ExecutorBiz", request.className); Assert.Equal("log", request.methodName); Assert.Equal(1545022980000, (long)request.parameters[0]); Assert.Equal(1429, (int)request.parameters[1]); Assert.Equal(1, (int)request.parameters[2]); }
/// <summary> /// The Request will be processed here. /// The main function in this class /// </summary> public void ProcessRequest() { //Get references to sockets input & output streams m_stream = new NetworkStream(m_socket, FileAccess.ReadWrite, true); MemoryStream memoryStream = new MemoryStream(); //BufferedStream bs = new BufferedStream(m_stream); var serviceUrl = string.Empty; //Reads the Header of HTTP Message try { serviceUrl = ReadHeaders(); } catch (NotSupportedException e) { SendError(500, "Close"); m_socket.Shutdown(SocketShutdown.Both); m_socket.Close(); m_stream.Close(); return; } AbstractHessianInput inHessian = new CHessianInput(m_stream); AbstractHessianOutput tempOutHessian = new CHessianOutput(memoryStream); /// Proxy object CHessianSkeleton objectSkeleton = null; try { var m_Service = ServiceFactory.SelectService(serviceUrl); if (m_Service == null) { throw new NotSupportedException("This ServiceUrl is not supported"); } objectSkeleton = new CHessianSkeleton(m_Service.GetType(), m_Service); //SendOk(bs, 0); objectSkeleton.invoke(inHessian, tempOutHessian); WriteResponse(memoryStream.ToArray()); } catch (Exception e) { SendError(500, e.GetBaseException().Message); } finally { m_socket.Shutdown(SocketShutdown.Both); m_socket.Close(); m_stream.Close(); } }
private CHessianInput GetHessianInput(string content) { var buffer = new byte[content.Length / 2]; for (int i = 0; i < content.Length; i += 2) { buffer[i / 2] = Convert.ToByte(content.Substring(i, 2), 16); } output.WriteLine(Encoding.ASCII.GetString(buffer)); var stream = new MemoryStream(buffer); CHessianInput input = new CHessianInput(stream); return(input); }
public void TestEnumSerializing() { MemoryStream stream = new MemoryStream(); CHessianOutput out1 = new CHessianOutput(stream); TestDto obj = new TestDto(); out1.StartReply(); out1.WriteObject(obj); out1.CompleteReply(); byte[] data = stream.ToArray(); File.WriteAllBytes(@"C:\Users\disap\Desktop\Projects\hessianscharp\HessianTestProject\test.txt", data); CHessianInput input = new CHessianInput(new MemoryStream(data)); var result = input.ReadReply(typeof(TestDto)); Assert.IsTrue(true); }
public void CallbackTest() { var str = "4d740025636f6d2e78786c2e6a6f622e636f72652e7270632e636f6465632e5270635265717565737453000d7365727665724164647265737353002b687474703a2f2f3137322e31382e32312e3134343a383038302f78786c2d6a6f622d61646d696e2f6170695300106372656174654d696c6c697354696d654c00000167c62501b653000b616363657373546f6b656e5300206364616666383133616266303266666530366265303436396233663365663433530009636c6173734e616d6553001d636f6d2e78786c2e6a6f622e636f72652e62697a2e41646d696e42697a53000a6d6574686f644e616d6553000863616c6c6261636b53000e706172616d657465725479706573567400105b6a6176612e6c616e672e436c6173736c000000014d74000f6a6176612e6c616e672e436c6173735300046e616d6553000e6a6176612e7574696c2e4c6973747a7a53000a706172616d6574657273567400075b6f626a6563746c00000001566c000000014d74002e636f6d2e78786c2e6a6f622e636f72652e62697a2e6d6f64656c2e48616e646c6543616c6c6261636b506172616d5300056c6f67496449000007f653000d65786563757465526573756c744d740022636f6d2e78786c2e6a6f622e636f72652e62697a2e6d6f64656c2e52657475726e54530004636f646549000000c85300036d736753000ae585b1e7a1aee8aea4e4ba86302f30e69da1e6b688e681af530007636f6e74656e744e7a7a7a7a7a"; CHessianInput input = GetHessianInput(str); var request = (RpcRequest)input.ReadObject(); Assert.Equal("http://172.18.21.144:8080/xxl-job-admin/api", request.serverAddress); Assert.Equal("cdaff813abf02ffe06be0469b3f3ef43", request.accessToken); Assert.Equal("com.xxl.job.core.biz.AdminBiz", request.className); Assert.Equal("callback", request.methodName); Assert.Equal("java.util.List", (request.parameterTypes[0] as Class).name); var callback = (request.parameters[0] as ArrayList)[0] as HandleCallbackParam; Assert.Equal(2038, callback.logId); Assert.Equal(200, callback.executeResult.code); Assert.Equal("共确认了0/0条消息", callback.executeResult.msg); Assert.Null(callback.executeResult.content); }
public byte[] HandleRequest(Stream inputStream) { var hessianInput = new CHessianInput(inputStream); var rpcRequest = hessianInput.ReadObject() as RpcRequest; var rpcResponse = new RpcResponse(); if (rpcRequest == null) { rpcResponse.error = "The request is not valid."; } else { rpcResponse.requestId = rpcRequest.requestId; InvokeService(rpcRequest, rpcResponse); } using (var outputStream = new MemoryStream()) { new CHessianOutput(outputStream).WriteObject(rpcResponse); return(outputStream.GetBuffer()); } }
internal AbstractHessianInput GetHessian1Input(Stream inputStream) { AbstractHessianInput abstractHessianInput = new CHessianInput(inputStream); return(abstractHessianInput); }