1 / 61

Formal Modeling and Verification of Web services

CS 290C: Formal Models for Web Software Lectures 14: Formal Modeling and Analysis of Orchestration and Choreography Specifications Instructor: Tevfik Bultan. Formal Modeling and Verification of Web services. There has been a lot of work on formal modeling and verification of web services

leroycarter
Download Presentation

Formal Modeling and Verification of Web services

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CS 290C: Formal Models for Web Software Lectures 14: Formal Modeling and Analysis of Orchestration and Choreography SpecificationsInstructor: Tevfik Bultan

  2. Formal Modeling and Verification of Web services • There has been a lot of work on formal modeling and verification of web services • These efforts mostly focused on analyzing composite services specified using orchestration and choreography languages • For example, there has been work on formally modeling BPEL and WS-CDL specifications as state machines and then automatically verifying their properties using model checking • I will give an overview of some work in this area

  3. Formal Modeling and Analysis of Orchestration • Basic Idea: • Automatically convert BPEL specifications to state machine models • Automatically analyze state machine models using a verification tool • This approach has been implemented by developing tools that translate BPEL specifications to Promela

  4. BPEL to State Machine Translation Each atomic BPEL activities can be translated to a state machine • single entry, single exit, and may have several exception exits • Transitions have guards (extended state machine) <assign … > <copy> <from = “yes” /> <to var = “aprvInfo” part = “accept” </copy> </assign> [apprvInfo/accept := ‘yes’] <receive … operation = “approve” variable = “request” /> [request := approve_In] ?approve_In

  5. BPEL to State Machine Translation [aprvInfo := approve_Out] [approve_In := request] <scope> <invoke … operation="approve”, invar="request“, outvar="aprvInfo” /> <catch …faultname="loanfault“> < ... handler1 ... /> </catch> </scope> !approve_In loanfault ? loanfault  ?approve_Out handler1 

  6. BPEL to State Machine Translation • Control flow constructs can be handled by composing state machines <sequence …/> fault1 fault2 <… act1…/> act1 act2  <… act2…/> </sequence …/> <flow …/> <… act1 …> act1 act2 <… act2 … > </flow …/> product

  7. BPEL to State Machine Translation • We can translate BPEL specifications to a state machine representation by recursively applying translation rules like we describe above • However, BPEL specifications do not only have control flow constructs • they can also contain branch conditions and assignment statements expressed using Xpath • So we have to use an extended state machine representation which keeps the branch conditions, assignments, etc.

  8. Extended State Machines • Use an extended state machine model where the transitions can gave guards and updates • Guards and updates are on XML messages and use MSL and XPath • MSL for declaring message types • MSL (Model Schema Language) is a compact formal model language which captures core features of XML Schema • XPath expressions for guards • XPath is a language for writing expressions (queries) that navigate through XML trees and return a set of answer nodes

  9. Translating Extended State Machines to Promela • Translate the extended state machine model to Promela and use the SPIN model checker to verify the properties of the orchestration • SPIN is a finite state model checker • Need to restrict XML message contents to finite domains • Translating extended state machine models to Promela • First, translate MSL type declarations to Promela type declarations • Then, translate XPath expressions to Promela code

  10. Mapping MSL types to Promela • Basic types • integer and boolean types are mapped to Promela basic types int and bool • We only allow constant string values and strings are mapped to enumerated type (mtype) in Promela • Other type constructors are handled using • structured types (declared using typedef) in Promela • or arrays

  11. Mapping MSL type constructors to Promela • t[g ] is translated to a typedef declaration • g{m ,n } is translated to an array declaration • g1,g2 is translated to a sequence of type declarations • g1|g2is translated to a sequence of type declarations and an enumerated variable which is used to record which type is chosen • g1&g2 unordered type sequence can cause state-space explosion, so it is better to convert them to an ordered sequence after choosing a fixed ordering

  12. Example typedef t1_investorID{ mtype stringvalue;} typedef t2_stockID{int intvalue;} typedef t3_requestList{ t2_stockID stockID [3]; int stockID_occ; } typedef t4_accountNum{int intvalue;} typedef t5_creditCard{int intvalue;} mtype {m_accountNum, m_creditCard} typedef t6_payment{ t4_accountNum accountNum; t5_creditCard creditCard; mtype choice; } typedef Register{ t1_investorID investorID; t3_requestList requestList; t6_payment payment; } Register[ investorID[string] , requestList[ stockID[int]{1,3} ] , payment[ creditCardNum[int] | accountNum[int] ] ]

  13. XPath to Promela • Generate code that evaluates the XPath expression • Traverse the XPath expression from left to right • Code generated in each step is inserted into the BLANK spaces left in the code from the previous step • A tree representation of the MSL type is used to keep track of the context of the generated code • Uses two data structures • Type tree shows the structure of the corresponding MSL type • Abstract statements which are mapped to Promela code

  14. $request//stockID=$register//stockID[int()>5][position()=last()]$request//stockID=$register//stockID[int()>5][position()=last()] /* result of the XPath expression */ bool bResult = false; /* results of the predicates 1, 2, and 1 resp. */ bool bRes1, bRes2, bRes3; /* index, position(), last(), index, position() */ int i1, i2, i3, i4, i5; i2=1; /* pre-calculate the value of last(), store in i3 */ i4=0; i5=1; i3=0; do :: i4 < v_register.requestList.stockID_occ -> /* compute first predicate */ bRes3 = false; if :: v_register.requestList.stockID[i4].intvalue>5 -> bRes3 = true :: else -> skip fi; if :: bRes3 -> i5++; i3++; :: else -> skip fi; i4++; :: else -> break; od;

  15. $request//stockID=$register//stockID[int()>5][position()=last()]$request//stockID=$register//stockID[int()>5][position()=last()] i1=0; do :: i1 < v_register.requestList.stockID_occ -> bRes1 = false; if :: v_register.requestList.stockID[i1].intvalue>5 -> bRes1 = true :: else -> skip fi; if :: bRes1 -> bRes2 = false; if :: (i2 == i3) -> bRes2 = true; :: else -> skip fi; if :: bRes2 -> if :: (v_request.stockID.intvalue == v_register.requestList.stockID[i1].intvalue) -> bResult = true; :: else -> skip fi :: else -> skip fi; i2++; :: else -> skip fi; i1++; :: else -> break; od;

  16. Model Checking Using Promela • Can analyze the SAS example from the previous lecture • 3 peers: Investor, Broker, ResearchDept. • An error was found in the specification using Spin • Investor  Broker: a registerList of stockIDs • Broker  ResearchDept.: • relay request (1 stockID per request) • find the stockID in the latest request, send its subsequent stockID in registerList • Repeating stockID will cause error. • Only discoverable by analysis of XPath expressions

  17. Orchestration Verification • What we have discussed was an automated verification approach for orchestrations written in BPEL • The basic idea is to • represent BPEL specifications as extended sate machines • generate Promela specifications for these extended state machines (by bounding the data) • and verify their properties using the Spin model checker • The question is can we use a similar approach for services which involve interaction among multiple processes (for example an orchestrated service interacting with another orchestrated service) • Let’s first recall the orchestration vs. choreography issue

  18. Composing Services Two dimensions: • Define an executable process that interacts with existing services and executes them in a particular order and combines the results to achieve a new goal • Orchestration: From atomic services to stateful services • Specify how the individual services should interact with each other. Find or construct individual services that follow this interaction specification • Choreography: Global specification of interactions among services

  19. Orchestration vs. Choreography • Orchestration: Central control of the behavior of a distributed system • Like a conductor conducting an orchestra • Conductor is in charge during the performance • Orchestration specifies an executable process, identifying when and how that process should interact with other services • Orchestration is used to specify the control flow of a composite web service (as opposed to an atomic web service that does not interact with any other service)

  20. Orchestration vs. Choreography • Choreography: Specification of the behavior of a distributed system without centralized control • Choreographer specifies the behavior of the dancing team • Choreographer is not present during the execution • A choreography specifies how the services should interact • It specifies the legal sequences of messages exchanged among individual services (peers) • It is not necessarily executable • A choreography can be realized by writing an orchestration for each peer involved in the choreography • Choreography as global behavior specification • Orchestration as local behavior specification that realizes the global specification

  21. Choreography with WS-CDL • Web Services Choreography Description Language (WS-CDL) • WS-CDL specifications describe ``peer-to-peer collaborations of Web Services participants by defining, from a global viewpoint, their common and complementary observable behavior; where ordered message exchanges result in accomplishing a common business goal.'' • A WS-CDL specification describes the interaction ordering among a set of peers using basic and structured activities • Basic activities: INTERACTION, PERFORM, ASSIGN, SILENT ACTION, NO ACTION • Structured activities: SEQUENCE, PARALLEL, CHOICE, PICK, FLOW, SCOPE, COMPENSATE

  22. Choreography Specifications & State Machines • Choreography specifications can also be translated to state machine models like the orchestration specifications • As we did for BPEL specifications, given a WS-CDL specification • map the basic actions of a choreography (such as an assignment or message exchange) to transitions of basic state machines • map control flow constructs to various compositions of state machines

  23. SAS Choreography Model • State machine representation of the SAS choreography model report ack 1 6 7 8 register request cancel ack request reject accept bill 3 2 5 9 report terminate 4 12 11 10 bill cancel terminate

  24. Another Issue: Asynchronous Messages • Remember that one of the goals in web services is to achieve loose coupling among services that interact with each other • One way to achieve this message-based interactions and asynchronous messaging • Asynchronous messaging: • Sender does not have to wait for the receiver • Message is inserted to a message queue • Messaging platform guarantees the delivery of the message

  25. Asynchronous Messages • Why support asynchronous messaging? • Otherwise the sender has to block and wait for the receiver • Sender may not need any data to be returned • If the sender needs some data to be returned, it should wait when it needs to use that data • Asynchronous messaging can alleviate the latency of message transmission through the Internet • Asynchronous messaging can prevent sender from blocking if the receiver service is temporarily unavailable • Rather then creating a thread to handle the send, use asynchronous messaging

  26. Choreography Analysis • So, we can assume the following formal model • We have a choreography model which corresponds to a state machine and characterizes the ordering of interactions (message-exchanges) among different services • We can also assume that each service participating in a choreography is also specified as a state machine model (maybe extracted from an orchestration specification) • We also assume that different services participating in the choreography are interacting with asynchronous messages • Given this framework, some interesting analysis and verification problems arise

  27. Choreography Analysis • I will explain issues about choreography analysis using an example which describes how two professors and a grad student go to lunch at UCSB

  28. Going to Lunch at UCSB • Before Xiang graduated from UCSB, Xiang, Jianwen and I were using the following protocol for going to lunch: • Sometime around noon one of us would call another one by phone and tell him where and when we would meet for lunch. • The receiver of this first call would call the remaining peer and pass the information. • Let’s call this protocol the First Caller Decides (FCD) protocol. • At the time we did not have answering machines or voicemail!

  29. FCD Protocol Scenarios • Possible scenario • Tevfik calls Jianwen with the decision of where and when to eat • Jianwen calls Xiang and passes the information • Another scenario • Jianwen calls Tevfik with the decision of where and when to eat • Tevfik calls Xiang and passes the information

  30. FCD Protocol Scenarios • Yet another scenario • Tevfik calls Xiang with the decision of where and when to eat • Maybe Jianwen also calls Xiang at the same time with a different decision. But the phone is busy. • Jianwen keeps calling. But Xiang is not going to answer because according to the protocol the next thing Xiang has to do is call Jianwen. • Xiang calls Jianwen and passes the information

  31. FCD Protocol: Tevfik’s Behavior Let’s look at all possible behaviors of Tevfik based on the FCD protocol Tevfik is hungry Tevfik receives a call from Jianwen passing him the lunch decision Tevfik calls Jianwen with the lunch decision Tevfik receives a call from Xiang passing him the lunch decision Tevfik calls Xiang with the lunch decision Tevfik receives a call from Xiang telling him the lunch decision that Tevfik has to pass to Jianwen

  32. FCD Protocol: Tevfik’s Behavior T->J(D) Message Labels: Tevfik calls Jianwen with the lunch decision !send ?receive J->X(P) Jianwen calls Xiang to pass the decision !T->J(D) ?J->T(P) ?X->T(P) !T->X(D) ?X->T(D) ?J->T(D) !T->X(P) !T->J(P)

  33. State machines for the FCD Protocol • Three state machines characterizing the behaviors of Tevfik, Xiang and Jianwen according to the FCD protocol Tevfik Xiang Jianwen ?J->X(P) !J->T(D) !X->J(D) ?T->J(P) !T->J(D) ?J->T(P) ?X->J(P) !X->T(D) ?T->X(P) !T->J(D) !J->X(D) ?X->T(P) ?T->X(D) ?X->T(D) ?J->X(D) ?J->T(D) ?X->J(D) ?T->J(D) !X->J(P) !X->T(P) !T->J(P) !J->X(P) !J->T(P) !T->X(P)

  34. FCD Protocol Has Voicemail Problems • When the university installed a voicemail system FCD protocol started causing problems • We were showing up at different restaurants at different times!

  35. Example Problem Scenario • Tevfik calls Xiang with the lunch decision • Jianwen also calls Xiang with the lunch decision • The phone is busy (Xiang is talking to Tevfik) so Jianwen leaves a message • Xiang calls Jianwen passing the lunch decision • Jianwen does not answer (he already left for lunch) so Xiang leaves a message • Jianwen shows up at a different restaurant! • Message sequence is: T->X(D) J->X(D)X->J(P) • The messages J->X(D) andX->J(P) are never consumed • This scenario is not possible without voicemail!

  36. A Different Lunch Protocol • To fix this problem, Jianwen suggested that we change our lunch protocol as follows: • As the most senior researcher among us Jianwen would make the first call to either Xiang or Tevfik and tell when and where we would meet for lunch. • Then, the receiver of this call would pass the information to the other peer. • Let’s call this protocol the Jianwen Decides (JD) protocol

  37. State machines for the JD Protocol • JD protocol works fine with voicemail! Xiang Jianwen Tevfik ?T->X(P) ?X->T(P) ?J->X(D) ?J->T(D) !J->T(D) !J->X(D) !T->X(P) !X->T(P)

  38. Conversations • The FCD and JD protocols specify a set of conversations • A conversation is the sequence of messages generated during an execution of the protocol • We can specify the set of conversations without showing how the peers implement them • we call such a specification a conversation protocol

  39. FCD and JD Conversation Protocols JD Protocol FCD Protocol T->X(D) J->X(D) J->T(D) J->X(D) X->T(D) X->J(D) T->J(D) J->T(D) J->X(P) X->T(P) T->J(P) J->T(P) X->T(P) T->X(P) T->X(P) X->J(P) Conversation set: { T->X(D)X->J(P), T->J(D)J->X(P), X->T(D)T->J(P), X->J(D)J->T(P), J->T(D)T->X(P), J->X(D)X->T(P) } Conversation set: { J->T(D)T->X(P), J->X(D)X->T(P)}

  40. Observations & Questions • The implementation of the FCD protocol behaves differently with synchronous and asynchronous communication whereas the implementation of the JD protocol behaves the same. • Can we find a way to identify such implementations? • The implementation of the FCD protocol does not obey the FCD protocol if asynchronous communication is used whereas the implementation of the JD protocol obeys the JD protocol even if asynchronous communication used. • Given a conversation protocol can we figure out if there is an implementation which generates the same conversation set?

  41. Conversations, Choreography, Orchestration • A conversation protocol is a choreography specification • A conversation set corresponds to a choreography • A conversation set can be specified using a choreography language such as WS-CDL • One can translate WS-CDL specifications to conversation protocols • Peer state machines are orchestrations • A peer state machine can be specified using an orchestration language such as WS-BPEL • One can translate WS-BPEL specifications to peer state machines

  42. A Model for Composite Web Services • A composite web service consists of • a finite set of peers • Lunch example: T, X, J • and a finite set of messages • Lunch example (JD protocol): J->T(D), T->X(P), J->X(D), X->T(P) T->X(P) Peer T Peer X X->T(P) J->T(D) J->X(D) Peer J

  43. Communication Model • We assume that the messages among the peers are exchanged using reliable and asynchronous messaging • FIFO and unbounded message queues Peer J Peer T J->T(D) J->T(D) • This model is similar to existing messaging platforms such as • JMS (Java Message Service) • Java API for XML messaging (JAXM) • MSMQ (Microsoft Message Queuing Service)

  44. Conversations T->X(P) J->T(D) • Record the messages in the order they are sent Peer T Peer X Generated conversation: J->T(D) T->X(P) Peer J • A conversation is a sequence of messages generated during an execution

  45. Properties of Conversations • The notion of conversation enables us to reason about temporal properties of the composite web services • LTL framework extends naturally to conversations • LTL temporal operators X (neXt), U (Until), G (Globally), F (Future) • Atomic properties Predicates on message classes (or contents) Example: G ( payment F receipt) • Model checking problem: Given an LTL property, does the conversation set satisfy the property?

  46. Bottom-Up vs. Top-Down Bottom-up approach • Specify the behavior of each peer • For example using an orchestration language such as WS-BPEL • The global communication behavior (conversation set) is implicitly defined based on the composed behavior of the peers • Global communication behavior is hard to understand and analyze Top-down approach • Specify the global communication behavior (conversation set) explicitly as a protocol • For example using a choreography language such as WS-CDL • Ensure that the conversations generated by the peers obey the protocol

  47. Top-Down vs. Bottom-Up J->T(D) J->X(D) Conversation Protocol LTL property ? GF(T->X(P)  X->T(P)) T->X(P) X->T(P) Peer T Peer X Peer J Input Queue !J->T(D) ?X->T(P) ?T->X(P) ?J->X(D) ?J->T(D) !J->X(D) !T->X(P) !X->T(P) ... ? Virtual Watcher GF(T->X(P)  X->T(P)) LTL property

  48. Conversation Protocols • Conversation Protocol: • An automaton that accepts the desired conversation set • A conversation protocol is a contract agreed by all peers • Each peer must act according to the protocol • For reactive protocols with infinite message sequences use: • Büchi automata which accept infinite strings • For specifying message contents, use: • Guarded automata • Guards are constraints on the message contents

  49. Synthesize Peer Implementations • Conversation protocol specifies the global communication behavior • How do we implement the peers? • How do we obtain the contracts that peers have to obey from the global contract specified by the conversation protocol? • Project the global protocol to each peer • By dropping unrelated messages for each peer

  50. Question If this equality holds the conversation protocol is realizable • The JD protocol is realizable • The FCD protocol is not realizable Are there conditions which ensure the equivalence? ? Conversations specified by the conversation protocol  Conversations generated by the projected services

More Related