TAILIEUCHUNG - PHP Programming with PEARXML, Data, Dates, Web Services, and Web APIs - Part 8

Để tạo ra một dịch vụ mới, chúng tôi sẽ có để bọc logic kinh doanh của chúng tôi với một getRecordsService mới () chức năng, chất chiết xuất từ các tham số nghệ sĩ từ các RPC_Message XML_ và kêu gọi các getRecords () chức năng với chuỗi này: getRecordsService chức năng ($ args) {$ nghệ sĩ = $ args-getParam (0)-scalarval (), $ hồ sơ = getRecords (nghệ sĩ);} | Chapter 4 In order to create a new service we will have to wrap our business logic with a new getRecordsService function which extracts the artist parameter from the XML_ RPC_Message and calls the getRecords function with this string function getRecordsService args artist args- getParam 0 - scalarval records getRecords artist After calling getRecords the records variable should either contain an array or return false if the artist is unknown. We could try just returning this value and hope that the rest of the service will work automatically. But sadly enough this will not work. Instead we have to encode the return value of the function as an XML_RPC_ Value and enclose this value in an XML_RPC_Response function getRecordsService args artist args- getParam 0 - scalarval records getRecords artist val XML_RPC_encode records response new XML_RPC_Response val return response This works exactly like encoding the values on the client and creating a new message. Now all that is left to do is create a new server and register this wrapper function as an XML-RPC function. Here is the code required for the complete server Include the actual business logic require_once Include the XML-RPC server class require_once XML RPC XML-RPC wrapper for this business logic @access public @param XML_RPC_Message The message send by the client @return XML_RPC_Response The encoded server response 199 Web Services function getRecordsService args artist args- getParam 0 - scalarval records getRecords artist val XML_RPC_encode records response new XML_RPC_Response val return response map XML-RPC method names to PHP function map array array function getRecordsService create and start the service server new XML_RPC_Server map The map array that is passed to the constructor of the XML_RPC_Server class is used to map the exposed RPC methods to the matching PHP function. The server will pass the XML_RPC_Message received as the sole argument to this PHP .

TỪ KHÓA LIÊN QUAN
TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.