Читаем Дефрагментация мозга. Софтостроение изнутри полностью

Псевдокод транзакции в среде веб-служб

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"?>

name ="StockInventoryService"

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">

name ="CurrentQuantity">

name ="stockSymbol" type ="string"/>

name ="CurrentQuantity">

name ="quantity" type

="float"/>

name ="CurrentQuantity">

name ="quantity" type ="float"/>

name ="getCurrentInput">

name ="body" element ="sqsxsd: CurrentQuantity"/>

name ="getCurrentOutput">

name ="body" element ="sqsxsd: CurrentQuantity"/>

name ="StockInventoryServicePortType">

name ="getCurrent">

message ="sqs: getCurrentInput"/>

message ="sqs: getCurrentOutput"/>

name ="StockInventoryServiceSoapBinding"

type ="sqs: StockInventoryServicePortType">

style ="document" transport ="http://schemas.xmlsoap.org/soap/http"/>

name ="getCurrent">

soapAction ="http://mycompany.com/getCurrent"/>

use ="literal"/>

use ="literal"/>

name ="StockInventoryService">

name ="StockInventoryServicePort"

binding ="sqs: StockInventoryServiceBinding">

location ="http://mycompany.com/StockInventoryService"/>

Перейти на страницу:
Нет соединения с сервером, попробуйте зайти чуть позже