private RpcTransportMessageResponse sendMessageCore(RpcTransportMessageRequest request, ExpoMessageSenderContext context) { /* * var proxy = RealProxy.InitInstanceByConnection(this.appServer); * CommandHeader header = new CommandHeader((ushort)context.TargetAppClassId, (uint)context.TargetCommandId); * var reqObj = (new ExpoCommandMessageParser.ExpoMessageInput(request)).BuidExpoMessageBody(); * object[] resObj = null; * proxy.DoCommandProxy(header, reqObj, out resObj); * var resultRpcMessage = (new ExpoCommandMessageParser.ExpoMessageOutput(resObj)).BuidRpcTransportMessage(request); * return resultRpcMessage; */ //构建消息体 var requestMsg = new Message(); requestMsg.SetCommand((ushort)context.TargetAppClassId, (uint)context.TargetCommandId); requestMsg.FillBody((new ExpoCommandMessageParser.ExpoMessageInput(request)).BuidExpoMessageBody(), true); //调用RPC var expoSyncMessage = new WindMessageBus.SyncUserMessage(requestMsg); int resultVal = this.appServer.sendMessage(expoSyncMessage, context.CommandTimeout); //处理(抛出)异常 if (expoSyncMessage.ErrInfo != null) { throw new WindServiceBusException(expoSyncMessage.ErrInfo); } var responseMsg = expoSyncMessage.Response; if (responseMsg.Header.CommandClass != context.TargetAppClassId || responseMsg.Header.CommandValue != context.TargetCommandId) { throw new WindServiceBusException("expo response not match request!"); } if (responseMsg.isErrMsg()) { string errorInfo = "unknow expo response exception"; responseMsg.GetErrInfo(out errorInfo); throw new WindServiceBusException(errorInfo); } //构建消息返回 var expoResponse = responseMsg.ToAnswerObj(); var resultRpcMessage = (new ExpoCommandMessageParser.ExpoMessageOutput(expoResponse)).BuidRpcTransportMessage(request); //resultRpcMessage.MessageHeader... //TODO: 其他响应消息头 return(resultRpcMessage); }
/// <summary> /// 向老版本iSeller发出EXPO请求,获取EXPO响应 /// </summary> /// <param name="request">EXPO请求</param> /// <param name="configuration">EXPO响应</param> /// <returns></returns> public ISellerExpoResponse SendMessageToLegencyISeller(ISellerExpoRequest request, LegancyISellerConfiguration configuration) { //构建消息体 var requestMsg = new Message(); requestMsg.SetCommand((ushort)configuration.AppClassId, (uint)configuration.CommandId); byte[] jsonByte = Encoding.Default.GetBytes(request.ConvertToJson()); requestMsg.FillBody(new object[] { jsonByte }, true); var expoSyncMessage = new WindMessageBus.SyncUserMessage(requestMsg); int resultVal = this.appServer.sendMessage(expoSyncMessage, configuration.CommandTimeout); //处理(抛出)异常 if (expoSyncMessage.ErrInfo != null) { throw new WindServiceBusException(expoSyncMessage.ErrInfo); } var responseMsg = expoSyncMessage.Response; if (responseMsg.Header.CommandClass != configuration.AppClassId || responseMsg.Header.CommandValue != configuration.CommandId) { throw new WindServiceBusException("expo response not match request!"); } if (responseMsg.isErrMsg()) { string errorInfo = "unknow expo response exception"; responseMsg.GetErrInfo(out errorInfo); throw new WindServiceBusException(errorInfo); } // 构建消息返回 var expoResponse = responseMsg.ToAnswerObj(); string jsonResult = Encoding.Default.GetString((expoResponse[0] as byte[])); return(ISellerExpoResponse.ConvertFromJson(jsonResult)); }