Professional Documents
Culture Documents
Bài Tập Soap
Bài Tập Soap
Viết một SOAP đơn giản tính phí qua thẻ tín dụng của một khách đã đặt chuyến
đi du lịch.
Soap yêu cầu cần có thông tin: Tên chủ thẻ, kiểu thẻ, số thẻ, số CVC và tháng năm
hết hạn.
Soap đáp ứng chứa thông tin thanh toán thành công hay không.
SOAP request
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:env=“http://www.w3.org/2003/05/soap-envelope”
xmlns:m="http://www.khachsanA.com/paymentresponse">
>
<env:Header>
</env:Header>
<soap:Body>
<m:Payment>
<m:CustomerName>Tran Xuan Hung</m:CustomerName>
<m:CardType>Visa</m:CardType>
<m:CardNumber>003429236323</m:CardNumber>
<m:CVCNumber>083</m:CVCNumber>
<m:DueDate>2022-12-31</m:CVCNumber>
</m:Payment>
</soap:Body>
</soap:Envelope>
SOAP response
<soap:Body>
<m:PaymentResponse>
<m:Message>Success</m:CustomerName>
</m:PaymentResponse>
</soap:Body>
</soap:Envelope>
2. Giả sử ta có phương thức Java cho phép kiểm tra trạng thái của một đơn hàng
checkOrderStatus(String OrderNumber, String companyID) có thể gọi thông qua
tham số : ("ZRA56782C", "Mega Electronics Ltd."). Viết thông điệp SOAP yêu cầu,
theo mô hình RPC để lấy về kết quả. SOAP kết quả chưa thông tin trạng thái của
đơn hàng (Đang xử lý, Xử lý xong ... )
SOAP request:
<env:Envelope
xmlns:env=“http://www.w3.org/2003/05/soap-envelope”
xmlns:m="http://www.hung.com/checkorderstatus">
<env:Header>
<tx:Transaction-id xmlns:t=”http://www.transaction.com/transactions”
env:mustUnderstand='1'>
512
</tx:Transaction-id>
</env:Header>
<env:Body>
<m:CheckOrderStatus>
<order-number> ZRA56782C </order-number >
<company-id> Mega Electronics Ltd </company-id >
</m:CheckOrderStatus >
</env:Body>
</env:Envelope>
SOAP response:
<env:Envelope
xmlns:env=“http://www.w3.org/2003/05/soap-envelope”
xmlns:m="http://www.plastics_supply.com/checkorderstatusresponse">
<env:Header>
<--! – Optional context information -->
</env:Header>
<env:Body>
<m:CheckOrderStatusResponse>
<order-status> processing </order-status>
</m:CheckOrderStatusResponse>
</env:Body>
</env:Envelope>
SOAP request:
<?xml version="1.0"?>
<env:Envelope
xmlns:env="http://www.w3.org/2003/05/soap-envelope/"
soap:encodingStyle="http://www.w3.org/2003/05/soap-encoding">
<env:Header>
</env:Header>
<env:Body>
<c:CheckItemRequest xmlns:tns="http://www.webserviceX.net">
<c:itemID>98752</c:itemID>
<c:itemQuantity>10</c:itemQuantity>
<c:CheckItemRequest>
</env:Body>
</env:Envelope>
SOAP response
<?xml version="1.0"?>
<env:Envelope
xmlns:env="http://www.w3.org/2003/05/soap-envelope/"
env:encodingStyle="http://www.w3.org/2003/05/soap-encoding">
<env:Header>
</env:Header>
<env:Body>
<c:CheckItemResponse xmlns:tns="http://www.webserviceX.net">
<c:result>True</c:result>
<c:CheckItemResponse>
</env:Body>
</env:Envelope>