paymentauthextension.cs

来自「《ASP.NET 2.0 XML 高级编程(第3版)》 《ASP.NET 2.」· CS 代码 · 共 43 行

CS
43
字号
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Services.Protocols;

public class PaymentAuthExtension : SoapExtension
{
	public override void ProcessMessage(SoapMessage message)
	{
		if (message.Stage == SoapMessageStage.AfterDeserialize)
		{
			//Check for an SoapPaymentHeader containing valid credit card information
			foreach (SoapHeader header in message.Headers)
			{
				if (header is SoapPaymentHeader)
				{
					SoapPaymentHeader paymentHeader = (SoapPaymentHeader)header;
					if (paymentHeader.CreditCardNumber.Length != 0 && paymentHeader.NameOnCard.Length != 0)
						return; // Allow call to execute
					break;
				}
			}
			// Throw an exception if we get here			
			throw new SoapException("Invalid credit card information", SoapException.ClientFaultCode);
		}
	}

	public override Object GetInitializer(Type type)
	{
		return GetType();
	}

	public override Object GetInitializer(LogicalMethodInfo info, SoapExtensionAttribute attribute)
	{
		return null;
	}

	public override void Initialize(Object initializer)
	{
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?