/// <summary> /// Solicit /// </summary> /// <param name="securityToken"></param> /// <param name="returnURL"></param> /// <param name="request"></param> /// <param name="parameters"></param> /// <returns></returns> string INetworkNodeBinding.Solicit(string securityToken, string returnURL, string request, string[] parameters) { Init(); LOG.Debug("Solicit"); #region Validate if (string.IsNullOrEmpty(securityToken)) { throw _service11Provider.FaultProvider.GetFault(EndpointVersionType.EN11, ENExceptionCodeType.E_InvalidParameter, "NULL SecurityToken argument"); } if (string.IsNullOrEmpty(request)) { throw _service11Provider.FaultProvider.GetFault(EndpointVersionType.EN11, ENExceptionCodeType.E_InvalidParameter, "NULL Request argument"); } #endregion Validate try { LOG.Debug("Getting visit"); NamedEndpointVisit visit = _service11Provider.VisitProvider.GetVisit(securityToken); AsyncContentRequest asyncRequest = new AsyncContentRequest(); asyncRequest.FlowName = null; //TODO: Make sure the flow can't be derived from the Flow asyncRequest.OperationName = request; asyncRequest.Parameters = CreateParameters(parameters); asyncRequest.Notifications = CreateNotifications(returnURL); LOG.Debug("Soliciting: " + asyncRequest); TransactionStatus status = _service11Provider.TransactionService.Solicit(asyncRequest, visit); LOG.Debug("Status: " + status.Id); return(status.Id); } catch (Exception ex) { LOG.Error("Error while soliciting", ex); throw _service11Provider.FaultProvider.GetFault(EndpointVersionType.EN11, ex); } }
public TransactionStatus Solicit(AsyncContentRequest request, NamedEndpointVisit visit) { Activity activity = null; string transactionId = null; try { NodeVisit nodeVisit; MakeEndpointActivity(visit, ActivityType.Audit, NodeMethod.Solicit, out nodeVisit, out activity); if (request == null) { throw FaultProvider.GetFault(visit.Version, ENExceptionCodeType.E_InvalidParameter, "Empty input request"); } if (string.IsNullOrEmpty(request.OperationName)) { throw FaultProvider.GetFault(visit.Version, ENExceptionCodeType.E_InvalidParameter, "Input request is null"); } if ((request.FlowName == null) || string.IsNullOrEmpty(request.FlowName)) { if (visit.Version == EndpointVersionType.EN11) { bool moreThanOneFlowFound; string flowNameByServiceName = FlowManager.GetDataFlowNameByServiceName(request.OperationName, out moreThanOneFlowFound); if (string.IsNullOrEmpty(flowNameByServiceName)) { if (moreThanOneFlowFound) { throw FaultProvider.GetFault(visit.Version, ENExceptionCodeType.E_InvalidParameter, string.Format("More than one flow was found for the service \"{0}\"", request.OperationName)); } else { throw FaultProvider.GetFault(visit.Version, ENExceptionCodeType.E_InvalidParameter, string.Format("Could not find a flow for the service \"{0}\"", request.OperationName)); } } request.FlowName = flowNameByServiceName; } else { throw FaultProvider.GetFault(visit.Version, ENExceptionCodeType.E_InvalidParameter, "Input flow is null"); } } bool isFlowProtected; string flowId = FlowManager.GetDataFlowIdByName(request.FlowName, out isFlowProtected); if (flowId == null) { throw FaultProvider.GetFault(visit.Version, ENExceptionCodeType.E_InvalidDataflow, "Flow \"{0}\" was not found", request.FlowName); } activity.FlowName = request.FlowName; activity.Operation = request.OperationName; DataService solicitService = FlowManager.GetSolicitServiceForFlow(flowId, request.OperationName); if ((solicitService == null) || !solicitService.IsActive) { throw FaultProvider.GetFault(visit.Version, ENExceptionCodeType.E_ServiceUnavailable, "A valid Solicit service was not found for the flow \"{0}\" and request \"{1}\"", request.FlowName, request.OperationName); } if (isFlowProtected) { ValidateUserPermissions(nodeVisit, request.FlowName, request.OperationName, NodeMethod.Solicit, activity); } activity.AppendFormat("Solicit request from {0} by {1}. ", visit.IP, nodeVisit.Account.NaasAccount); activity.AppendFormat("Service:{0} Parameters:{1}. ", request.OperationName, ParsingHelper.ToQualifiedString(request.Parameters)); // Validate the service plugin try { PluginLoader.ValidateSolicitProcessor(solicitService); } catch (Exception) { throw FaultProvider.GetFault(visit.Version, ENExceptionCodeType.E_ServiceUnavailable, "Failed to load the Solicit service for the flow \"{0}\" and request \"{1}\"", request.FlowName, request.OperationName); } transactionId = TransactionManager.CreateTransaction(NodeMethod.Solicit, visit.Version, flowId, request.OperationName, nodeVisit.Account.Id, CommonTransactionStatusCode.Unknown, null, request.Notifications, request.Recipients, false); activity.TransactionId = transactionId; string requestId = RequestManager.CreateDataRequest(transactionId, solicitService.Id, 0, -1, RequestType.Solicit, nodeVisit.Account.Id, request.Parameters); TransactionStatus transactionStatus = TransactionManager.SetTransactionStatus(transactionId, CommonTransactionStatusCode.Received, null, false); NotificationManager.DoSolicitNotifications(transactionStatus, flowId, request.FlowName, nodeVisit.Account.NaasAccount, request.OperationName, request.Parameters); SolicitProcessor.Wakeup(); return(transactionStatus); } catch (Exception ex) { if (transactionId != null) { TransactionManager.SetTransactionStatusNoThrow(transactionId, CommonTransactionStatusCode.Failed, ex.Message, false); } if (activity != null) { activity.Append(ExceptionUtils.ToShortString(ex)); activity.Type = ActivityType.Error; } if (ex is SoapException) { throw; // Throw directly since already SoapException } else { throw FaultProvider.GetFault(visit.Version, ex); } } finally { if (activity != null) { ActivityManager.Log(activity); } } }