WS-ReliableMessaging

ได้รับการบ้านวิชา Webservice ข้อ8.1 มาซึ่งจะต้องส่งก่อนวันพุธที่จะถึงนี้เลยต้องมาหาความรู้กันหน่อย แล้วถ้าจะเก็บเอาไว้คนเดียวให้ราขึ้นก็กระไรอยู่ก็เลยมาอัพบล็อคซะเลยอ่ะคะ

8.1 Assume that the purchase order service allows its clients to make bulk order submission under the condition that bulk orders are submitted as part of the same sequence and that WS- ReliableMessaging is used to perform the submissions.
Encode an SOAP header using WS-ReliableMessaging to address this problem.Use the code snippet in Listing 8.1 to help you develop your solution.

What is Reliable Message ??

Realiable Message คือ มาตรการที่ถูกกำหนดขึ้นเพื่อเพิ่มความน่าเชื่อถือให้กับการรับส่งข้อมูล โดยเป็นการรับรองว่า Message ที่ส่งไปจะถึงมือผู้รับอย่างแน่นอน

What is WS-ReliableMessaging ??

WS-ReliableMessaging describes a protocol that allows SOAP messages to be delivered reliably between distributed applications in the presence of software component, system, or network failures.

ที่มา : http://en.wikipedia.org/wiki/WS-ReliableMessaging

WS-ReliableMessaging ใช้ในการกำหนดมาตรการที่ทำให้การรับส่งข้อมูลมีความน่าเชื่อถือมากขึ้น โดย WS-ReliableMessaging ทำให้เกิดกระบวณการที่สำคัญคือ

– Service Provider จะต้องแจ้งผลลัพธ์ของการส่ง Message กลับไป ไม่ว่าการส่ง Message นั้นจะเสร็จสมบูรณ์หรือไม่ก็ตาม

– ผู้รับได้รับ Message ตามลำดับที่ระบุไว้

จุดประสงค์สำคัญของ WS-ReliableMessaging คือ การสร้างกลไกย่อยๆ เพื่อเพิ่มเติมความน่าเชื่อถือให้กับการส่ง Message โดยระบุ Messaging Protocol และร่องรอยเส้นทางเดิน (Track)  ของ Message รวมถึงควบคุมกิจกรรมต่างๆ ของ Message ที่ใช้รับส่งกันระหว่างต้นทางและปลายทาง เพื่อเพิ่มเติมความน่าเชื่อถือให้กับ Message ยิ่งขึ้น

กระบวณการหลัก  WS-ReliableMessaging

1. Send (ส่ง) : Application Source ของ Initial Sender ส่ง message ไปยัง RM Source

2. Transmit (ลำเลียง): RM Source ทำหน้าที่เป็นโหนดสำหรับส่งผ่านข้อมูลและลำเลียงไปยัง RM Destination

3. Receive (รับ) : RM Destination รับ message

4. Acknowledge (แจ้งกลับ) : เมื่่อ RM Destination รับ Message แล้วจะแจ้งกลับไปยัง RM Source

5. Deliver (ส่งต่อ) : RM Destination จะทำการส่งต่อ Message ไปยัง Application Destination ของ Ultimate Receiver ต่อไป

ตัวอย่าง

1. การเชื่อมต่อจะเริ่มขึ้นเมื่อ RM source ส่ง <CreateSequence> ใส่ไปยัง body ของ messageเพื่อสร้าง RM sequence.

<wsrm:CreateSequence …>

</wsrm:CreateSequence>

เช่น


<soapenv:Body>

<wsrm:CreateSequence xmlns:wsrm=”http://schemas.xmlsoap.org/ws/2005/02/rm”>

<wsrm:AcksTo>
<wsa:Address>http://www.w3.org/2005/08/addressing/anonymous</wsa:Address>
</wsrm:AcksTo>

<wsrm:Offer>
<wsrm:Identifier>urn:uuid:546F6F33FB7D8BBE351179807372769</wsrm:Identifier>
</wsrm:Offer>

</wsrm:CreateSequence>

</soapenv:Body>

2. RM destinationจะส่งการตอบกลับด้วย  <CreateSequenceReponse> หรือ <CreateSequenceRefused>

<wsrm:CreateSequenceResponse …>
<wsu:Identifier> [URI] </wsu:Identifier>

</wsrm:CreateSequenceResponse>

เช่น


<soapenv:Body>

<wsrm:CreateSequenceResponse xmlns:wsrm=”http://schemas.xmlsoap.org/ws/2005/02/rm”>

<wsrm:Identifier>urn:uuid:879853A6871A66641C1179807373270</wsrm:Identifier>
<wsrm:Accept>

<wsrm:AcksTo>
<wsa:Address>http://localhost:9000/services/ReliableStockQuoteService</wsa:Address>

</wsrm:AcksTo>

</wsrm:Accept>

</wsrm:CreateSequenceResponse>

</soapenv:Body>

3. หลัง sequence เริ่มขึ้น จะมีการเพิ่มเติมในส่วนของ SOAP Header ใน message  เมื่อ Client ส่ง message และรอจนกระทั่ง messageทั้งหมดได้รับacknowledgements.

<wsrm:Sequence …>

<wsu:Identifier> [URI] </wsu:Identifier>
<wsrm:MessageNumber> [unsignedLong] </wsrm:MessageNumber>
<wsrm:LastMessage/>?
<wsu:Expires> [dateTime] </wsu:Expires>?

</wsrm:Sequence>

เช่น

<wsrm:Sequence>

<wsu:Identifier>http://fabrikam123.com/abc</wsu:Identifier>
<wsrm:MessageNumber>10</wsrm:MessageNumber>
<wsrm:LastMessage/>

</wsrm:Sequence>

4. RM source จะส่ง <SequenceAcknowledgement> เมื่อ message ทั้งหมดได้รับการแจ้งกลับ

<wsrm:SequenceAcknowledgement …>

<wsu:Identifier> [URI] </wsu:Identifier>
[ <wsrm:AcknowledgementRange …
Upper=”[unsignedLong]”
Lower=”[unsignedLong]”/> +
| <wsrm:Nack>[unsignedLong]</wsrm:Nack> + ]

<wsrm:SequenceAcknowledgement>

เช่น

<wsrm:SequenceAcknowledgement>

<wsu:Identifier>http://fabrikam123.com/abc</wsu:Identifier>
<wsrm:AcknowledgementRange Upper=”2″ Lower=”1″/>
<wsrm:AcknowledgementRange Upper=”6″ Lower=”4″/>
<wsrm:AcknowledgementRange Upper=”10″ Lower=”8″/>

</wsrm:SequenceAcknowledgement>

5.  ผู้เริ่มต้นสามารถหยุดการส่งได้ด้วย <TerminateSequence> message

<wsrm:TerminateSequence …>
<wsu:Identifier> [URI] </wsu:Identifier>

</wsrm:TerminateSequence>

เช่น

<S:Envelope xmlns:S=”http://www.w3.org/2003/05/soap-envelope”
xmlns:wsrm=”http://schemas.xmlsoap.org/ws/2005/01/rm”>

<S:Header>

</S:Header>
<S:Body>

<wsrm:TerminateSequence>

<wsrm:Identifier>http://example.com/sequence/67</wsrm:Identifier>

</wsrm:TerminateSequence>

</S:Body>

</S:Envelope>

อ้างอิง

– การพัฒนาระบบด้วยสถาปัตยกรรมเชิงบริการบนเทคโนโลยีของ Web Service – สุธี พงศาสกุลชัย

http://www.sysnetint.com/presentations/EnterpriseIntegrationWithSOAAndESB.pdf

http://specs.xmlsoap.org/ws/2005/02/rm/ws-reliablemessaging.pdf

http://www.srdc.metu.edu.tr/webpage/seminars/WebServices/WS-ReliableMessaging.ppt

Leave a comment