コード例 #1
0
      /// <summary>
      ///    Enables the creation of a custom System.ServiceModel.FaultException{TDetail}
      ///    that is returned from an exception in the course of a service method.
      /// </summary>
      /// <param name="error">The System.Exception object thrown in the course of the service operation.</param>
      /// <param name="version">The SOAP version of the message.</param>
      /// <param name="fault">
      ///    The System.ServiceModel.Channels.Message object that is returned to the client, or service in
      ///    duplex case
      /// </param>
      public void ProvideFault(Exception error, MessageVersion version, ref Message fault)
      {
         if (error is FaultException<ApplicationServiceError>)
         {
            var messageFault = ((FaultException<ApplicationServiceError>) error).CreateMessageFault();

            //propagate FaultException
            fault = Message.CreateMessage(
               version,
               messageFault,
               ((FaultException<ApplicationServiceError>) error).Action);
         }
         else
         {
            //create service error
            var defaultError = new ApplicationServiceError()
            {
               ErrorMessage = Messages.message_DefaultErrorMessage
            };

            //Create fault exception and message fault
            var defaultFaultException = new FaultException<ApplicationServiceError>(defaultError);
            var defaultMessageFault = defaultFaultException.CreateMessageFault();

            //propagate FaultException
            fault = Message.CreateMessage(version, defaultMessageFault, defaultFaultException.Action);
         }
      }
コード例 #2
0
ファイル: ElectricCar.cs プロジェクト: Dadov/3rdsemproject
 public void addBooking(Booking b)
 {
     MBooking bk = new MBooking();
     bk.cId = b.cId;
     bk.createDate = DateTime.ParseExact(b.createDate, "dd/MM/yyyy", System.Globalization.CultureInfo.CurrentCulture);
     bk.creaditCard = b.payStatus;
     bk.tripStart = DateTime.ParseExact(b.tripStart, "dd/MM/yyyy HH:mm", System.Globalization.CultureInfo.CurrentCulture);
     bk.totalPrice = b.totalPrice;
     List<MBookingLine> bkls = new List<MBookingLine>();
     List<BookingLine> bls = b.bookinglines.ToList<BookingLine>();
     for (int i = 0; i < bls.Count; i++)
     {
         MBookingLine bl = new MBookingLine();
         bl.price = bls[i].price;
         bl.quantity = bls[i].quantity;
         bl.Station.Id = bls[i].station.Id;
         bl.time = bls[i].time;
         bl.BatteryType.id = bls[i].BatteryType.ID;
         bkls.Add(bl);
     }
     bk.bookinglines = bkls;
     BookingCtr bCtr = new BookingCtr();
     if (!bCtr.addBooking(bk))
     {
         FaultException f = new FaultException("Booking failed because one of the station is fully booked");
         throw f;
     }
 }
コード例 #3
0
        /// <summary>
        /// Enables the creation of a custom System.ServiceModel.FaultException{TDetail}
        /// that is returned from an exception in the course of a service method.
        /// </summary>
        /// <param name="error">The System.Exception object thrown in the course of the service operation.</param>
        /// <param name="version">The SOAP version of the message.</param>
        /// <param name="fault">The System.ServiceModel.Channels.Message object that is returned to the client, or service in duplex case</param>
        public void ProvideFault(Exception error, System.ServiceModel.Channels.MessageVersion version, ref System.ServiceModel.Channels.Message fault)
        {
            if (error is FaultException<ApplicationServiceError>)
            {
                MessageFault messageFault = ((FaultException<ApplicationServiceError>)error).CreateMessageFault();

                //propagate FaultException
                fault = Message.CreateMessage(version, messageFault, ((FaultException<ApplicationServiceError>)error).Action);
            }
            else
            {
                //create service error
                ApplicationServiceError defaultError = new ApplicationServiceError()
                {
                    ErrorMessage = Resources.Messages.message_DefaultErrorMessage
                };

                //Create fault exception and message fault
                FaultException<ApplicationServiceError> defaultFaultException = new FaultException<ApplicationServiceError>(defaultError);
                MessageFault defaultMessageFault = defaultFaultException.CreateMessageFault();

                //propagate FaultException
                fault = Message.CreateMessage(version, defaultMessageFault, defaultFaultException.Action);
            }
        }
コード例 #4
0
        /********************************************************************/
        /*****************************FIN IVAN*******************************/
        /********************************************************************/
        /********************************************************************/
        /*****************************MIGUEL*********************************/
        /********************************************************************/
        /// <summary>
        /// Método que añade una accion comercial a la base de datos
        /// </summary>
        /// <param name="accion"> Objeto usuario a añadir en la base de datos</param>
        /// <returns>Devuelve true si se ha añadido el registro correctamente. False si no.</returns>
        public int addAccionComercial(AccionComercialData accion)
        {
            if (accion == null) return -1;
            try
            {
                using (GestionEmpresasEntities db = new GestionEmpresasEntities())
                {
                    AccionComercial nuevo = new AccionComercial();
                    nuevo.descripcion = accion.descripcion;
                    nuevo.comentarios = accion.comentarios;
                    nuevo.fechaHora = accion.fechaHora;
                    nuevo.idUsuario = accion.idUsuario;
                    nuevo.idTipoAccion = accion.idTipoAccion;
                    nuevo.idEstadoAccion = accion.idEstadoAccion;
                    nuevo.idEmpresa = accion.idEmpresa;

                    db.AccionComercial.Add(nuevo);
                    db.SaveChanges();
                    return nuevo.idAccion;
                }
            }
            catch (SqlException ex)
            {
                FaultException fault = new FaultException("ERROR SQL: " + ex.Message,
                                                            new FaultCode("SQL"));
                throw fault;
            }
            catch (Exception ex)
            {
                FaultException fault = new FaultException("ERROR: " + ex.Message,
                                                            new FaultCode("GENERAL"));
                throw fault;
            }
        }
コード例 #5
0
        /// <summary>
        /// Converts to dictionary.
        /// </summary>
        /// <param name="metaData">The meta data.</param>
        /// <param name="customError">Parameter for returning the exception.</param>
        /// <returns>dictionary</returns>
        internal Dictionary<string, string> ConvertToDictionary(string metaData, out FaultException customError)
        {
            customError = null;

            if (!string.IsNullOrEmpty(metaData))
            {
                var returnHashTable = new Dictionary<string, string>();
                try
                {
                    // spliting using the seperators
                    var metaDataSeparators = new string[] { "~|#" };
                    var split = metaData.Split(metaDataSeparators, StringSplitOptions.None);

                    foreach (string t in split)
                    {
                        var valueSeparators = new string[] { "~|~" };
                        var value = t.Split(valueSeparators, StringSplitOptions.None);
                        returnHashTable.Add(value[0].Trim(), value[1].Trim());
                    }
                }
                catch (Exception e)
                {
                    Trace.TraceError(DateTime.Now + ": " + e.Message.ToString() + Environment.NewLine + e.StackTrace);
                    customError = new FaultException(e.Message);
                }

                return returnHashTable;
            }
            else
            {
                //customError = new FaultException(string.Format(Properties.Resources.NOT_VALID_STRING, "MetaData"));
            }
            return null;
        }
コード例 #6
0
    protected void btnHelloIErrorHandler_Click(object sender, EventArgs e)
    {
        ExceptionService.HelloClient proxy = new ExceptionService.HelloClient();
        try
        {
            proxy.HelloIErrorHandler();
        }
        catch (Exception ex)
        {
            System.ServiceModel.FaultException faultException = ex as System.ServiceModel.FaultException;

            if (faultException != null)
            {
                lblMsg.Text = string.Format("错误信息:{0}", faultException.Message);
            }
            else
            {
                lblMsg.Text = ex.ToString();
            }
        }
        finally
        {
            proxy.Close();
        }
    }
コード例 #7
0
        public static void Handle(FaultException faultException)
        {
            Exception innerException = null;
            if (faultException is FaultException<RecordNotFoundFault>)
            {
                var recordNotFoundFault = faultException as FaultException<RecordNotFoundFault>;
                innerException = new RecordNotFoundException(recordNotFoundFault.Message);
            }
            if (faultException is FaultException<InvalidRecordFault>)
            {
                var invalidRecordFault = faultException as FaultException<InvalidRecordFault>;
                innerException = new InvalidRecordException(invalidRecordFault.Message);
            }

            if (faultException is FaultException<DuplicateRecordFoundFault>)
            {
                var duplicateRecordFault = faultException as FaultException<DuplicateRecordFoundFault>;
                innerException = new DuplicateRecordFoundException(duplicateRecordFault.Message);
            }

            if (innerException == null)
            {
                throw faultException;
            }

            if (innerException == null)
            {
                throw faultException;
            }

            throw new StockException("A exception has occured.",innerException);
        }
コード例 #8
0
        public void ProvideFault(Exception error, MessageVersion version, ref Message fault)
        {
            var newEx = new FaultException(string.Format("服务端错误 {0}", error.TargetSite.Name));
            MessageFault msgFault = newEx.CreateMessageFault();

            fault = Message.CreateMessage(version, msgFault, newEx.Action);
        }
コード例 #9
0
ファイル: FaultExceptionTest.cs プロジェクト: nickchal/pash
		public void TestCode ()
		{
			// default Code is a SenderFault with a null SubCode
			FaultException<int> e = new FaultException<int> (0);
			Assert.IsTrue (e.Code.IsSenderFault);
			Assert.IsNull (e.Code.SubCode);
		}
コード例 #10
0
        public void ProvideFault(Exception error, MessageVersion version, ref Message fault)
        {
            FaultException faultException;
            var logger = LogManager.GetCurrentClassLogger();

            if (error != null && error is ObjectValidationException)
            {
                faultException = new FaultException<ValidationFault>(new ValidationFault(((ObjectValidationException)error).ValidationErrors.Select(item =>
                    new ValidationError
                    {
                        ErrorMessage = item.ErrorMessage,
                        ObjectName = item.ObjectName,
                        PropertyName = item.PropertyName
                    })), new FaultReason("Validation error"));

                logger.Error(error, "Validation error in GlobalError filter");
            }
            else
            {
                faultException = new FaultException<InternalServiceFault>(new InternalServiceFault(error,
                string.Format("Exception caught at GlobalErrorHandler{0}Method: {1}{2}Message:{3}",
                             Environment.NewLine, error.TargetSite.Name, Environment.NewLine, error.Message)));

                logger.Error(error, "Generic internal error in GlobalError filter");
            }
            // Shield the unknown exception
            //FaultException faultException = new FaultException<SimpleErrorFault>(new SimpleErrorFault(), new FaultReason("Server error encountered. All details have been logged."));
            //new FaultException("Server error encountered. All details have been logged.");
            MessageFault messageFault = faultException.CreateMessageFault();

            fault = Message.CreateMessage(version, messageFault, faultException.Action);
        }
コード例 #11
0
 void IErrorHandler.ProvideFault(Exception error, MessageVersion version, ref Message fault)
 {
     this.ErrorGuid = Guid.NewGuid();
     FaultException<ExceptionDetail> faultException = new FaultException<ExceptionDetail>(new ExceptionDetail(error) { Message = this.ErrorGuid.ToString() }, new FaultReason("ServiceError"));
     MessageFault messageFault = faultException.CreateMessageFault();
     fault = Message.CreateMessage(version, messageFault, faultException.Action);
 }
コード例 #12
0
        public void Execute(IServiceProvider serviceProvider)
        {
            //Extract the tracing service for use in debugging sandboxed plug-ins.
            ITracingService tracingService =
                (ITracingService)serviceProvider.GetService(typeof(ITracingService));
            FaultException ex1 = new FaultException();
            // Obtain the execution context from the service provider.
            IPluginExecutionContext context = (IPluginExecutionContext)
                serviceProvider.GetService(typeof(IPluginExecutionContext));

            try
            {
                IOrganizationServiceFactory serviceFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
                IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId);
                Entity target = (Entity)context.OutputParameters["BusinessEntity"];
                if (new UserLocaleHelper(service, context).getUserLanguage() == 1033) {
                    if (target.Attributes.Contains("address1_line1"))
                    {
                        target["name"] = target.GetAttributeValue<string>("address1_line1");
                    }
                    else
                    {
                        target["name"] = "testing";
                    }
                } else {
                    target["name"] = "French";
                }

            }
            catch (FaultException<OrganizationServiceFault> ex)
            {
                throw new InvalidPluginExecutionException("An error occurred in the multi lingual plug-in.", ex);
            }
        }
コード例 #13
0
        public void Submit(Order order)
        {
            Console.WriteLine("Begin to process the order of the order No.: {0}", order.OrderNo);
            FaultException exception = null;
            if (order.OrderDate < DateTime.Now) {
                exception = new FaultException(new FaultReason("The order has expried"), new FaultCode("sender"));
                Console.WriteLine("It's fail to process the order.\n\tOrder No.: {0}\n\tReason:{1}", order.OrderNo, "The order has expried");
            } else {
                Console.WriteLine("It's successful to process the order.\n\tOrder No.: {0}", order.OrderNo);
            }
            NetMsmqBinding binding = new NetMsmqBinding();
            binding.ExactlyOnce = false;
            binding.Security.Transport.MsmqAuthenticationMode = MsmqAuthenticationMode.None;
            binding.Security.Transport.MsmqProtectionLevel = ProtectionLevel.None;

            ChannelFactory<IOrderRessponse> channelFactory = new ChannelFactory<IOrderRessponse>(binding);
            OrderResponseContext responseContext = OrderResponseContext.Current;

            IOrderRessponse channel = channelFactory.CreateChannel(new EndpointAddress(responseContext.ResponseAddress));

            using (OperationContextScope contextScope = new OperationContextScope(channel as IContextChannel)) {
                channel.SubmitOrderResponse(order.OrderNo, exception);
            }
            Console.Read();
        }
コード例 #14
0
    /// <summary>
    /// calculates the collection of the error codes recevied from SQL stored procedure
    /// </summary>
    /// <param name="excobj"></param>
    /// <returns>new line separated error messages</returns>
    internal static string GetUserFriendlyErrorMessage(FaultException<ExceptionDetail> excobj) {
      string msg = string.Empty;

      string faultmsg = GetFaultExceptionMessage(excobj);

      string spname = faultmsg.Split('.')[0];
      int code = int.Parse(faultmsg.Split(':')[1]);
      List<int> codes = new List<int>();
      int quotbase = 1000;

      while (true) {
        if (code >= quotbase) {
          int modulo = code % quotbase;
          if (modulo == 0) {
            codes.Add(quotbase);
            break;
          }
          else if (modulo >= 1) {
            codes.Add(quotbase);
            code = code - quotbase;
            quotbase = quotbase / 10;
          }
        }
        else
          quotbase = quotbase / 10;
      }

      StringBuilder sb = new StringBuilder();
      foreach (int err in codes) {
        sb.AppendLine(string.Format("{0} - {1}", err, _SPErrorCodes.Find(e => e.ErrorCode == err && e.SPName == spname).ErrorMessage));
      }

      msg = sb.ToString();
      return msg;
    }
コード例 #15
0
ファイル: ErrorHandler.cs プロジェクト: kapitanov/diploma
        /// <summary>
        /// Enables the creation of a custom <see cref="T:System.ServiceModel.FaultException`1"/> that is returned from an exception in the course of a service method.
        /// </summary>
        /// <param name="error">
        /// The <see cref="T:System.Exception"/> object thrown in the course of the service operation.
        /// </param>
        /// <param name="version">
        /// The SOAP version of the message.</param>
        /// <param name="fault">
        /// The <see cref="T:System.ServiceModel.Channels.Message"/> object that is returned to the client, or service, in the duplex case.
        /// </param>
        public void ProvideFault(Exception error, MessageVersion version, ref Message fault)
        {
            // Shield the unknown exception
            var faultException = new FaultException("Server error encountered. All details have been logged.");
            var messageFault = faultException.CreateMessageFault();

            fault = Message.CreateMessage(version, messageFault, faultException.Action);
        }
コード例 #16
0
 public void ProvideFault(Exception error, MessageVersion version, ref Message fault)
 {
     if (error is FaultException)
         return;
     FaultException faultException = new FaultException("A general service error occured");
     MessageFault messageFault = faultException.CreateMessageFault();
     fault = Message.CreateMessage(version, messageFault, null);
 }
コード例 #17
0
        // Provide a fault. The Message fault parameter can be replaced, or set to null to suppress
        // reporting a fault.

        public void ProvideFault(Exception error, MessageVersion version, ref Message fault)
        {
            var newEx = new FaultException(
                $"Exception caught at GlobalErrorHandler{Environment.NewLine}Method: {error.TargetSite.Name}{Environment.NewLine}Message:{error.Message}");

            var msgFault = newEx.CreateMessageFault();
            fault = Message.CreateMessage(version, msgFault, newEx.Action);
        }
コード例 #18
0
        /// <summary>
        ///  Allows to add, modify, or suppress a fault message that is generated in response to an exception.
        /// </summary>
        /// <param name="error"></param>
        /// <param name="version"></param>
        /// <param name="fault"></param>
        public void ProvideFault(Exception error, MessageVersion version, ref Message fault)
        {
            FaultException<PricingException> faultException =
                new FaultException<PricingException>(new PricingException(error.Message,error.InnerException));
            MessageFault messageFault = faultException.CreateMessageFault();

            fault = Message.CreateMessage(version, messageFault, faultException.Action);
        }
コード例 #19
0
ファイル: ServiceFault.cs プロジェクト: jserna-arl/LIMSv2
 public ServiceFault(FaultException<ServiceFault> sf)
 {
     this.Exception = sf.Detail.GetType().Name;
     this.Type = sf.GetType().FullName;
     this.Message = sf.Detail.Message;
     this.StackTrace = sf.Detail.StackTrace;
     this.InnerException = sf.Detail.InnerException;
     if (sf.Detail.ValidationErrors != null) this.ValidationErrors = sf.Detail.ValidationErrors;
 }
コード例 #20
0
        public void When_Passed_A_Non_Typed_Fault_Exception_ToException_Returns_A_Generic_Exception()
        {
            var faultException = new FaultException("Test fault exception");
            var translator = new ExceptionTranslator();

            var result = translator.ToException(faultException);

            Assert.That(result, Is.TypeOf(typeof(System.Exception)));
        }
コード例 #21
0
 /// <summary>
 /// ProvideFault
 /// </summary>
 /// <param name="ex">ex</param>
 /// <param name="version">version</param>
 /// <param name="msg">msg</param>
 public void ProvideFault(Exception ex, MessageVersion version, ref Message msg)
 {
     //// 写入log4net
     //log.Error("WCF异常", ex);
     Logging.LogHelper.WriteError(string.Empty, "WCF异常", ex);
     var newEx = new FaultException(string.Format("WCF接口出错 {0}", ex.TargetSite.Name));
     MessageFault msgFault = newEx.CreateMessageFault();
     msg = Message.CreateMessage(version, msgFault, newEx.Action);
 }
コード例 #22
0
        public void ProvideFault(Exception error, MessageVersion version, ref Message fault)
        {
            if (error is FaultException) return;
            if (!error.GetType().IsSerializable) return;

            FaultException<GeneralServerFault> faultExc = new FaultException<GeneralServerFault>(new GeneralServerFault(error), new FaultReason("Server Level Error"));
            MessageFault messageFault = faultExc.CreateMessageFault();
            fault = Message.CreateMessage(version, messageFault, faultExc.Action);
        }
コード例 #23
0
ファイル: FaultExceptionTest.cs プロジェクト: nickchal/pash
		public void TestCreateMessageFault ()
		{
			FaultException<int> e = new FaultException<int> (0);				Assert.IsFalse (
				(object) MessageFault.CreateFault (e.Code, e.Reason, e.Detail)
				== e.CreateMessageFault (), "#1");
			AreMessageFaultEqual (
				MessageFault.CreateFault (e.Code, e.Reason, e.Detail), 
				e.CreateMessageFault (), "#2");
		}
コード例 #24
0
        public void When_Passed_A_Translatable_Fault_ToException_Returns_A_Generic_Exception()
        {
            var faultException = new FaultException<TestFault>(new TestFault(), "Test fault exception");
            var translator = new ExceptionTranslator();

            var result = translator.ToException(faultException);

            Assert.That(result, Is.TypeOf(typeof(TestException)));
        }
コード例 #25
0
        public void ProvideFault(Exception error, MessageVersion version, ref Message fault)
        {
            FaultException faultException = null;
            if (error is GetDataException)
                faultException = new FaultException<GetDataFault>(new GetDataFault());

            if (faultException != null)
                fault = Message.CreateMessage(version, faultException.CreateMessageFault(), faultException.Action);
        }
コード例 #26
0
        // Provide a fault. The Message fault parameter can be replaced, or set to
        // null to suppress reporting a fault.
        public void ProvideFault(Exception error, MessageVersion version, ref Message fault)
        {
            var newEx = new FaultException(
                string.Format("Exception caught at GlobalErrorHandler{0}Method: {1}{2}Message:{3}",
                             Environment.NewLine, error.TargetSite.Name, Environment.NewLine, error.Message));

            MessageFault msgFault = newEx.CreateMessageFault();
            fault = Message.CreateMessage(version, msgFault, newEx.Action);
        }
コード例 #27
0
 public void ProvideFault(Exception error, MessageVersion version, ref Message fault)
 {
     var realException = GetRealException(error);
     FaultException fe = new FaultException(realException.Message);
     MessageFault messageFault = fe.CreateMessageFault();
     fault = Message.CreateMessage(version, messageFault, "http://microsoft.wcf.documentation/default");
     HttpResponseMessageProperty property = new HttpResponseMessageProperty();
     property.StatusCode = System.Net.HttpStatusCode.OK;
     fault.Properties[HttpResponseMessageProperty.Name] = property;
 }
コード例 #28
0
        /// <summary>
        /// 启用创建从服务方法过程中的异常返回的自定义 System.ServiceModel.FaultException
        /// </summary>
        /// <param name="error">服务操作过程中引发的 Exception 异常。</param>
        /// <param name="version">消息的 SOAP 版本。</param>
        /// <param name="fault">双工情况下,返回到客户端或服务的 System.ServiceModel.Channels.Message 对象。</param>
        public void ProvideFault(Exception error, MessageVersion version, ref Message fault)
        {
            string err = string.Format("调用WCF接口 '{0}' 出错",
                    error.TargetSite.Name) + ",详情:\r\n" + error.Message;
            var newEx = new FaultException(err);

            MessageFault msgFault = newEx.CreateMessageFault();
            fault = Message.CreateMessage(version, msgFault, newEx.Action);
            LogHelper.Error(err,error);
        }
コード例 #29
0
        public void ProvideFault(Exception ex, MessageVersion version, ref Message msg)
        {
            _logger.Error("ServiceExceptionsHandler received unhandled exception", ex);

            var fe = new FaultException<UnhandledException>(UnhandledException.CreateFromEx(ex));
            var mf = fe.CreateMessageFault();
            msg = Message.CreateMessage(version, mf, string.Empty);

            _logger.Error("ServiceExceptionsHandler handled exception and sent ex data to client");
        }
コード例 #30
0
ファイル: ErrorHandler.cs プロジェクト: tmccord123/TMCDev
 public void ProvideFault(Exception error, MessageVersion version, ref Message fault)
 {
     if (error is FaultException) return;
     BusinessServiceException businessFault = new BusinessServiceException(error);
     FaultException<BusinessServiceException> faultEx =
         new FaultException<BusinessServiceException>(businessFault, "Error occurs in business service",
                                                      new FaultCode("BusinessServiceException"));
     MessageFault msgFault = faultEx.CreateMessageFault();
     fault = Message.CreateMessage(version, msgFault, faultEx.Action);
 }
コード例 #31
0
ファイル: Program.cs プロジェクト: pepipe/ISEL
 public string newAnnounce(string msg, int ex)
 {
     System.Threading.Thread.Sleep(5 * 1000);
     Console.WriteLine(msg);
     if (ex == -1) {
         FaultException<string> e = new FaultException<string>("erro", new FaultReason("ex=-1"));
         throw e;
     }
     else return "Callback with args=" + msg;
 }
コード例 #32
0
        private void button1_Click(object sender, EventArgs e)
        {
            string txtDestinationFolder = @"c:\pobrane_z_ePUAP";
            //string txtAdresSkrytki = "/zsisigidspzoo/skrytkaKD";
            string txtAdresSkrytki = "skrytkaKD";
            string txtNazwaSkrytki = "test KD";
            string txtPodmiot      = "zsisigidspzoo";


            //nowy komentarz

            //parametry do zapytania
            ZapytaniePullOczekujaceTyp zapBody = new ZapytaniePullOczekujaceTyp();

            zapBody.adresSkrytki = txtAdresSkrytki;
            zapBody.nazwaSkrytki = txtNazwaSkrytki;
            zapBody.podmiot      = txtPodmiot;

            textBox1.AppendText("Adres skrytki: " + zapBody.adresSkrytki + Environment.NewLine);
            textBox1.AppendText("Nazwa skrytki: " + zapBody.nazwaSkrytki + Environment.NewLine);
            textBox1.AppendText("Podmiot: " + zapBody.podmiot + Environment.NewLine);

            CustomBinding   pullBinding  = CreatePullBinding();
            EndpointAddress pullEndpoint = CreatePullEndpoint();

            //klient pull
            pullClient _client = new pullClient(pullBinding, pullEndpoint);

            X509Certificate2 certyfikatKlienta = GetClientCert();
            X509Certificate2 certyfikatSerwisu = GetServiceCert();

            _client.ClientCredentials.ClientCertificate.Certificate         = certyfikatKlienta;
            _client.ClientCredentials.ServiceCertificate.DefaultCertificate = certyfikatSerwisu;

            //certyfikat dostarczony przez ePUAP do podpisywanie nie daje się zwalidować pod względem nadrzędnych instytucji
            //tzn. chyba sami go sobie wystawiają
            _client.ClientCredentials.ServiceCertificate.Authentication.CertificateValidationMode = X509CertificateValidationMode.None;

            try
            {
                //sprawdź oczekujące dokumenty
                OdpowiedzPullOczekujaceTyp odp = _client.oczekujaceDokumenty(zapBody);

                textBox1.AppendText("Oczekujące dokumenty: " + odp.oczekujace.ToString());
            }
            catch (MessageSecurityException ex)
            {
                try
                {
                    System.ServiceModel.FaultException exInner = (FaultException)ex.InnerException;
                    textBox1.AppendText("Wyjątek 1: " + ex.Message);
                    if (ex.InnerException == null)
                    {
                        throw new Exception("Brak szczegółowych informacji o błędzie.");
                    }
                    FaultException fe = ex.InnerException as FaultException;
                    textBox1.AppendText("Wyjątek 2: " + fe.Message);
                    if (fe == null)
                    {
                        throw new Exception("Szczegółowe informacje zapisane zostały w nieprzewidzianym formacie.");
                    }
                    MessageFault mf = fe.CreateMessageFault();
                    if (mf == null)
                    {
                        throw new Exception("Wystąpił problem podczas odtwarzania szczegółowych informacji.");
                    }
                    XmlReader   xr = mf.GetReaderAtDetailContents();
                    XmlDocument xd = new XmlDocument();
                    xd.Load(xr);
                    XmlNode       elemKomunikat = xd.SelectSingleNode("//*[local-name() = 'komunikat']");
                    XmlNode       elemKod       = xd.SelectSingleNode("//*[local-name() = 'kod']");
                    StringBuilder msg           = new StringBuilder();
                    msg.Append("Wystąpił problem z doręczeniem dokumentów. Poniżej znajdują się szczegółowe informacje (komunikaty) przekazane przez ePUAP.");
                    msg.AppendFormat("Informacja z ePUAP: \"{0}, kod błędu: {1}\"", elemKomunikat.InnerText, elemKod.InnerText);
                    textBox1.AppendText(msg.ToString());
                }
                catch (Exception iex)
                {
                    //textBox1.AppendText(ex.Message);
                    //textBox1.AppendText(iex.Message);
                }
            }
            catch (Exception ex)
            {
                textBox1.AppendText(string.Format("Wystąpił błąd podczas pobierania liczby oczekujacych dokumentow:   " + ex.Message));
                textBox1.AppendText(string.Format("Wystąpił błąd podczas pobierania liczby oczekujacych source:   " + ex));
            }
        }
コード例 #33
0
 public FaultException(string reason)
     : base(reason)
 {
     _code   = FaultException.DefaultCode;
     _reason = FaultException.CreateReason(reason);
 }
コード例 #34
0
 public FaultException(FaultReason reason)
     : base(FaultException.GetSafeReasonText(reason))
 {
     _code   = FaultException.DefaultCode;
     _reason = FaultException.EnsureReason(reason);
 }
コード例 #35
0
 public FaultException(string reason, FaultCode code)
     : base(reason)
 {
     _code   = FaultException.EnsureCode(code);
     _reason = FaultException.CreateReason(reason);
 }
コード例 #36
0
 public FaultException(FaultReason reason, FaultCode code)
     : base(FaultException.GetSafeReasonText(reason))
 {
     _code   = FaultException.EnsureCode(code);
     _reason = FaultException.EnsureReason(reason);
 }