Esempio n. 1
0
 public CompositeType GetDataUsingDataContract(CompositeType composite)
 {
     if (composite == null)
     {
         throw new ArgumentNullException("composite");
     }
     if (composite.BoolValue)
     {
         composite.StringValue += "Suffix";
     }
     return composite;
 }
Esempio n. 2
0
        public CompositeType GetDataUsingDataContract(CompositeType composite)
        {
            if (composite == null)
            {
                // 异常处理的第一种方式:
                // (服务端)抛出和(客户端)捕获SOAP Fault
                throw new FaultException("传入的参数不能为 NULL !",  new FaultCode("P00001"));
            }

            if (composite.BoolValue)
            {
                composite.StringValue += "Suffix";
            }
            return composite;
        }
Esempio n. 3
0
        public CompositeType TestFaults(CompositeType composite)
        {
            if (composite == null)
            {
                // 异常处理的第二种方式:
                // 使用强类型Faults

                SystemFault sf = new SystemFault() {
                    SystemOperation = "TestFaults",
                    SystemReason = "composite is null",
                    SystemMessage = "传入的参数不能为 NULL !"
                };

                throw new FaultException<SystemFault>(sf);
            }

            if (composite.BoolValue)
            {
                composite.StringValue += "Suffix";
            }
            return composite;
        }