Псевдокод транзакции в среде веб-служб
StoreServiceClient storeServiceClient = new StoreServiceClient(url);
StoreOperationDTO operation1 = storeServiceClient.CreateOperation(store1.Id);
operation1.Type = StoreOperations.Remove;
operation1.ProductId = product.Id;
operation1.Quantity = quantity;
StoreOperationDTO operation2 = storeServiceClient.CreateOperation(store2.Id);
operation2.Type = StoreOperations.Append;
operation2.ProductId = product.Id;
operation2.Quantity = quantity;UnitOfWork uow = new UnitOfWork;
uof.RegisterDirty(operation1);
uof.RegisterDirty(operation2);
try
{
storeServiceClient.ProcessOperations(uow);
}
catch (Exception e)
{
ShowError("Ошибка выполнения операции: " + e.toString);
}Вторым «упрощением» стал переход от понятных прикладному программисту деклараций интерфейсов объектов и служб на языке IDL [82] к WSDL [83] – описаниям, ориентированным, прежде всего, на обработку компьютером. Сравним декларации складской службы, возвращающей по запросу текущее количество товарных позиций.
Декларация службы в CORBA IDL
module StockServices
{
typedef float CurrentQuantity;
struct QuantityRequest
{
string stockSymbol;
};
interface StockInventoryService
{
CurrentQuantity getCurrent(in QuantityRequest request);
};
};Декларация службы в WSDL
version ="1.0" encoding
="utf-8"?>xmlns: sqs
="http://mycompany.com/stockinventoryservice.wsdl"xmlns: sqsxsd
="http://mycompany.com/stockinventoryservice.xsd"xmlns: soap
="http://schemas.xmlsoap.org/wsdl/soap/"xmlns: wsdl
="http://schemas.xmlsoap.org/wsdl/"xmlns: xsd
="http://www.w3.org/2000/10/XMLSchema">type
binding
="sqs: StockInventoryServiceBinding">